Skip to content

Commit 6dcb67e

Browse files
committed
refactor: solvability checks in separate method
1 parent 7fad40e commit 6dcb67e

File tree

1 file changed

+40
-18
lines changed

1 file changed

+40
-18
lines changed

conda_forge_tick/auto_tick.py

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,43 @@ def _handle_solvability_error(
397397
vpri["new_version_attempts"][_new_ver] -= 0.8
398398

399399

400+
def _check_and_process_solvability(
401+
migrator: Migrator, context: FeedstockContext, base_branch: str
402+
) -> bool:
403+
"""
404+
If the migration needs a solvability check, perform the check. If the recipe is not solvable, handle the error
405+
by setting the corresponding fields in the feedstock attributes.
406+
If the recipe is solvable, reset the fields that track the solvability check status.
407+
408+
:param migrator: The migrator that was run
409+
:param context: The current FeedstockContext of the feedstock that was migrated
410+
:param base_branch: The branch of the feedstock repository that is the migration target
411+
412+
:returns: True if the migration can proceed normally, False if a required solvability check failed and the migration
413+
needs to be aborted
414+
"""
415+
if not _is_solvability_check_needed(migrator, context, base_branch):
416+
return True
417+
418+
solvable, solvability_errors, _ = is_recipe_solvable(
419+
str(context.local_clone_dir),
420+
build_platform=context.attrs["conda-forge.yml"].get(
421+
"build_platform",
422+
None,
423+
),
424+
)
425+
if solvable:
426+
_reset_pre_pr_migrator_fields(
427+
context.attrs,
428+
get_migrator_name(migrator),
429+
is_version=isinstance(migrator, Version),
430+
)
431+
return True
432+
433+
_handle_solvability_error(solvability_errors, context, migrator, base_branch)
434+
return False
435+
436+
400437
def get_spoofed_closed_pr_info() -> PullRequestInfoSpecial:
401438
return PullRequestInfoSpecial(
402439
id=str(uuid4()),
@@ -501,24 +538,9 @@ def run(
501538
else:
502539
rerender_info = _RerenderInfo(nontrivial_migration_yaml_changes=False)
503540

504-
if _is_solvability_check_needed(migrator, context, base_branch):
505-
solvable, solvability_errors, _ = is_recipe_solvable(
506-
str(context.local_clone_dir),
507-
build_platform=context.attrs["conda-forge.yml"].get(
508-
"build_platform",
509-
None,
510-
),
511-
)
512-
if not solvable:
513-
_handle_solvability_error(
514-
solvability_errors, context, migrator, base_branch
515-
)
516-
shutil.rmtree(context.local_clone_dir)
517-
return False, False
518-
else:
519-
_reset_pre_pr_migrator_fields(
520-
context.attrs, migrator_name, is_version=is_version_migration
521-
)
541+
if not _check_and_process_solvability(migrator, context, base_branch):
542+
logger.warning("Skipping migration due to solvability check failure")
543+
return False, False
522544

523545
pr_data: PullRequestData | PullRequestInfoSpecial | None = None
524546
"""

0 commit comments

Comments
 (0)