run compat checks when old rc found

(also removed legacy-delegation sugar script)
This commit is contained in:
Sitaram Chamarty 2012-03-22 06:17:34 +05:30
parent 8dc43affdb
commit 1c590e633f
5 changed files with 69 additions and 34 deletions

60
src/Gitolite/Compat.pm Normal file
View file

@ -0,0 +1,60 @@
#!/usr/bin/perl
# a quick and dirty program to warn about compatibilities issues in your
# current gitolite 2 setup, with the new one.
@EXPORT = qw(
);
use Exporter 'import';
use lib $ENV{GL_BINDIR};
use Gitolite::Common;
my $header_printed = 0;
my $glrc = "$ENV{HOME}/.gitolite.rc";
do "$glrc";
if (defined($GL_ADMINDIR)) {
check_compat();
if ($header_printed) {
say2 "Please read the documentation for additional details on migrating.\n\n"
} else {
say2 "
It looks like there were no real issues found, but you should still read the
documentation for additional details on migrating.
";
}
}
sub check_compat {
chdir($GL_ADMINDIR) or die "FATAL: could not chdir to $GL_ADMINDIR\n";
my $conf = `find . -name "*.conf" | xargs cat`;
g2warn("MUST fix", "fallthru in NAME rules; this affects user's push rights")
if $conf =~ m(NAME/);
g2warn("MUST fix", "subconf command in admin repo; this affects conf compilation")
if $conf =~ m(NAME/conf/fragments);
}
sub header {
return if $header_printed;
$header_printed++;
say2 "
The following is a list of compat issues found, if any. Please see the
compatibility with gitolite 2' section of the documentation for additional
details on each issue found.\n";
}
sub g2warn {
my ($cat, $msg) = @_;
header();
say2 "$cat: $msg\n";
}
1;

View file

@ -57,7 +57,13 @@ my $current_data_version = "3.0";
my $rc = glrc('filename'); my $rc = glrc('filename');
do $rc if -r $rc; do $rc if -r $rc;
_die "$rc seems to be for older gitolite" if defined($GL_ADMINDIR); if (defined($GL_ADMINDIR)) {
say2 "";
say2 "FATAL: $rc seems to be for older gitolite; checking compat";
require Gitolite::Compat;
exit 1;
}
# let values specified in rc file override our internal ones # let values specified in rc file override our internal ones
@rc{ keys %RC } = values %RC; @rc{ keys %RC } = values %RC;
@ -246,7 +252,6 @@ __DATA__
SYNTACTIC_SUGAR => SYNTACTIC_SUGAR =>
[ [
# 'continuation-lines', # 'continuation-lines',
'legacy-delegation-abort',
], ],
# comment out or uncomment as needed # comment out or uncomment as needed

View file

@ -1,26 +0,0 @@
# vim: syn=perl:
# "sugar script" (syntactic sugar helper) for gitolite3
# Aborts if you appear to be using legacy delegation.
# Note: you cannot fix this using sugar; subconf processing has already
# happened by the time it gets to this point.
# TODO: supply doc keyword, and that doc should tell people to add this to the
# end of the main conf file:
# repo gitolite-admin
# - NAME/ = @all
# subconf "fragments/*.conf"
sub sugar_script {
Gitolite::Common::trace( 2, "running 'legacy-delegation-warn' sugar script..." );
my $lines = shift;
my $text = join("\n", @$lines);
if ($text =~ m(NAME/conf/fragments/) and $text !~ /^subconf /m) {
die "\t**** ABORT ****\nYou may be using legacy delegation; see docs\n";
}
return $lines;
}

View file

@ -9,7 +9,7 @@ use Gitolite::Test;
# delegation tests -- part 1 # delegation tests -- part 1
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
try "plan 55"; try "plan 53";
try " try "
DEF SP_1 = git add conf ; ok; git commit -m %1; ok; /master.* %1/ DEF SP_1 = git add conf ; ok; git commit -m %1; ok; /master.* %1/
@ -33,7 +33,6 @@ confreset;confadd '
subconf "fragments/*.conf" subconf "fragments/*.conf"
'; ';
try "ADMIN_PUSH set1; !/FATAL/" or die text(); try "ADMIN_PUSH set1; !/FATAL/" or die text();
try "/ABORT/; /legacy delegation/";
mkdir "conf/fragments"; mkdir "conf/fragments";
put "conf/fragments/u1r.conf", ' put "conf/fragments/u1r.conf", '

View file

@ -9,7 +9,7 @@ use Gitolite::Test;
# delegation tests -- part 2 # delegation tests -- part 2
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
try "plan 56"; try "plan 54";
try " try "
DEF SP_1 = git add conf ; ok; git commit -m %1; ok; /master.* %1/ DEF SP_1 = git add conf ; ok; git commit -m %1; ok; /master.* %1/
@ -35,9 +35,6 @@ confreset;confadd '
'; ';
try "ADMIN_PUSH set1; !/FATAL/" or die text(); try "ADMIN_PUSH set1; !/FATAL/" or die text();
try "
/ABORT/; /legacy delegation/
";
try "mkdir -p conf/fragments; ok"; try "mkdir -p conf/fragments; ok";