Add auto-tags via git hooks

This commit is contained in:
Dan Buch 2019-03-28 10:02:06 -04:00
parent 1c70d8890b
commit 7df3d4bb22
Signed by: meatballhat
GPG Key ID: 9685130D8B763EA7
6 changed files with 67 additions and 0 deletions

24
config/git_template/hooks/ctags Executable file
View 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 "${@}"

View 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 "${@}"

View 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 "${@}"

View 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 "${@}"

View 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 "${@}"

View File

@ -65,3 +65,6 @@
[gpg] [gpg]
program = gpg2 program = gpg2
[init]
templatedir = ~/.config/git_template