From afcd974afab9cdd9da23107723ca62d7f52293d0 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Thu, 15 Mar 2012 19:14:40 +0530 Subject: [PATCH] record and maintain a 'version' (for info and elsewhere) --- src/Gitolite/Rc.pm | 13 ++++++++++++- src/Gitolite/Setup.pm | 3 +++ src/commands/info | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Gitolite/Rc.pm b/src/Gitolite/Rc.pm index 139d6e3..f276fc2 100644 --- a/src/Gitolite/Rc.pm +++ b/src/Gitolite/Rc.pm @@ -7,6 +7,7 @@ package Gitolite::Rc; %rc glrc query_rc + version $REMOTE_COMMAND_PATT $REF_OR_FILENAME_PATT @@ -102,7 +103,7 @@ sub glrc { } # ---------------------------------------------------------------------- -# implements 'gitolite query-rc' +# implements 'gitolite query-rc' and 'version' # ---------------------------------------------------------------------- # ---------------------------------------------------------------------- @@ -131,6 +132,16 @@ sub query_rc { exit 1; } +sub version { + my $version = ''; + $version = '(unknown)'; + for ("$rc{GL_ADMIN_BASE}/VERSION") { + $version = slurp($_) if -r $_; + } + chomp($version); + return $version; +} + # ---------------------------------------------------------------------- =for args diff --git a/src/Gitolite/Setup.pm b/src/Gitolite/Setup.pm index 20143f0..3b5f37a 100644 --- a/src/Gitolite/Setup.pm +++ b/src/Gitolite/Setup.pm @@ -95,6 +95,9 @@ sub setup_gladmin { _mkdir( $rc{GL_ADMIN_BASE} ); _chdir( $rc{GL_ADMIN_BASE} ); + tsh_try("cd \$GL_BINDIR; git describe --tags --long --dirty=-dt 2>/dev/null") + and _print("VERSION", tsh_text()); + _mkdir("conf"); my $conf; { diff --git a/src/commands/info b/src/commands/info index 6672aeb..726b0d8 100755 --- a/src/commands/info +++ b/src/commands/info @@ -19,6 +19,8 @@ usage() if @ARGV; my $user = $ENV{GL_USER} or _die "GL_USER not set"; my $ref = 'any'; +print "hello $user, this is gitolite3 " . version() . " on git " . substr(`git --version`, 12) . "\n"; + my $lr = lister_dispatch('list-repos'); my $lm = lister_dispatch('list-members');