e6df0e036e39bcc2c20d7feaef1749d3c4f2768f

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Clean up and refactor code in svn plugin

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
  2index e95ee9d995213e13a50ab67dbf9303086f6e6bc4..fbc9ee5387e40feaf74a7c6b319f9a062a3aace0 100644
  3--- a/plugins/svn/svn.plugin.zsh
  4+++ b/plugins/svn/svn.plugin.zsh
  5@@ -1,9 +1,7 @@
  6-# vim:ft=zsh ts=2 sw=2 sts=2
  7-#
  8-function svn_prompt_info() {
  9+svn_prompt_info() {
 10   local _DISPLAY
 11   if in_svn; then
 12-    if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
 13+    if [[ "$SVN_SHOW_BRANCH" = true ]]; then
 14       unset SVN_SHOW_BRANCH
 15       _DISPLAY=$(svn_get_branch_name)
 16     else
 17@@ -16,21 +14,18 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_S
 18 }
 19 
 20 
 21-function in_svn() {
 22-  if $(svn info >/dev/null 2>&1); then
 23-    return 0
 24-  fi
 25-  return 1
 26+in_svn() {
 27+  svn info >/dev/null 2>&1
 28 }
 29 
 30-function svn_get_repo_name() {
 31+svn_get_repo_name() {
 32   if in_svn; then
 33     LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT
 34     LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p"
 35   fi
 36 }
 37 
 38-function svn_get_branch_name() {
 39+svn_get_branch_name() {
 40   local _DISPLAY=$(
 41     LANG=C svn info 2> /dev/null | \
 42       awk -F/ \
 43@@ -44,24 +39,28 @@ function svn_get_branch_name() {
 44         } \
 45       }'
 46   )
 47-  
 48-  if [ "x$_DISPLAY" = "x" ]; then
 49+
 50+  if [[ -z "$_DISPLAY" ]]; then
 51     svn_get_repo_name
 52   else
 53     echo $_DISPLAY
 54   fi
 55 }
 56 
 57-function svn_get_rev_nr() {
 58+svn_get_rev_nr() {
 59   if in_svn; then
 60     LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p'
 61   fi
 62 }
 63 
 64-function svn_dirty_choose() {
 65+svn_dirty() {
 66+  svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
 67+}
 68+
 69+svn_dirty_choose() {
 70   if in_svn; then
 71-    local root=`LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
 72-    if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
 73+    local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p')
 74+    if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
 75       # Grep exits with 0 when "One or more lines were selected", return "dirty".
 76       echo $1
 77     else
 78@@ -71,14 +70,13 @@ function svn_dirty_choose() {
 79   fi
 80 }
 81 
 82-function svn_dirty() {
 83-  svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN
 84+svn_dirty_pwd () {
 85+  svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
 86 }
 87 
 88-function svn_dirty_choose_pwd () {
 89+svn_dirty_choose_pwd () {
 90   if in_svn; then
 91-    local root=$PWD
 92-    if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
 93+    if svn status "$PWD" 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then
 94       # Grep exits with 0 when "One or more lines were selected", return "dirty".
 95       echo $1
 96     else
 97@@ -87,9 +85,3 @@ function svn_dirty_choose_pwd () {
 98     fi
 99   fi
100 }
101-
102-function svn_dirty_pwd () {
103-  svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD
104-}