Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: add support for stgit in VCS_Info
- X-seq: zsh-workers 26980
- From: Julien Langer <julien.langer@xxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: add support for stgit in VCS_Info
- Date: Fri, 22 May 2009 17:45:43 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=yS/5ef7GDXobwHqrqRoD7Gl7lzq8EyqwKN1PkOGfPSM=; b=aky5I1AEqeMox3VPdDhUr7AopNbpwSRDqPRnp0gS8Pxl+Pd4Jn67m++QF7MUAkm940 FylUF7ypJqXNMOEu7h8mmXoqxtlIOSYwX80jUbwJN0arZ2a4NJQ2By/68vx+ZKV0L8pu TiMK8SkHIbZ2v5qpwCnHFJ7gaoyq6o5G6CKzU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Wf8/YPw4tWwtNacZl43pcwTJQprhSlIC8EhHeExBMn5NxFnblIYJV8Zd6VEU+CQxCP cCsTa+pERDpOaYHwO75rftYhBuVe3v4avw8vjJ0BDCVHarGlmwys5YKAJbiEWx0xwJa4 FWvAnBZKbXFnrl9g3NF0G6wCwknvgqx89FNBc=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This patch adds some support for stgit to VCS_Info. It displays the currently active patch and the number of unapplied patches.
The additional info is configured via a new "stgitformat" style and is put into the "misc" part of the prompt. I don't know if this is the best idea, what do you (Frank?) think?
-Julien
add support for stgit
From: Julien Langer <julien.langer@xxxxxxxxx>
---
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 47 +++++++++++++++++++++
1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index faab2b8..d30938d 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -89,6 +89,36 @@ VCS_INFO_git_getbranch () {
return 0
}
+VCS_INFO_git_get_stgit_top_patch () {
+ local patchdir=$1
+
+ if [[ -d "$patchdir" ]]; then
+ local -a patches
+ patches=(${(f)"$(< "${patchdir}/applied")"})
+ printf '%s' $patches[-1]
+ return 0
+ fi
+
+ return 1
+}
+
+VCS_INFO_git_get_stgit_unapplied() {
+ local patchdir=$1
+
+ if [[ -d "$patchdir" ]]; then
+ local -a patches
+ patches=(${(f)"$(< "${patchdir}/unapplied")"})
+ if [[ -z $patches[@] ]]; then
+ printf 0
+ else
+ printf '%d' $#patches
+ fi
+ return 0
+ fi
+
+ return 1
+}
+
gitdir=${vcs_comm[gitdir]}
gitbranch="$(VCS_INFO_git_getbranch ${gitdir})"
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision && \
@@ -117,5 +147,20 @@ VCS_INFO_adjust
gitaction="$(VCS_INFO_git_getaction ${gitdir})"
gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}}
rrn=${gitbase:t}
-VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" ''
+
+local patchdir=${gitdir}/patches/${gitbranch}
+if [[ -d $patchdir ]] ; then
+ stgitpatch=$(VCS_INFO_git_get_stgit_top_patch "${patchdir}")
+ stgitunapplied=$(VCS_INFO_git_get_stgit_unapplied "${patchdir}")
+
+ stgitpatch=${stgitpatch:-"no patch applied"}
+
+ zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" stgitformat stgitmsg || stgitmsg=" %p (%c)"
+ zformat -f stgitmsg "${stgitmsg}" "p:${stgitpatch}" "c:${stgitunapplied}"
+ gitmisc=${stgitmsg}
+else
+ gitmisc=''
+fi
+
+VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" "${gitmisc}"
return 0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author