3 # print vpnc version from file VERSION, appending the string printed
4 # by svnversion(1) if appropriate
8 git rev-parse
--is-inside-work-tree > /dev
/null
2>&1
14 # search for svn-remote defined in git configuration
16 while read key value
; do
17 svn_url_pattern
="${svn_url_pattern}\\|${value}"
19 $(git config --get-regexp '^svn-remote\..*\.url$' 2>/dev/null)
22 # exit if no svn-remote defined
23 if [ -z "${svn_url_pattern}" ]; then
27 # scan git-log for latest commit from any svn-remote above
28 set -- $
(git log
--first-parent -1 \
29 --grep="^git-svn-id: \(${svn_url_pattern#??}\)@" 2>/dev
/null
)
31 # check commit hash is 40 hex digits
33 if [ ${#svn_commit} -ne 40 -o -z "${svn_commit##*[!0-9a-f]*}" ]; then
37 # check svn version is numeric
40 if [ -z "${svn_ver}" -o -z "${svn_ver##*[!0-9]*}" ]; then
44 if [ $
(git rev-list HEAD...
${svn_commit} |
wc -l) -eq 0 ]; then
45 if [ `git status -s | grep -vc '^??'` -eq 0 ]; then
46 # no git commits and tree clean
51 # there are local git commits after latest svn commit or tree is dirty
56 _version
="`cat VERSION`"
59 if which svnversion
> /dev
/null
; then
60 _version
="$_version-`svnversion`"
62 _version
="$_version-`sed -n '/^dir$/{n;p;q;}' .svn/entries`"
64 elif which git
> /dev
/null
&& in_git_repository
; then
65 git_ext
=$
(git_svn_version
)
66 if [ -n "${git_ext}" ]; then
67 _version
="$_version-${git_ext}"