Skip to content

Commit bb1bcc7

Browse files
committed
Step: Update makefile with install-hooks target
1 parent 9b00668 commit bb1bcc7

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ docs-serve:
1111

1212
docs-build:
1313
@mkdocs build
14+
15+
install-hooks:
16+
ln -sf ../../.gemini/hooks/pre-commit.py .git/hooks/pre-commit
17+
chmod +x .git/hooks/pre-commit

tests/test_hooks.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ def test_journal_mtime_validation_success(self):
6969

7070
# Hook should succeed
7171
result = subprocess.run(["python3", "../.gemini/hooks/pre-commit.py"], capture_output=True, text=True)
72-
if result.returncode != 0:
73-
print(f"\nHOOK FAILED (rc={result.returncode})")
74-
print(f"STDOUT: {result.stdout}")
75-
print(f"STDERR: {result.stderr}")
7672
self.assertEqual(result.returncode, 0)
7773
self.assertIn("Validation passed", result.stdout)
7874

@@ -115,5 +111,24 @@ def test_ignore_gemini_files(self):
115111
# But it shouldn't fail with "Updated journal required"
116112
self.assertNotIn("Updated journal required", result.stdout + result.stderr)
117113

114+
def test_install_hooks(self):
115+
# Create a dummy pre-commit script in the test repo so the symlink is not dangling
116+
os.makedirs(".gemini/hooks", exist_ok=True)
117+
with open(".gemini/hooks/pre-commit.py", "w") as f:
118+
f.write("#!/usr/bin/env python3\npass")
119+
120+
# Create a makefile with install-hooks target (the one we'll implement)
121+
# For now, we'll use the real makefile from the project
122+
shutil.copy("../makefile", "makefile")
123+
124+
# Run make install-hooks
125+
result = subprocess.run(["make", "install-hooks"], capture_output=True, text=True)
126+
self.assertEqual(result.returncode, 0)
127+
128+
# Check if the hook is linked
129+
hook_path = ".git/hooks/pre-commit"
130+
self.assertTrue(os.path.exists(hook_path))
131+
self.assertTrue(os.access(hook_path, os.X_OK))
132+
118133
if __name__ == "__main__":
119134
unittest.main()

0 commit comments

Comments
 (0)