1313
1414from upgrade_dependencies .dependency import GitHubDependency , PyPIDependency
1515from upgrade_dependencies .project import Project
16- from upgrade_dependencies .utils import run_shell_command
16+ from upgrade_dependencies .utils import get_git_status , run_shell_command
1717
1818if TYPE_CHECKING :
1919 from upgrade_dependencies .dependency import Dependency
@@ -330,22 +330,24 @@ def update(
330330 version: _description_
331331 project_path: _description_
332332 """
333- # TODO: print status
333+ # TODO: print status of update
334334 project = Project (
335335 project_path = project_path ,
336336 gh_pat = GH_PAT ,
337337 )
338338
339+ # search for dependency and save old version
339340 try :
340341 dep = project .get_dependency (name = dependency )
341342 old_ver = str (sorted (dep .specifier , key = str )[0 ].version )
342343 except RuntimeError as e :
343344 rprint (f"Cannot find { dependency } in { project .name } ." )
344345 raise typer .Exit (code = 1 ) from e
345346
347+ # fetch data from pypi/github
346348 asyncio .run (dep .save_data ())
347349
348- # get version
350+ # get latest/desired version
349351 if version is None :
350352 version = str (dep .get_latest_version ())
351353
@@ -358,11 +360,19 @@ def update(
358360
359361 run_shell_command (["git" , "checkout" , "-b" , branch_name ])
360362
363+ # get status of files before changes
364+ files_before = get_git_status ()
365+
361366 # update dependency
362367 project .update_dependency (dependency = dep , version = version )
363368
364- # stage changes - TODO: get files that are changed
365- run_shell_command (["git" , "add" , ".github/" ])
369+ # get status of files after changes
370+ files_after = get_git_status ()
371+
372+ # get only the files that were changed
373+ changed_files = [f for f in files_after if f not in files_before ]
374+
375+ run_shell_command (["git" , "add" , * changed_files ])
366376
367377 # commit the changes
368378 if isinstance (dep , GitHubDependency ) and dep .action :
0 commit comments