Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug ErrorReturnCode exception of sh library #26

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,20 @@ def apply_patch(branch, comm_ci):
conflict_files = []
try:
git('cherry-pick', git_commit.sha)
except Exception as e:
except sh.ErrorReturnCode as e:
err = str(e)
print(">>> Fail to apply the patch to branch {}, cause: {}".format(branch, err))
if err.find('more, please see e.stdout') >= 0 and isinstance(e, sh.ErrorReturnCode):
ee = sh.ErrorReturnCode(e)
print(">>> DEBUG: stdout of ErrorReturnCode: {}".format(ee.stdout))
conflict_files = conflict_file_list(ee.stdout)
else:
conflict_files = conflict_file_list(err.splitlines())
if err.find('more, please see e.stdout') >= 0:
err = e.stdout
conflict_files = conflict_file_list(err.splitlines())
git('cherry-pick', '--abort')
overwrite_conflict_files(git_commit)
commit_changes(comm_ci)
stopped = True

try:
git.push("-u", "origin", branch)
except Exception as e:
except sh.ErrorReturnCode as e:
print(">>> Fail to push branch({}) to origin, caused by {}".format(branch, e))

return (stopped, conflict_files)
Expand Down