Skip to content

Commit c0df2e2

Browse files
committed
git hooks for rag indexing
1 parent 4973cc4 commit c0df2e2

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

.githooks.setup.fish

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env fish
2+
git config core.hooksPath .githooks

.githooks/post-checkout

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env fish
2+
3+
# Skip when it's not a branch checkout
4+
# i.e. grstr == git restore --staged
5+
# also, git checkout -- file
6+
set is_branch "$argv[3]" # 1 means branch, 0 means no
7+
if test "$is_branch" = 0
8+
# FYI get rid of this output once I am happy with this hook not triggering
9+
echo "skipping post-checkout hook b/c no branch set: '$is_branch'"
10+
exit 0
11+
end
12+
13+
echo "$(status current-filename) $argv"
14+
15+
# make clean && make tags
16+
rag_indexer --githook

.githooks/post-commit

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env fish
2+
3+
echo "$(status current-filename) $argv"
4+
5+
if test -d "$(git rev-parse --git-dir)/rebase-merge"
6+
or test -d "$(git rev-parse --git-dir)/rebase-apply"
7+
or test -f "$(git rev-parse --git-dir)/MERGE_HEAD"
8+
# skip for rebase/merge
9+
exit
10+
# by the way $1 seems to have # commits affected? during rebase?
11+
# 3) 2)
12+
end
13+
14+
# make clean && make tags
15+
rag_indexer --githook

.githooks/post-rewrite

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env fish
2+
3+
echo "$(status current-filename) $argv"
4+
5+
# $1 == amend/rebase
6+
# post-rewrite is called for amend and rebase
7+
if test $argv[1] = amend
8+
# amend will also trigger post-commit
9+
echo " skipping '$argv[1]'"
10+
exit
11+
end
12+
13+
# make clean && make tags
14+
rag_indexer --githook

0 commit comments

Comments
 (0)