diff options
author | Sitaram Chamarty <sitaram@atc.tcs.com> | 2012-03-19 16:15:21 +0530 |
---|---|---|
committer | Sitaram Chamarty <sitaram@atc.tcs.com> | 2012-03-24 10:30:44 +0530 |
commit | af1191902542671565c6fc82519d97818ead2760 (patch) | |
tree | 3d75e6e54d9ac86797809a33b2e56026de9ed4ed | |
parent | (minor) (diff) | |
download | gitolite-gentoo-af1191902542671565c6fc82519d97818ead2760.tar.gz gitolite-gentoo-af1191902542671565c6fc82519d97818ead2760.tar.bz2 gitolite-gentoo-af1191902542671565c6fc82519d97818ead2760.zip |
git-configs update code done
-rw-r--r-- | src/Gitolite/Rc.pm | 2 | ||||
-rwxr-xr-x | src/commands/post-compile/update-git-configs | 34 | ||||
-rwxr-xr-x | t/git-config.t | 103 |
3 files changed, 139 insertions, 0 deletions
diff --git a/src/Gitolite/Rc.pm b/src/Gitolite/Rc.pm index 5050852..d10f049 100644 --- a/src/Gitolite/Rc.pm +++ b/src/Gitolite/Rc.pm @@ -246,6 +246,7 @@ __DATA__ POST_COMPILE => [ 'post-compile/ssh-authkeys', + 'post-compile/update-git-configs', 'post-compile/update-gitweb-access-list', 'post-compile/update-git-daemon-access-list', ], @@ -254,6 +255,7 @@ __DATA__ # these will run in sequence after a new wild repo is created POST_CREATE => [ + # 'post-compile/update-git-configs', # 'post-compile/update-gitweb-access-list', # 'post-compile/update-git-daemon-access-list', ], diff --git a/src/commands/post-compile/update-git-configs b/src/commands/post-compile/update-git-configs new file mode 100755 index 0000000..df85f35 --- /dev/null +++ b/src/commands/post-compile/update-git-configs @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +# update git-config entries in each repo +# ---------------------------------------------------------------------- + +use FindBin; + +use lib $ENV{GL_BINDIR}; +use Gitolite::Rc; +use Gitolite::Common; +use Gitolite::Conf::Load; + +use strict; +use warnings; + +# ---------------------------------------------------------------------- + +my $RB = $rc{GL_REPO_BASE}; +_chdir ($RB); +my $lpr = list_phy_repos(); + +for my $pr (@$lpr) { + my $gc = git_config($pr, '.'); + while ( my ($key, $value) = each(%{ $gc }) ) { + next if $key =~ /^gitolite-options\./; + if ($value ne "") { + $value =~ s/^['"](.*)["']$/$1/; + $value =~ s/%GL_REPO/$pr/g; + 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/t/git-config.t b/t/git-config.t new file mode 100755 index 0000000..b3ea176 --- /dev/null +++ b/t/git-config.t @@ -0,0 +1,103 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# this is hardcoded; change it if needed +use lib "src"; +use Gitolite::Test; + +# git config settings +# ---------------------------------------------------------------------- + +try "plan 21"; + +try "pwd"; +my $od = text(); +chomp($od); + +# make foo.bar a valid gc key +$ENV{G3T_RC} = "$ENV{HOME}/g3trc"; +put "$ENV{G3T_RC}", "\$rc{GIT_CONFIG_KEYS} = 'foo\.bar';\n"; + +confreset;confadd ' + + repo @all + config foo.bar = dft + + repo gitolite-admin + RW+ = admin + config foo.bar = + + repo testing + RW+ = @all + + repo foo + RW = u1 + config foo.bar = f1 + + repo frob + RW = u3 + + repo bar + RW = u2 + config foo.bar = one + +'; + +try "ADMIN_PUSH set1; !/FATAL/" or die text(); + +my $rb = `gitolite query-rc -n GL_REPO_BASE`; +try " + cd $rb; ok + egrep foo\\|bar *.git/config | sort +"; +cmp 'bar.git/config: bare = true +bar.git/config: bar = one +bar.git/config:[foo] +foo.git/config: bare = true +foo.git/config: bar = f1 +foo.git/config:[foo] +frob.git/config: bar = dft +frob.git/config: bare = true +frob.git/config:[foo] +gitolite-admin.git/config: bare = true +testing.git/config: bar = dft +testing.git/config: bare = true +testing.git/config:[foo] +'; + +try "cd $od; ok"; + +confadd ' + + repo frob + RW = u3 + config foo.bar = none + + repo bar + RW = u2 + config foo.bar = one + +'; + +try "ADMIN_PUSH set1; !/FATAL/" or die text(); + +try " + cd $rb; ok + egrep foo\\|bar *.git/config | sort +"; + +cmp 'bar.git/config: bare = true +bar.git/config: bar = one +bar.git/config:[foo] +foo.git/config: bare = true +foo.git/config: bar = f1 +foo.git/config:[foo] +frob.git/config: bare = true +frob.git/config: bar = none +frob.git/config:[foo] +gitolite-admin.git/config: bare = true +testing.git/config: bar = dft +testing.git/config: bare = true +testing.git/config:[foo] +'; |