From e84f9e3d081305b0d294b9349ba60ebf2e34d6e4 Mon Sep 17 00:00:00 2001 From: John Barker & Michael Chinigo Date: Fri, 17 Aug 2012 17:45:24 -0400 Subject: [PATCH] Add some more useful git aliases - Set autosquash on - Add a bunch of useful aliases for log output and diffing the index --- recipes/git_config_global_defaults.rb | 76 +++++++++++++++------------ 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/recipes/git_config_global_defaults.rb b/recipes/git_config_global_defaults.rb index 96b4ed1e..e47b6bb3 100644 --- a/recipes/git_config_global_defaults.rb +++ b/recipes/git_config_global_defaults.rb @@ -4,50 +4,53 @@ template "#{WS_HOME}/.gitignore_global" do source "gitignore_global.erb" owner WS_USER - variables( - :ignore_idea => node[:git_global_ignore_idea] - ) + variables(:ignore_idea => node[:git_global_ignore_idea]) end execute "set global git ignore" do command "git config --global core.excludesfile #{WS_HOME}/.gitignore_global" user WS_USER - not_if "git config --global core.excludesfile | grep -q .gitignore_global" + not_if "[ -z `git config --global core.excludesfile`]" end -execute "set alias st=status" do - command "git config --global alias.st status" +execute "make the pager prettier" do + # When paging to less: + # * -x2 Tabs appear as two spaces + # * -S Chop long lines + # * -F Don't require interaction if paging less than a full screen + # * -X No scren clearing + # * -R Raw, i.e. don't escape the control characters that produce colored output + command %{git config --global core.pager "less -FXRS -x2"} user WS_USER end -execute "set alias di=diff" do - command "git config --global alias.di diff" - user WS_USER -end - -execute "set alias co=checkout" do - command "git config --global alias.co checkout" - user WS_USER -end - -execute "set alias ci=commit" do - command "git config --global alias.ci commit" - user WS_USER -end - -execute "set alias br=branch" do - command "git config --global alias.br branch" - user WS_USER -end - -execute "set alias sta=stash" do - command "git config --global alias.sta stash" - user WS_USER -end - -execute "set alias llog=log --date=local" do - command "git config --replace-all --global alias.llog 'log --date=local'" - user WS_USER +aliases =<%Creset' --abbrev-commit --date=relative\" +lol \"log --graph --decorate --oneline\" +lola \"log --graph --decorate --oneline --all\" +blog \"log origin/master... --left-right\" +ds \"diff --staged\" +fixup \"commit --fixup\" +squash \"commit --squash\" +unstage \"reset HEAD\" +rum rebase master@{u} +EOF + +aliases.split("\n").each do |alias_string| + abbrev = alias_string.split[0] + execute "set alias #{abbrev}" do + command "git config --global alias.#{alias_string}" + user WS_USER + only_if "[ -z `git config --global alias.#{abbrev}` ]" + end end execute "set apply whitespace=nowarn" do @@ -84,3 +87,8 @@ command "git config --global branch.autosetupmerge true" user WS_USER end + +execute "set rebase autosquash=true" do + command "git config --global rebase.autosquash true" + user WS_USER +end