Add auto-tags via git hooks
This commit is contained in:
parent
1c70d8890b
commit
7df3d4bb22
24
config/git_template/hooks/ctags
Executable file
24
config/git_template/hooks/ctags
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# inspired by https://tbaggery.com/2011/08/08/effortless-ctags-with-git.html
|
||||
set -o errexit
|
||||
|
||||
main() {
|
||||
local git_dir
|
||||
git_dir="$(git rev-parse --git-dir)"
|
||||
|
||||
local tmp_tags
|
||||
tmp_tags="$(mktemp)"
|
||||
|
||||
trap 'rm -f "${tmp_tags}"' EXIT
|
||||
|
||||
git ls-files |
|
||||
ctags \
|
||||
--tag-relative \
|
||||
-L - \
|
||||
-f"${tmp_tags}" \
|
||||
--languages=-javascript,sql
|
||||
|
||||
mv "${tmp_tags}" "${git_dir}/tags"
|
||||
}
|
||||
|
||||
main "${@}"
|
10
config/git_template/hooks/post-checkout
Executable file
10
config/git_template/hooks/post-checkout
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit
|
||||
|
||||
main() {
|
||||
if [[ -x .git/hooks/ctags ]]; then
|
||||
.git/hooks/ctags &>/dev/null &
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
10
config/git_template/hooks/post-commit
Executable file
10
config/git_template/hooks/post-commit
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit
|
||||
|
||||
main() {
|
||||
if [[ -x .git/hooks/ctags ]]; then
|
||||
.git/hooks/ctags &>/dev/null &
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
10
config/git_template/hooks/post-merge
Executable file
10
config/git_template/hooks/post-merge
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit
|
||||
|
||||
main() {
|
||||
if [[ -x .git/hooks/ctags ]]; then
|
||||
.git/hooks/ctags &>/dev/null &
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
10
config/git_template/hooks/post-rewrite
Executable file
10
config/git_template/hooks/post-rewrite
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit
|
||||
|
||||
main() {
|
||||
if [[ "${1}" == rebase && -x .git/hooks/ctags ]]; then
|
||||
.git/hooks/ctags &>/dev/null &
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
Loading…
Reference in New Issue
Block a user