Simpler scheme than r27195: if the gk commit file ends up being 0
bytes long, then abort the commit. This avoids asking an extra question in the most common case (where the GK doesn't edit the file at all). This commit was SVN r27198. The following SVN revision numbers were found above: r27195 --> open-mpi/ompi@70aa879ed3
Этот коммит содержится в:
родитель
6319014ab0
Коммит
de512db1fd
81
contrib/dist/gkcommit.pl
поставляемый
81
contrib/dist/gkcommit.pl
поставляемый
@ -264,26 +264,22 @@ $logentries->{$r}->{msg}\n\n";
|
||||
print "Running 'svn status'...\n";
|
||||
open(SVN, "svn status|") ||
|
||||
die "Can't open svn status";
|
||||
print FILE "--This line, and those below, will be ignored--\n";
|
||||
print FILE "--This line, and those below, will be ignored--
|
||||
|
||||
****************************************************************************
|
||||
GATEKEEPER: If you wish to abort this commit, delete all content from
|
||||
this file, save the file, and then quit your editor as normal. The
|
||||
gkcommit script will see the 0-byte file and not perform the commit.
|
||||
****************************************************************************
|
||||
|
||||
";
|
||||
|
||||
while (<SVN>) {
|
||||
print FILE $_;
|
||||
}
|
||||
close(SVN);
|
||||
close(FILE);
|
||||
|
||||
# Make a copy of the file so that we can compare it when the gk is
|
||||
# done and see if they actually made any changes.
|
||||
my $commit_file2 = File::Temp::tempnam(Cwd::cwd(), "gkcommit");
|
||||
open(IN, $commit_file) ||
|
||||
die "Can't open temp file";
|
||||
open(OUT, ">$commit_file2") ||
|
||||
die "Can't open temp file";
|
||||
while (<IN>) {
|
||||
print OUT $_;
|
||||
}
|
||||
close(OUT);
|
||||
close(IN);
|
||||
|
||||
# Now allow the gk to edit the file
|
||||
if ($dry_run_arg) {
|
||||
# Dry run -- just show what would have happened.
|
||||
@ -296,49 +292,22 @@ if ($dry_run_arg) {
|
||||
print("----------------------------------------------------------------------------\n");
|
||||
} else {
|
||||
# Let the GK edit the file
|
||||
my $done = 0;
|
||||
while (!$done) {
|
||||
if ($ENV{SVN_EDITOR}) {
|
||||
system("$ENV{SVN_EDITOR} $commit_file");
|
||||
} elsif ($ENV{EDITOR}) {
|
||||
system("$ENV{EDITOR} $commit_file");
|
||||
} else {
|
||||
system("vi $commit_file");
|
||||
}
|
||||
if (! -f $commit_file) {
|
||||
print "Commit file no longer exists! Aborting.\n";
|
||||
exit(1);
|
||||
}
|
||||
if ($ENV{SVN_EDITOR}) {
|
||||
system("$ENV{SVN_EDITOR} $commit_file");
|
||||
} elsif ($ENV{EDITOR}) {
|
||||
system("$ENV{EDITOR} $commit_file");
|
||||
} else {
|
||||
system("vi $commit_file");
|
||||
}
|
||||
if (! -f $commit_file) {
|
||||
print "Commit file no longer exists! Aborting.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
# Did the file change?
|
||||
my $rc = system("diff $commit_file $commit_file2");
|
||||
if (0 != $rc) {
|
||||
# If the diff came back different, then the file changed,
|
||||
# and we're good to go ahead and commit.
|
||||
$done = 1;
|
||||
last;
|
||||
} else {
|
||||
# Otherwise, the file didn't change, and the GK may be
|
||||
# trying to abort. Prompt them to figure out what to do.
|
||||
print "\n\nWARNING: GK commit message did not change.\n";
|
||||
my $answer;
|
||||
while (1) {
|
||||
print "(a)bort, (c)ontinue, (e)dit:\n";
|
||||
$answer = lc(<STDIN>);
|
||||
chomp($answer);
|
||||
if ($answer eq "a") {
|
||||
print "Aborted -- nothing committed\n";
|
||||
exit(0);
|
||||
} elsif ($answer eq "c") {
|
||||
$done = 1;
|
||||
last;
|
||||
} elsif ($answer eq "e") {
|
||||
last;
|
||||
} else {
|
||||
print "Unrecognized: $answer\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
# Ensure that the file is >0 bytes long
|
||||
if (-z $commit_file) {
|
||||
print "ABORT: Commit file is 0 bytes long. Nothing committed.\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user