Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#31479: lint: Disable signature output in git log
Browse files Browse the repository at this point in the history
e2d3372 lint: Disable signature output in git log (Hodlinator)

Pull request description:

  Necessary for users that have signature output enabled by default, since the script would stumble on them and error out.

  ---

  ### Testing setup

  Set local repo config to show signatures in log by default, simulating a user having that setting turned on globally.
  ```
  ₿ git config set log.showSignature true
  ```
  ### Command under test

  ```
  ₿ ( cd ./test/lint/test_runner/ && COMMIT_RANGE='HEAD^..HEAD' cargo run )
  ```
  #### Before
  ```
  ...
  fatal: invalid object name 'gpg'.
  Traceback (most recent call last):
    File "/home/hodlinator/bitcoin/test/lint/lint-git-commit-check.py", line 52, in <module>
      main()
    File "/home/hodlinator/bitcoin/test/lint/lint-git-commit-check.py", line 42, in main
      commit_info = check_output(["git", "log", "--format=%B", "-n", "1", hash], text=True, encoding="utf8").splitlines()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/nix/store/wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6/lib/python3.12/subprocess.py", line 466, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/nix/store/wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6/lib/python3.12/subprocess.py", line 571, in run
      raise CalledProcessError(retcode, process.args,
  subprocess.CalledProcessError: Command '['git', 'log', '--format=%B', '-n', '1', 'gpg: Signature made ons 11 dec 2024 10:46:34 CET']' returned non-zero exit status 128.
  ^---- ⚠️ Failure generated from lint-git-commit-check.py
  ...
  ```
  #### After

  (No failure generated by *lint-git-commit-check.py*).

ACKs for top commit:
  maflcko:
    lgtm ACK e2d3372
  willcl-ark:
    ACK e2d3372

Tree-SHA512: 584ccece1e6e0f4691683a2b1816eff33b88f48e9ead9272e2dc73ea9c637b182632108fbeddea1ffc8ed6ba5a5838d7eac7a9f33dfda5bdf325dd7a41e43365
  • Loading branch information
fanquake committed Dec 12, 2024
2 parents ea9e64f + e2d3372 commit 435ad57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/lint/lint-git-commit-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def main():
assert os.getenv("COMMIT_RANGE") # E.g. COMMIT_RANGE='HEAD~n..HEAD'
commit_range = os.getenv("COMMIT_RANGE")

commit_hashes = check_output(["git", "log", commit_range, "--format=%H"], text=True, encoding="utf8").splitlines()
commit_hashes = check_output(["git", "-c", "log.showSignature=false", "log", commit_range, "--format=%H"], text=True, encoding="utf8").splitlines()

for hash in commit_hashes:
commit_info = check_output(["git", "log", "--format=%B", "-n", "1", hash], text=True, encoding="utf8").splitlines()
commit_info = check_output(["git", "-c", "log.showSignature=false", "log", "--format=%B", "-n", "1", hash], text=True, encoding="utf8").splitlines()
if len(commit_info) >= 2:
if commit_info[1]:
print(f"The subject line of commit hash {hash} is followed by a non-empty line. Subject lines should always be followed by a blank line.")
Expand Down

0 comments on commit 435ad57

Please sign in to comment.