瀏覽代碼

update git log to use auto colours for decoration

Weiyi Lou 12 年之前
父節點
當前提交
fc38fa884f
共有 6 個文件被更改,包括 34 次插入7 次删除
  1. 1 1
      vim/bundle/gundo
  2. 1 1
      vim/bundle/snipmate
  3. 1 1
      vim/bundle/syntastic
  4. 1 1
      vim/bundle/vim-snippets
  5. 1 1
      zsh/oh-my-zsh
  6. 29 2
      zsh/omz-custom/git.zsh

+ 1 - 1
vim/bundle/gundo

@@ -1 +1 @@
-Subproject commit 4c376a8061fa335228da420937ce385b847dd56a
+Subproject commit 3975ac871565115e3769dc69c06bc88ddc1369af

+ 1 - 1
vim/bundle/snipmate

@@ -1 +1 @@
-Subproject commit 54acd6a3e03a0bb448d81d53e35b2c8b22b709bc
+Subproject commit cc708d74ad233ba625551e282f2eda08c24cc4ed

+ 1 - 1
vim/bundle/syntastic

@@ -1 +1 @@
-Subproject commit 3d614fb2bdf433422389c2db5226e135b46966aa
+Subproject commit 9f7d5d74479743291e2fb225dfcfe8a89ebc80c7

+ 1 - 1
vim/bundle/vim-snippets

@@ -1 +1 @@
-Subproject commit c8783fd02f0688612abc9cbd85edacaea2f3f319
+Subproject commit ade6f26f10c21f227dc696046446c1138561f969

+ 1 - 1
zsh/oh-my-zsh

@@ -1 +1 @@
-Subproject commit 86a889ea083d341ba2bc48656008e5af46a3df2d
+Subproject commit 7f74294d7aa7ab86e18e70a1153c15fa373c5849

+ 29 - 2
zsh/omz-custom/git.zsh

@@ -1,5 +1,33 @@
 # preferred git shortcuts, not in the git plugin
 
+#compare the provided version of git to the version installed and on path
+#prints 1 if input version <= installed version
+#prints -1 otherwise
+function git_compare_version() {
+  local INPUT_GIT_VERSION=$1;
+  local INSTALLED_GIT_VERSION
+  INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
+  INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null));
+  INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
+
+  for i in {1..3}; do
+    if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
+      echo -1
+      return 0
+    fi
+  done
+  echo 1
+}
+POST_1_8_3_GIT=$(git_compare_version "1.8.3")
+unset -f git_compare_version
+
+if [[ $POST_1_8_3_GIT -gt 0 ]]; then
+  DECO_COLOUR='%C(auto)'
+else
+  DECO_COLOUR='%Cgreen'
+fi
+GIT_LOG_FORMAT='"format:%C(yellow)%h %Creset%ad %Cblue%an:'$DECO_COLOUR'%d %Creset%s"'
+
 alias ga.='git add .'
 alias gap='git add -p'
 
@@ -11,9 +39,8 @@ alias gcob='git checkout -b'
 alias gf='git fetch --tags && git fetch --prune'
 
 alias gbd='git branch -D'
-
 # standard log with train tracks
-alias gl='git log --graph --pretty="format:%C(yellow)%h%Cgreen%d %Cblue[%an] %Creset%s... %C(cyan)%ar%Creset"'
+alias gl='git log --graph --date=short --pretty='$GIT_LOG_FORMAT
 # concise, branch and tag log with train tracks (some merge commits unavoidable)
 alias glb='gl --simplify-by-decoration'
 alias glp='git log --patch'