12
12
from rich .progress import Progress , SpinnerColumn , TextColumn
13
13
from rich .text import Text
14
14
15
+ import upgrade_dependencies .utils as utils
15
16
from upgrade_dependencies .dependency import GitHubDependency , PyPIDependency
16
17
from upgrade_dependencies .project import Project
17
- from upgrade_dependencies .utils import get_git_status , run_shell_command
18
18
19
19
if TYPE_CHECKING :
20
20
from upgrade_dependencies .dependency import Dependency
@@ -339,11 +339,11 @@ def update(
339
339
else :
340
340
branch_name = f"dependency/{ dep .short_name } -{ version } "
341
341
342
- run_shell_command (["git" , "checkout" , "-b" , branch_name ])
342
+ utils . run_shell_command (["git" , "checkout" , "-b" , branch_name ])
343
343
344
344
# get status of files before changes
345
345
progress .update (task , description = "Updating dependency..." )
346
- files_before = get_git_status ()
346
+ files_before = utils . get_git_status ()
347
347
348
348
# warning if there are changed files
349
349
if len (files_before ) > 0 :
@@ -356,16 +356,16 @@ def update(
356
356
project .update_dependency (dependency = dep , version = version )
357
357
358
358
# run uv.lock, don't worry if it doesn't work (i.e. uv not installed)
359
- run_shell_command (["uv" , "lock" ], suppress_errors = True )
359
+ utils . run_shell_command (["uv" , "lock" ], suppress_errors = True )
360
360
361
361
# get status of files after changes
362
- files_after = get_git_status ()
362
+ files_after = utils . get_git_status ()
363
363
364
364
# get only the files that were changed
365
365
changed_files = [f for f in files_after if f not in files_before ]
366
366
367
367
# git add the changed files
368
- run_shell_command (["git" , "add" , * changed_files ])
368
+ utils . run_shell_command (["git" , "add" , * changed_files ])
369
369
370
370
# commit the changes
371
371
progress .update (task , description = "Committing changes..." )
@@ -378,11 +378,11 @@ def update(
378
378
else :
379
379
commit_message = f"Bump { dep .package_name } from { old_ver } to { version } "
380
380
381
- run_shell_command (["git" , "commit" , "-m" , commit_message ])
381
+ utils . run_shell_command (["git" , "commit" , "-m" , commit_message ])
382
382
383
383
# push the branch to GitHub
384
384
progress .update (task , description = "Pushing changes to GitHub..." )
385
- run_shell_command (["git" , "push" , "origin" , branch_name ])
385
+ utils . run_shell_command (["git" , "push" , "origin" , branch_name ])
386
386
387
387
# create pr_body
388
388
progress .update (task , description = "Creating pull request..." )
@@ -400,7 +400,7 @@ def update(
400
400
pr_body = ""
401
401
402
402
# create pull request
403
- pr = run_shell_command (
403
+ pr = utils . run_shell_command (
404
404
[
405
405
"gh" ,
406
406
"pr" ,
@@ -419,13 +419,19 @@ def update(
419
419
)
420
420
421
421
# re-checkout master branch
422
- run_shell_command (["git" , "checkout" , target_branch ])
422
+ utils . run_shell_command (["git" , "checkout" , target_branch ])
423
423
424
424
msg = f"✅ [bold]{ dep .package_name } [/bold] updated! View the pull request at"
425
425
msg += f" { pr .stdout } "
426
426
rprint (msg )
427
427
428
428
429
+ @app .command ()
430
+ def format_yml ():
431
+ """Formats the workflow and pre-commit config yaml files."""
432
+ utils .format_all_yml_files ()
433
+
434
+
429
435
def main ():
430
436
"""_summary_."""
431
437
app ()
0 commit comments