From ea0c1c95be5d9d7e67cb74f3512368087146bd76 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 23 Feb 2012 13:14:23 +0100 Subject: [PATCH 1/3] add git-svn plugin with a git equivalent of svnversion --- plugins/git-svn/git-svn.plugin.zsh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 plugins/git-svn/git-svn.plugin.zsh diff --git a/plugins/git-svn/git-svn.plugin.zsh b/plugins/git-svn/git-svn.plugin.zsh new file mode 100644 index 000000000..178bb7b8d --- /dev/null +++ b/plugins/git-svn/git-svn.plugin.zsh @@ -0,0 +1,15 @@ +# +# git equivalent of svnversion +# +get_svnversion() +{ + alias git_svnversion="git svn find-rev `git log -1 --pretty=format:%H 2>/dev/null` 2>/dev/null" + LANG=C SVN_VERSION=`/usr/bin/svnversion` + if [ "X$SVN_VERSION" == "Xexported" -o "X$SVN_VERSION" == "X" ]; then + git_svnversion + else + echo $SVN_VERSION + fi +} +alias svnversion=get_svnversion + From fcd318089de1817191b862ebc7075d0995eff38b Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 23 Feb 2012 13:37:58 +0100 Subject: [PATCH 2/3] use git describe instead of git log --- plugins/git-svn/git-svn.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git-svn/git-svn.plugin.zsh b/plugins/git-svn/git-svn.plugin.zsh index 178bb7b8d..c554a0307 100644 --- a/plugins/git-svn/git-svn.plugin.zsh +++ b/plugins/git-svn/git-svn.plugin.zsh @@ -3,7 +3,7 @@ # get_svnversion() { - alias git_svnversion="git svn find-rev `git log -1 --pretty=format:%H 2>/dev/null` 2>/dev/null" + alias git_svnversion="git svn find-rev `git describe --always` 2>/dev/null" LANG=C SVN_VERSION=`/usr/bin/svnversion` if [ "X$SVN_VERSION" == "Xexported" -o "X$SVN_VERSION" == "X" ]; then git_svnversion From b3277242f0ce64f9f8752615ee87a87d3c01f0f9 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 23 Feb 2012 14:02:13 +0100 Subject: [PATCH 3/3] - move alias from git plugin to git-svn - use local variables for the get_svnversion function --- plugins/git-svn/git-svn.plugin.zsh | 19 ++++++++++++++----- plugins/git/git.plugin.zsh | 8 +------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/git-svn/git-svn.plugin.zsh b/plugins/git-svn/git-svn.plugin.zsh index c554a0307..26d49db74 100644 --- a/plugins/git-svn/git-svn.plugin.zsh +++ b/plugins/git-svn/git-svn.plugin.zsh @@ -1,14 +1,23 @@ +# Git and svn mix +alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' +compdef git-svn-dcommit-push=git + +alias gsr='git svn rebase' +alias gsd='git svn dcommit' + # # git equivalent of svnversion # get_svnversion() { - alias git_svnversion="git svn find-rev `git describe --always` 2>/dev/null" - LANG=C SVN_VERSION=`/usr/bin/svnversion` - if [ "X$SVN_VERSION" == "Xexported" -o "X$SVN_VERSION" == "X" ]; then - git_svnversion + local git_version=`git describe --always 2>/dev/null` + local git_svnversion=`git svn find-rev $git_version 2>/dev/null` + local svn_version + LANG=C svn_version=`/usr/bin/svnversion` + if [ "X$svn_version" == "Xexported" -o "X$svn_version" == "X" ]; then + echo $git_svnversion else - echo $SVN_VERSION + echo $svn_version fi } alias svnversion=get_svnversion diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index e1d682508..b2790aef7 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -39,12 +39,6 @@ compdef _git gm=git-merge alias grh='git reset HEAD' alias grhh='git reset HEAD --hard' -# Git and svn mix -alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' -compdef git-svn-dcommit-push=git - -alias gsr='git svn rebase' -alias gsd='git svn dcommit' # # Will return the current branch name # Usage example: git pull origin $(current_branch) @@ -60,4 +54,4 @@ compdef ggpull=git alias ggpush='git push origin $(current_branch)' compdef ggpush=git alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)' -compdef ggpnp=git \ No newline at end of file +compdef ggpnp=git