From a509b208e340f11bb62a113dbdf089942b229db5 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Tue, 30 Oct 2012 12:09:16 +0530 Subject: [PATCH] move %GL_REPO and %GL_CREATOR substitution into core see usage example at the end of src/triggers/upstream --- src/lib/Gitolite/Conf/Load.pm | 8 ++++++ src/triggers/post-compile/update-git-configs | 2 -- src/triggers/upstream | 26 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/lib/Gitolite/Conf/Load.pm b/src/lib/Gitolite/Conf/Load.pm index 0f76908..27f3c95 100644 --- a/src/lib/Gitolite/Conf/Load.pm +++ b/src/lib/Gitolite/Conf/Load.pm @@ -164,6 +164,14 @@ sub git_config { } } + my($k, $v); + my $creator = creator($repo); + while (($k, $v) = each %ret) { + $v =~ s/%GL_REPO/$repo/g; + $v =~ s/%GL_CREATOR/$creator/g if $creator; + $ret{$k} = $v; + } + trace( 3, map { ( "$_" => "-> $ret{$_}" ) } ( sort keys %ret ) ); return \%ret; } diff --git a/src/triggers/post-compile/update-git-configs b/src/triggers/post-compile/update-git-configs index 23458d2..64b8ed9 100755 --- a/src/triggers/post-compile/update-git-configs +++ b/src/triggers/post-compile/update-git-configs @@ -49,8 +49,6 @@ sub fixup_config { while ( my ( $key, $value ) = each( %{$gc} ) ) { next if $key =~ /^gitolite-options\./; if ( $value ne "" ) { - $value =~ s/%GL_REPO/$pr/g; - $value =~ s/%GL_CREATOR/$creator/g if $creator; system( "git", "config", "--file", "$RB/$pr.git/config", $key, $value ); } else { system( "git", "config", "--file", "$RB/$pr.git/config", "--unset-all", $key ); diff --git a/src/triggers/upstream b/src/triggers/upstream index 7c4981d..c8e8c6d 100755 --- a/src/triggers/upstream +++ b/src/triggers/upstream @@ -44,3 +44,29 @@ git fetch -q "$url" '+refs/*:refs/*' # * if the upstream URL changes, just change the conf and push admin repo # * the 'nice' setting is in minutes and is optional; it is the minimum # elapsed time between 2 upstream fetches. + +# USAGE EXAMPLE: +# +# Let's say you want to keep a read-only local mirror of all your github repos +# on your local gitolite installation. Assuming your github usernames are the +# same as your local usernames, and you have updated GIT_CONFIG_KEYS in the rc +# file to allow 'config' lines, you can do this: +# +# repo github/CREATOR/..* +# C = @all +# R = @all +# option upstream.url = git://github.com/%GL_REPO.git +# option upstream.nice = 120 +# config url.git://github.com/.insteadOf = git://github.com/github/ +# +# Now you can make local, read-only, clones of all your github repos with +# +# git ls-remote gitolite:github/sitaramc/gitolite +# git ls-remote gitolite:github/sitaramc/hap +# (etc) +# +# and if milki were also a user on this gitolite instance, then +# +# git ls-remote gitolite:github/milki/xclip +# git ls-remote gitolite:github/milki/ircblogger +# (etc)