mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 12:24:59 +00:00
fix: Move pre-commit hook creation after initial commit in test
This commit is contained in:
parent
62b52a78fe
commit
6022b09437
1 changed files with 10 additions and 10 deletions
|
@ -416,21 +416,21 @@ class TestRepo(unittest.TestCase):
|
|||
# Create a new repo
|
||||
raw_repo = git.Repo()
|
||||
|
||||
# Create a pre-commit hook that always fails
|
||||
hooks_dir = Path(raw_repo.git_dir) / "hooks"
|
||||
hooks_dir.mkdir(exist_ok=True)
|
||||
|
||||
pre_commit_hook = hooks_dir / "pre-commit"
|
||||
pre_commit_hook.write_text("#!/bin/sh\nexit 1\n") # Always fail
|
||||
pre_commit_hook.chmod(0o755) # Make executable
|
||||
|
||||
# Create a file to commit
|
||||
fname = Path("test_file.txt")
|
||||
fname.write_text("initial content")
|
||||
raw_repo.git.add(str(fname))
|
||||
|
||||
# First commit should work (hooks aren't run for initial commit)
|
||||
|
||||
# Do the initial commit
|
||||
raw_repo.git.commit("-m", "Initial commit")
|
||||
|
||||
# Now create a pre-commit hook that always fails
|
||||
hooks_dir = Path(raw_repo.git_dir) / "hooks"
|
||||
hooks_dir.mkdir(exist_ok=True)
|
||||
|
||||
pre_commit_hook = hooks_dir / "pre-commit"
|
||||
pre_commit_hook.write_text("#!/bin/sh\nexit 1\n") # Always fail
|
||||
pre_commit_hook.chmod(0o755) # Make executable
|
||||
|
||||
# Modify the file
|
||||
fname.write_text("modified content")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue