08efdcdd16bc825357dbc5a50b8d3ee762cc3508

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1400 from tresni/patch-2

Updated svn.plugin.zsh to behave more like lib/git.zsh

Diff

 1diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
 2index bd2767e3ee6b465c587c4a71777620f25183795d..7ae3897afe7f36601bfb5238c4db68e9ad047ab9 100644
 3--- a/plugins/svn/svn.plugin.zsh
 4+++ b/plugins/svn/svn.plugin.zsh
 5@@ -1,7 +1,14 @@
 6 function svn_prompt_info {
 7     if [ $(in_svn) ]; then
 8+        if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
 9+            unset SVN_SHOW_BRANCH
10+            _DISPLAY=$(svn_get_branch_name)
11+        else
12+            _DISPLAY=$(svn_get_repo_name)
13+        fi
14         echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
15-$ZSH_THEME_REPO_NAME_COLOR$(svn_get_repo_name)$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR"
16+$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR"
17+        unset _DISPLAY
18     fi
19 }
20 
21@@ -20,6 +27,16 @@ function svn_get_repo_name {
22     fi
23 }
24 
25+function svn_get_branch_name {
26+    _DISPLAY=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }')
27+    if [ "x$_DISPLAY" = "x" ]; then
28+        svn_get_repo_name
29+    else
30+        echo $_DISPLAY
31+    fi
32+    unset _DISPLAY
33+}
34+
35 function svn_get_rev_nr {
36     if [ $(in_svn) ]; then
37         svn info 2> /dev/null | sed -n s/Revision:\ //p