mirror of
https://github.com/wahyd4/gitolite.git
synced 2026-08-09 04:55:55 +10:00
update hook: squelch message for branch deletion
Ilari pointed out that in case of branch deletion the *new* SHA could be 0,
which causes an ugly
fatal: Not a valid commit name 0000000000000000000000000000000000000000
Since we consider deletion an extreme form of rewind, the end result does not
change ($merge_base will be unequal to $oldsha anyway), but we do need to
squelch the ugly message.
This commit is contained in:
+7
-3
@@ -55,17 +55,21 @@ my $ref = shift;
|
||||
my $oldsha = shift;
|
||||
my $newsha = shift;
|
||||
my $merge_base = '0' x 40;
|
||||
# compute a merge-base if both SHAs are non-0, else leave it as '0'x40
|
||||
# (i.e., for branch create or delete, merge_base == '0'x40)
|
||||
chomp($merge_base = `git merge-base $oldsha $newsha`)
|
||||
unless $oldsha eq '0' x 40;
|
||||
unless $oldsha eq '0' x 40
|
||||
or $newsha eq '0' x 40;
|
||||
|
||||
# some of this is from an example hook in Documentation/howto of git.git, with
|
||||
# some variations
|
||||
|
||||
# what are you trying to do? (is it 'W' or '+'?)
|
||||
my $perm = 'W';
|
||||
# rewriting a tag
|
||||
# rewriting a tag is considered a rewind, in terms of permissions
|
||||
$perm = '+' if $ref =~ m(refs/tags/) and $oldsha ne ('0' x 40);
|
||||
# non-ff push to branch
|
||||
# non-ff push to branch. Notice that branch delete looks like a rewind, as it
|
||||
# should
|
||||
$perm = '+' if $ref =~ m(refs/heads/) and $oldsha ne $merge_base;
|
||||
|
||||
my $allowed_refs = $repos{$ENV{GL_REPO}}{$perm}{$ENV{GL_USER}};
|
||||
|
||||
Reference in New Issue
Block a user