Skip to content

CI: Fix a bug in the cherry pick checker #8947

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

Merged
merged 1 commit into from
May 11, 2021
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
25 changes: 20 additions & 5 deletions .github/workflows/git-commit-checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def _is_entirely_submodule_updates(repo, commit):
return GOOD, "skipped (submodules updates)"

non_existent = dict()
unmerged = dict()
found_cherry_pick_line = False
for match in prog_cp.findall(commit.message):
found_cherry_pick_line = True
Expand All @@ -195,9 +196,11 @@ def _is_entirely_submodule_updates(repo, commit):
# These errors mean that the git library recognized the
# hash as a valid commit, but the GitHub Action didn't
# fetch the entire repo, so we don't have all the meta
# data about this commit. Bottom line: it's a good hash.
# So -- no error here.
pass
# data about this commit. This occurs because the commit
# only exists in an as-yet unmerged pull request on github. Therefore, we
# want to fail this commit until the corresponding pull request
# is merged.
unmerged[match] = True
except git.BadName as e:
# Use a dictionary to track the non-existent hashes, just
# on the off chance that the same non-existent hash exists
Expand All @@ -208,15 +211,27 @@ def _is_entirely_submodule_updates(repo, commit):

# Process the results for this commit
if found_cherry_pick_line:
if len(non_existent) == 0:
if len(non_existent) == 0 and len(unmerged) == 0:
return GOOD, None
else:
elif len(non_existent) > 0 and len(unmerged) == 0:
str = f"contains a cherry pick message that refers to non-existent commit"
if len(non_existent) > 1:
str += "s"
str += ": "
str += ", ".join(non_existent)
return BAD, str
elif len(non_existent) == 0 and len(unmerged) > 0:
str = f"contains a cherry pick message that refers to a commit that exists, but is in an as-yet unmerged pull request"
if len(non_existent) > 1:
str += "s"
str += ": "
str += ", ".join(unmerged)
return BAD, str
else:
str = f"contains a cherry pick message that refers to both non-existent commits and commits that exist but are in as-yet unmerged pull requests"
str += ": "
str += ", ".join(non_existent + unmerged)
return BAD, str

else:
if config['cherry pick required']:
Expand Down