Skip to content

Commit

Permalink
Introduces ctag git automation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-on-prem committed May 18, 2015
1 parent 4d76040 commit d8974f7
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 3 deletions.
23 changes: 22 additions & 1 deletion babushka-deps/dev.rb
Expand Up @@ -6,7 +6,7 @@
requires 'ag'
requires 'bower'
requires 'redis'
requires 'exuberant-ctags.pkg'
requires 'ctags'
requires 'fzf'
requires 'mlocate.managed' if Babushka::Helpers::Os.linux?
requires 'docker-main'
Expand All @@ -31,6 +31,27 @@

dep 'exuberant-ctags.pkg'

dep 'ctags' do
requires 'exuberant-ctags.pkg'

met? do
"~/.git/hooks/ctags".p.exists?
end

meet do
shell "mkdir -p ~/.git/hooks"

cd "~/.git/hooks" do
shell "ln -sf ~/.dotfiles/scripts/git-hooks/ctags.sh ~/.git/hooks/ctags"
shell "ln -sf ~/.dotfiles/scripts/git-hooks/post-rewrite.sh ~/.git/hooks/post-rewrite"
shell "ln -sf ~/.dotfiles/scripts/git-hooks/post-commit.sh ~/.git/hooks/post-commit"
shell "ln -sf ~/.dotfiles/scripts/git-hooks/post-commit.sh ~/.git/hooks/post-checkout"
shell "ln -sf ~/.dotfiles/scripts/git-hooks/post-commit.sh ~/.git/hooks/post-merge"
shell "sudo chmod +x *"
end
end
end

dep 'nvim' do
if Babushka::Helpers::Os.osx?
requires 'nvim-brew'
Expand Down
5 changes: 5 additions & 0 deletions babushka-deps/rc-files.rb
Expand Up @@ -41,6 +41,7 @@ def real_file
requires 'zlogout.rcfile'
requires 'zshenv.rcfile'
requires 'rspec.rcfile'
requires 'ctags.rcfile'
end


Expand Down Expand Up @@ -127,3 +128,7 @@ def sym_file
dep 'rspec.rcfile' do
file_name '.rspec'
end

dep 'ctags.rcfile' do
file_name '.ctags'
end
15 changes: 15 additions & 0 deletions scripts/git-hooks/ctags.sh
@@ -0,0 +1,15 @@
#!/bin/sh
IGNORE=("/usr" "${HOME}/.gem" "${HOME}/.rbenv");
for dir in "${IGNORE[@]}"
do
case "$PWD" in
${dir}*) exit 0;;
esac
done

mkdir .git/tags_lock 2>/dev/null || exit 0
trap "rmdir .git/tags_lock; rm -f .git/tags.$$" EXIT

ripper-tags -R --tag-relative -f .git/tags.$$
ctags -aR --tag-relative -f .git/tags.$$ --languages=-sql --exclude="*.rb"
mv .git/tags.$$ .git/tags
2 changes: 2 additions & 0 deletions scripts/git-hooks/post-commit.sh
@@ -0,0 +1,2 @@
#!/bin/sh
.git/hooks/ctags >/dev/null 2>&1 &
4 changes: 4 additions & 0 deletions scripts/git-hooks/post-rewrite.sh
@@ -0,0 +1,4 @@
#!/bin/sh
case "$1" in
rebase) exec .git/hooks/post-merge ;;
esac
5 changes: 5 additions & 0 deletions templates/rc-files/.ctags
@@ -0,0 +1,5 @@
--recurse=yes
--exclude=.git
--exclude=log
--languages=-javascript,sql
--append
5 changes: 4 additions & 1 deletion templates/rc-files/.gitconfig
Expand Up @@ -4,6 +4,7 @@
[color]
ui = true
[alias]
ctags = !.git/hooks/ctags
st = status -s
sb = status -s -b
#############
Expand All @@ -27,11 +28,13 @@
[core]
filemode = false
editor = vim
[init]
templatedir = ~/.git
[rerere]
enabled = true
[merge]
tool = vimdiff
defaultToUpstream = true
defaultToUpstream = true
[push]
default = tracking
[branch]
Expand Down
2 changes: 1 addition & 1 deletion templates/rc-files/.vimrc
Expand Up @@ -9,7 +9,7 @@ set nowrap " don't wrap text
set nu
set ttimeoutlen=10 "wait for 10ms after escape
set hidden "Hide the buffers
set tags=./tags "Where to find ctags
set tags=./tags,tags;$HOME "Where to find ctags
set backspace=indent,eol,start
set autoread
set noswapfile " No swp files
Expand Down

0 comments on commit d8974f7

Please sign in to comment.