fix: checkout_new works on git 2.39

git before 2.43 reads a revision after --end-of-options in checkout as a pathspec, so
every drafting run in node:22 failed with 'Cannot update paths and switch to branch'.
Option-like values are refused instead and a trailing -- keeps rev a revision. The
suite passes in node:22 (git 2.39.5, Python 3.11.2): 185 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-12 14:53:17 -05:00
1 parent cdfe3ed1ef
commit 7783b6e78f
2 files changed
+24 -2

No files matched your search

+14
View File
@@ -49,6 +49,20 @@ class TestGit(unittest.TestCase):
call()
self.assertFalse(out.exists())
def test_checkout_new_creates_branch_at_rev(self):
git.checkout_new("docs-review/pr-3", "HEAD~1", self.repo)
self.assertEqual(git.run(["rev-parse", "--abbrev-ref", "HEAD"], self.repo).strip(),
"docs-review/pr-3")
self.assertEqual(git.run(["rev-parse", "HEAD"], self.repo).strip(),
git.run(["rev-parse", "main~1"], self.repo).strip())
def test_checkout_new_refuses_option_like_values(self):
out = Path(self._tmp.name) / "x"
for branch, rev in (("b", f"--output={out}"), ("-b", "HEAD"), ("b", "")):
with self.assertRaises(git.GitError):
git.checkout_new(branch, rev, self.repo)
self.assertFalse(out.exists())
def test_merge_base_and_ls_files(self):
head = git.run(["rev-parse", "HEAD"], self.repo).strip()
self.assertEqual(git.merge_base("HEAD", "HEAD~1", self.repo),