master
リポジトリの、、、alpha
およびbeta
ブランチを誰もが削除できないようにするgitフックを設定しようとしています。誰かがこれを手伝うことができますか?私はgitフックを行ったことがないので、少しの助けなしに自分の運を試してみたくありません。
1921 次
2 に答える
8
pre-receive
フック付きで簡単。ベア セントラル リポジトリを使用していると仮定して、次のコードを に配置します。your-repo.git/hooks/pre-receive
忘れずにchmod +x your-repo.git/hooks/pre-receive
.
#! /usr/bin/perl
# create: 00000... 51b8d... refs/heads/topic/gbacon
# delete: 51b8d... 00000... refs/heads/topic/gbacon
# update: 51b8d... d5e14... refs/heads/topic/gbacon
my $errors = 0;
while (<>) {
chomp;
next
unless m[ ^
([0-9a-f]+) # old SHA-1
\s+
([0-9a-f]+) # new SHA-1
\s+
refs/heads/(\S+) # ref
\s*
$
]x;
my($old,$new,$ref) = ($1,$2,$3);
next unless $ref =~ /^(master|alpha|beta)$/;
die "$0: deleting $ref not permitted!\n"
if $new =~ /^0+$/;
}
exit $errors == 0 ? 0 : 1;
于 2010-01-07T18:25:45.570 に答える
7
「プッシュ」によるすべてのブランチの削除を喜んで拒否する場合は、リポジトリでconfig 変数receive.denyDeletes
を設定するだけです。true
update-paranoid
より高度な制御が必要な場合は、git ディストリビューションのcontrib/hooks
フォルダーからフックを確認することをお勧めします。非早送りを拒否したり、プッシュによる削除を拒否したり、より洗練された動作を実行したりできる ref acls ごとに設定できます。
update-paranoid
独自のフックを作成しなくても、必要なすべてを行う必要があります。
于 2010-01-07T18:20:37.637 に答える