Skip to content
Open
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
15 changes: 14 additions & 1 deletion contrib/verify-commits/verify-commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,20 @@ def main():
current_tree = subprocess.check_output([GIT, 'show', '--format=%T', current_commit]).decode('utf8').splitlines()[0]
subprocess.call([GIT, 'checkout', '--force', '--quiet', parents[0]])
subprocess.call([GIT, 'merge', '--no-ff', '--quiet', '--no-gpg-sign', parents[1]], stdout=subprocess.DEVNULL)
recreated_tree = subprocess.check_output([GIT, 'show', '--format=format:%T', 'HEAD']).decode('utf8').splitlines()[0]

# This merge-tree functionality requires git >= 2.38. The
# --write-tree option was added in order to opt-in to the new
# behavior. Older versions of git will not recognize the option and
# will instead exit with code 128.
try:
recreated_tree = subprocess.check_output([GIT, "merge-tree", "--write-tree", parents[0], parents[1]]).decode('utf8').splitlines()[0]
except subprocess.CalledProcessError as e:
if e.returncode == 128:
print("git v2.38+ is required for this functionality.", file=sys.stderr)
sys.exit(1)
else:
raise e
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Use bare raise to preserve traceback.

Python best practice is to use a bare raise statement without specifying the exception name to preserve the original traceback.

Apply this diff:

-                else:
-                    raise e
+                else:
+                    raise

As per static analysis hint from Ruff.

🧰 Tools
🪛 Ruff (0.14.5)

165-165: Use raise without specifying exception name

Remove exception name

(TRY201)

🤖 Prompt for AI Agents
In contrib/verify-commits/verify-commits.py around line 165, the code re-raises
an exception using "raise e" which discards the original traceback; change it to
a bare "raise" so the original traceback is preserved when propagating the
exception.


if current_tree != recreated_tree:
print("Merge commit {} is not clean".format(current_commit), file=sys.stderr)
subprocess.call([GIT, 'diff', current_commit])
Expand Down
Loading