fix(tools): handle git command failures gracefully #7456
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7456"
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?
Imported from boykopovar/AnyPS5. Originally posted by Cankiee on 2026-10-18T08:13:15Z.
What
Improve error handling in
tools/check_conventions.pywhen Git commands fail.Previously, providing an invalid base or head revision caused an unhandled
subprocess.CalledProcessErrortraceback.This PR:
Tested
Environment: Windows, Git Bash, Python 3.14.
python -m unittest discover -s tools -p "test_check_conventions_git.py" -v— passed (2 tests).python -m py_compile tools/check_conventions.py— passed.git diff --check— passed.No PS5 hardware or GPU testing required for this Python tooling change.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file (not applicable).mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by Cankiee on 2026-10-18T10:51:33Z.
I manually reviewed the overlap warning regarding #6447.
Both PRs modify
tools/check_conventions.py, but they address separate issues.PR #6447 modifies the conventions checker's handling of Markdown fences and other checks, while this PR adds error handling for failed Git subprocess calls.
I also inspected the
git()function in PR #6447 and confirmed that it retains the original implementation withoutCalledProcessErrororFileNotFoundErrorhandling.Based on this comparison, I found no duplicate implementation of the functionality introduced by this PR.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T11:28:35Z.
Review: COMMENTED
Checked on macOS, head
49c2feab7.Machine: Apple M2 Max, macOS 27.2, Xcode's
/usr/bin/python33.9.6 and Python 3.14.7.tools/test_check_conventions_git.pypasses on both Pythons. Withmain'scheck_conventions.py, both tests fail (aCalledProcessErrortraceback, exit 1), so they do cover the change.--baseor--headnow printsGit command failed: fatal: Not a valid object name ...and exits 2.The new test is not registered, so CI never runs it. The PR adds the file as
tools/test_check_conventions_git.pyand does not touchCMakeLists.txt. The othercheck_conventionstests live intools/tests/and each has anadd_testentry there (conventions_ci_gate,conventions_doc_links, ...). Nothing in.github/workflowsdiscovers loosetools/test_*.pyfiles either: the only one run directly istest_web.py. Moving the file totools/tests/and adding anadd_test(NAME conventions_git_errors ...)next to the others would get it into ctest.Minor: the tests run
check_conventions.pyfrom the current directory and only check theGit command failed:prefix. Run outside a git checkout, they pass because ofnot a git repository, not because of the invalid revision. Asserting onthis-branch-does-not-existin stderr, or passingcwdset to the repository root, would pin that down.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Cankiee on 2026-10-18T15:11:41Z.
Thanks for testing this on macOS and for the detailed feedback!
I've addressed both issues:
tools/tests/.conventions_git_errorstoCMakeLists.txtso CTest can run them.The updated Python regression tests pass locally on Windows with Python 3.14.
Thanks again for the review!
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T15:33:28Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
CMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtCMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-18T15:45:22Z.
Re-checked head
361f56a08on macOS after the changes, merged withmaine5f18ea99.Machine: Apple M2 Max, macOS 27.2, Xcode's
/usr/bin/python33.9.6 and Python 3.14.7.conventions_git_errorsis now registered and runs in ctest (relinker-only configure, x86_64 with Python 3.9.6): passes, together withtest_registration.tools/tests/test_check_conventions_git.pypasses on both Pythons, also when started from outside the checkout. Withmain'scheck_conventions.pyboth tests fail, so they still cover the change.check_conventions.py --base origin/mainpasses on the merge.Both points from my earlier review are addressed.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Cankiee on 2026-10-18T18:35:43Z.
I manually checked the CMakeLists.txt overlap warnings against all 10 flagged PRs (#674, #1835, #3998, #5021, #5710, #6044, #6746, #6879, #7201 and #7332).
None of the PR diffs adds the
conventions_git_errorsregistration or referencestest_check_conventions_git.py.Thanks to @jotitadev for independently verifying the updated implementation and tests on macOS.
As far as I can tell, there is no duplicate implementation of this test registration. The remaining warnings appear to be caused by other changes to the shared
CMakeLists.txtfile.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T10:27:39Z.
The full Build failed
conventions_git_errorson the relinker job:test_invalid_head_branchran with the default--base origin/main, which does not exist in a CI checkout, so git rejected the base first and the message never named the invalid head. I pushed a small commit to your branch (rebased on current main): each test now passesHEADfor the option it is not testing. Both tests pass; the rest is as reviewed (thegit()handling exits 2 with a readable message, and both tests fail onmain); merged.