mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:55:52 +01:00
[PR #610] [MERGED] merge_check: exit 2 when git cannot be run (MERGE-CHECK-GIT-MISSING) #650
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#650
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/610
Author: @TuroYT
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism
Base:
main← Head:fix/merge-check-git-missing📝 Commits (1)
5abe553merge_check: exit 2 when git cannot be run (MERGE-CHECK-GIT-MISSING)📊 Changes
2 files changed (+31 additions, -1 deletions)
View changed files
📝
scripts/merge_check.py(+4 -1)📝
tests/test_merge_check.py(+27 -0)📄 Description
Claimed in the coordination issue as: MERGE-CHECK-GIT-MISSING (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7127995605)
The docstring of
scripts/merge_check.py(line 21) says exit 2 on a usage or git error. Butgit()(line 45) callssubprocess.runwith no handling for a missing executable. With git not on PATH, that raisesFileNotFoundError.maincatches onlyGitError, so the script printed a traceback and exited 1.The change:
git()turns theOSErrorfromsubprocess.runintoGitError("cannot run git: <strerror>").mainalready prints aGitErrorto stderr and returns 2.git()is the only place the script runs git, so this covers every caller (prior_merges,cherry,merged_tree,rev_tree,duplicates).Before:
env PATH=/nonexistent /usr/bin/python3 -I scripts/merge_check.py 1=HEADprinted a traceback and exited 1.After: it prints
merge_check: cannot run git: No such file or directoryand exits 2.Tests added to
tests/test_merge_check.py:subprocess.runpatched to raiseFileNotFoundError; asserts exit 2, the exact message on stderr, no traceback.PATHset toos.devnull; same assertions.The first two fail on the unfixed script with 2 errors (
FileNotFoundError).Overlap with #242 and #300: both change
scripts/merge_check.pyoutsidegit(). #242 edits lines 65, 110-113 and 132 (argument order forlog,diff,show). #300 edits line 66 (splitlinestosplit). This PR changes lines 44-51 only, so the hunks do not overlap. I did not check thetests/test_merge_check.pyhunks of #242 and #300. This PR appends tests aftertest_usage_errors; if either of them also appends at the end of the class, that one will need a rebase.Tested:
python3 -m compileall -q scripts tests: exit 0.python3 -I tests/test_merge_check.py: Ran 23 tests, OK.scripts/merge_check.pyfrom origin/main: 2 errors, bothFileNotFoundError, as expected.env PATH=/nonexistent /usr/bin/python3 -I scripts/merge_check.py 1=HEAD:merge_check: cannot run git: No such file or directory, exit 2 (was a traceback and exit 1).python3 -I scripts/merge_check.pywith no arguments: argparse usage message, exit 2.python3 -I scripts/merge_check.py --repo /tmp 1=HEAD: git reports "not a git repository", exit 2.env -u PATH /usr/bin/python3 -I scripts/merge_check.py 1=HEAD: git is still found through the default search path, exit 1. This is not a missing-git case; the empty-PATH test covers that.python3 -I tests/test_text_write_line_endings.py: Ran 3 tests, OK.python3 -I scripts/check_no_game_data.py scripts/merge_check.py tests/test_merge_check.py: exit 0.Not tested: Windows (the mocked test does not depend on the platform, but the empty-PATH test checks only the message prefix there); CI on other Python versions; this branch together with #242 and #300.
AI-assisted (Claude Code).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.