mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 13:54:59 +00:00
style: Remove trailing whitespace in test_repo.py
This commit is contained in:
parent
e33dc9355d
commit
62b52a78fe
1 changed files with 12 additions and 12 deletions
|
@ -405,51 +405,51 @@ class TestRepo(unittest.TestCase):
|
||||||
git_repo = GitRepo(InputOutput(), None, None)
|
git_repo = GitRepo(InputOutput(), None, None)
|
||||||
|
|
||||||
git_repo.commit(fnames=[str(fname)])
|
git_repo.commit(fnames=[str(fname)])
|
||||||
|
|
||||||
def test_git_commit_verify(self):
|
def test_git_commit_verify(self):
|
||||||
"""Test that git_commit_verify controls whether --no-verify is passed to git commit"""
|
"""Test that git_commit_verify controls whether --no-verify is passed to git commit"""
|
||||||
# Skip on Windows as hook execution works differently
|
# Skip on Windows as hook execution works differently
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
return
|
return
|
||||||
|
|
||||||
with GitTemporaryDirectory():
|
with GitTemporaryDirectory():
|
||||||
# Create a new repo
|
# Create a new repo
|
||||||
raw_repo = git.Repo()
|
raw_repo = git.Repo()
|
||||||
|
|
||||||
# Create a pre-commit hook that always fails
|
# Create a pre-commit hook that always fails
|
||||||
hooks_dir = Path(raw_repo.git_dir) / "hooks"
|
hooks_dir = Path(raw_repo.git_dir) / "hooks"
|
||||||
hooks_dir.mkdir(exist_ok=True)
|
hooks_dir.mkdir(exist_ok=True)
|
||||||
|
|
||||||
pre_commit_hook = hooks_dir / "pre-commit"
|
pre_commit_hook = hooks_dir / "pre-commit"
|
||||||
pre_commit_hook.write_text("#!/bin/sh\nexit 1\n") # Always fail
|
pre_commit_hook.write_text("#!/bin/sh\nexit 1\n") # Always fail
|
||||||
pre_commit_hook.chmod(0o755) # Make executable
|
pre_commit_hook.chmod(0o755) # Make executable
|
||||||
|
|
||||||
# Create a file to commit
|
# Create a file to commit
|
||||||
fname = Path("test_file.txt")
|
fname = Path("test_file.txt")
|
||||||
fname.write_text("initial content")
|
fname.write_text("initial content")
|
||||||
raw_repo.git.add(str(fname))
|
raw_repo.git.add(str(fname))
|
||||||
|
|
||||||
# First commit should work (hooks aren't run for initial commit)
|
# First commit should work (hooks aren't run for initial commit)
|
||||||
raw_repo.git.commit("-m", "Initial commit")
|
raw_repo.git.commit("-m", "Initial commit")
|
||||||
|
|
||||||
# Modify the file
|
# Modify the file
|
||||||
fname.write_text("modified content")
|
fname.write_text("modified content")
|
||||||
|
|
||||||
# Create GitRepo with verify=True (default)
|
# Create GitRepo with verify=True (default)
|
||||||
io = InputOutput()
|
io = InputOutput()
|
||||||
git_repo_verify = GitRepo(io, None, None, git_commit_verify=True)
|
git_repo_verify = GitRepo(io, None, None, git_commit_verify=True)
|
||||||
|
|
||||||
# Attempt to commit - should fail due to pre-commit hook
|
# Attempt to commit - should fail due to pre-commit hook
|
||||||
commit_result = git_repo_verify.commit(fnames=[str(fname)], message="Should fail")
|
commit_result = git_repo_verify.commit(fnames=[str(fname)], message="Should fail")
|
||||||
self.assertIsNone(commit_result)
|
self.assertIsNone(commit_result)
|
||||||
|
|
||||||
# Create GitRepo with verify=False
|
# Create GitRepo with verify=False
|
||||||
git_repo_no_verify = GitRepo(io, None, None, git_commit_verify=False)
|
git_repo_no_verify = GitRepo(io, None, None, git_commit_verify=False)
|
||||||
|
|
||||||
# Attempt to commit - should succeed by bypassing the hook
|
# Attempt to commit - should succeed by bypassing the hook
|
||||||
commit_result = git_repo_no_verify.commit(fnames=[str(fname)], message="Should succeed")
|
commit_result = git_repo_no_verify.commit(fnames=[str(fname)], message="Should succeed")
|
||||||
self.assertIsNotNone(commit_result)
|
self.assertIsNotNone(commit_result)
|
||||||
|
|
||||||
# Verify the commit was actually made
|
# Verify the commit was actually made
|
||||||
latest_commit_msg = raw_repo.head.commit.message
|
latest_commit_msg = raw_repo.head.commit.message
|
||||||
self.assertEqual(latest_commit_msg, "Should succeed")
|
self.assertEqual(latest_commit_msg, "Should succeed")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue