@@ -444,9 +444,9 @@ def get_spoofed_closed_pr_info() -> PullRequestInfoSpecial:
444
444
def run_with_tmpdir (
445
445
context : FeedstockContext ,
446
446
migrator : Migrator ,
447
+ git_backend : GitPlatformBackend ,
447
448
rerender : bool = True ,
448
449
base_branch : str = "main" ,
449
- dry_run : bool = False ,
450
450
** kwargs : typing .Any ,
451
451
) -> tuple [MigrationUidTypedDict , dict ] | tuple [Literal [False ], Literal [False ]]:
452
452
"""
@@ -462,19 +462,19 @@ def run_with_tmpdir(
462
462
return run (
463
463
context = cloned_context ,
464
464
migrator = migrator ,
465
+ git_backend = git_backend ,
465
466
rerender = rerender ,
466
467
base_branch = base_branch ,
467
- dry_run = dry_run ,
468
468
** kwargs ,
469
469
)
470
470
471
471
472
472
def run (
473
473
context : ClonedFeedstockContext ,
474
474
migrator : Migrator ,
475
+ git_backend : GitPlatformBackend ,
475
476
rerender : bool = True ,
476
477
base_branch : str = "main" ,
477
- dry_run : bool = False ,
478
478
** kwargs : typing .Any ,
479
479
) -> tuple [MigrationUidTypedDict , dict ] | tuple [Literal [False ], Literal [False ]]:
480
480
"""For a given feedstock and migration run the migration
@@ -485,12 +485,12 @@ def run(
485
485
The current feedstock context, already containing information about a temporary directory for the feedstock.
486
486
migrator: Migrator instance
487
487
The migrator to run on the feedstock
488
+ git_backend: GitPlatformBackend
489
+ The git backend to use. Use the DryRunBackend for testing.
488
490
rerender : bool
489
491
Whether to rerender
490
492
base_branch : str, optional
491
493
The base branch to which the PR will be targeted.
492
- dry_run : bool, optional
493
- Whether to run in dry run mode.
494
494
kwargs: dict
495
495
The keyword arguments to pass to the migrator.
496
496
@@ -506,8 +506,6 @@ def run(
506
506
GitCliError
507
507
If an error occurs during a git command which is not suppressed
508
508
"""
509
- git_backend : GitPlatformBackend = DryRunBackend () if dry_run else github_backend ()
510
-
511
509
# sometimes we get weird directory issues so make sure we reset
512
510
os .chdir (BOT_HOME_DIR )
513
511
@@ -715,7 +713,7 @@ def _run_migrator_on_feedstock_branch(
715
713
base_branch ,
716
714
migrator ,
717
715
fctx : FeedstockContext ,
718
- dry_run ,
716
+ git_backend : GitPlatformBackend ,
719
717
mctx ,
720
718
migrator_name ,
721
719
good_prs ,
@@ -729,9 +727,9 @@ def _run_migrator_on_feedstock_branch(
729
727
migrator_uid , pr_json = run_with_tmpdir (
730
728
context = fctx ,
731
729
migrator = migrator ,
730
+ git_backend = git_backend ,
732
731
rerender = migrator .rerender ,
733
732
base_branch = base_branch ,
734
- dry_run = dry_run ,
735
733
hash_type = attrs .get ("hash_type" , "sha256" ),
736
734
)
737
735
finally :
@@ -892,7 +890,7 @@ def _is_migrator_done(_mg_start, good_prs, time_per, pr_limit):
892
890
return False
893
891
894
892
895
- def _run_migrator (migrator , mctx , temp , time_per , dry_run ):
893
+ def _run_migrator (migrator , mctx , temp , time_per , git_backend : GitPlatformBackend ):
896
894
_mg_start = time .time ()
897
895
898
896
migrator_name = get_migrator_name (migrator )
@@ -1010,14 +1008,14 @@ def _run_migrator(migrator, mctx, temp, time_per, dry_run):
1010
1008
)
1011
1009
):
1012
1010
good_prs , break_loop = _run_migrator_on_feedstock_branch (
1013
- attrs ,
1014
- base_branch ,
1015
- migrator ,
1016
- fctx ,
1017
- dry_run ,
1018
- mctx ,
1019
- migrator_name ,
1020
- good_prs ,
1011
+ attrs = attrs ,
1012
+ base_branch = base_branch ,
1013
+ migrator = migrator ,
1014
+ fctx = fctx ,
1015
+ git_backend = git_backend ,
1016
+ mctx = mctx ,
1017
+ migrator_name = migrator_name ,
1018
+ good_prs = good_prs ,
1021
1019
)
1022
1020
if break_loop :
1023
1021
break
@@ -1033,8 +1031,7 @@ def _run_migrator(migrator, mctx, temp, time_per, dry_run):
1033
1031
os .chdir (BOT_HOME_DIR )
1034
1032
1035
1033
# Write graph partially through
1036
- if not dry_run :
1037
- dump_graph (mctx .graph )
1034
+ dump_graph (mctx .graph )
1038
1035
1039
1036
with filter_reprinted_lines ("rm-tmp" ):
1040
1037
for f in glob .glob ("/tmp/*" ):
@@ -1267,13 +1264,15 @@ def main(ctx: CliContext) -> None:
1267
1264
flush = True ,
1268
1265
)
1269
1266
1267
+ git_backend = github_backend () if not ctx .dry_run else DryRunBackend ()
1268
+
1270
1269
for mg_ind , migrator in enumerate (migrators ):
1271
1270
good_prs = _run_migrator (
1272
1271
migrator ,
1273
1272
mctx ,
1274
1273
temp ,
1275
1274
time_per_migrator [mg_ind ],
1276
- ctx . dry_run ,
1275
+ git_backend ,
1277
1276
)
1278
1277
if good_prs > 0 :
1279
1278
pass
0 commit comments