Skip to content

Commit ffbaca2

Browse files
committed
refactor(hooks): improve error messages and formatting in pre-commit
1 parent e28c93b commit ffbaca2

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

.gemini/hooks/pre-commit.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,39 @@ def run_command(command):
1111
def main():
1212
today = date.today().strftime("%Y-%m-%d")
1313
journal_path = f"journal/{today}.md"
14-
14+
1515
# Scan for changes (staged, modified, untracked)
1616
# git status --porcelain shows all changes
1717
res = run_command("git status --porcelain")
1818
changed_files = [line[3:] for line in res.stdout.strip().splitlines() if line]
19-
19+
2020
if not changed_files:
2121
return 0
22-
22+
2323
# Calculate max(mtime) for all changed files (excluding .gemini/ and the journal)
2424
meaningful_changes = [f for f in changed_files if not f.startswith(".gemini/") and f != journal_path]
25-
25+
2626
if not meaningful_changes:
2727
return 0
28-
28+
2929
max_mtime = 0
3030
for f in meaningful_changes:
3131
if os.path.exists(f):
3232
mtime = os.path.getmtime(f)
3333
if mtime > max_mtime:
3434
max_mtime = mtime
35-
35+
3636
# Check journal mtime
3737
if not os.path.exists(journal_path):
38-
print(f"Error: Updated journal required ({journal_path} does not exist)")
38+
print(f"Error: Updated journal required (create {journal_path} with a summary of recent changes).")
3939
return 1
40-
40+
4141
journal_mtime = os.path.getmtime(journal_path)
42-
42+
4343
if journal_mtime < max_mtime:
44-
print("Error: Updated journal required (Today's journal must be the most recently modified file)")
44+
print(f"Error: Updated journal required (update {journal_path} to include a summary of recent changes).")
4545
return 1
46-
46+
4747
# Run make
4848
print("Running validation (make test)...")
4949
res = run_command("make test")
@@ -52,7 +52,7 @@ def main():
5252
print(res.stdout)
5353
print(res.stderr)
5454
return res.returncode
55-
55+
5656
print("Validation passed.")
5757
return 0
5858

0 commit comments

Comments
 (0)