Skip to content

Conversation

@ndhaller
Copy link
Contributor

@ndhaller ndhaller commented Jul 3, 2024

Two commits for additional error handling and clean up during the PatchSet cherry-pick from a remote source operation.

ndhaller added 2 commits July 3, 2024 15:30
If a PatchSet cherry-pick source_remote step fails after a new remote is added,
attempt to cleanup the added remote before raising exception.

Signed-off-by: Nathaniel Haller <[email protected]>
In some cases where filter settings are enabled on the repo, the git fetch
from a remote repo step will fail while the remote repo branch does exist.

Running the git fetch step again with --refetch resolved one git fetch error case
with --filter=tree:0 enabled, but adds additional time and resources to the PatchSet
creation when it is required to run.

Signed-off-by: Nathaniel Haller <[email protected]>
repo.git.execute(['git', 'fetch', operation.source_remote, operation.source_branch, '--refetch'])
except:
try:
repo.git.execute(['git', 'remote', 'remove', operation.source_remote])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding an except here to remove the remote. Let's use a finally: across the whole block.

if is_merge_conflict(repo):
repo.git.execute(['git', 'cherry-pick', '--abort'])
try:
repo.git.execute(['git', 'remote', 'remove', operation.source_remote])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding an except here to remove the remote. Let's use a finally: across the whole block.

Copy link
Contributor

@ashedesimone ashedesimone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this into two PRs

@ndhaller
Copy link
Contributor Author

Please split this into two PRs

#270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants