From: Stephen Haberman Date: Wed, 23 Jul 2008 13:20:55 +0000 (-0500) Subject: Add support for locking branches. X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=fb54ccc29ef84db56630e44636318cb2acdf0192;p=git-central.git Add support for locking branches. --- diff --git a/cbas/update b/cbas/update index a4a4374..02ed157 100755 --- a/cbas/update +++ b/cbas/update @@ -4,6 +4,7 @@ refname="$1" oldrev="$2" newrev="$3" +ruby /srv/git/hooks/server/update-lock-check.rb "$refname" "$oldrev" "$newrev" && sh /srv/git/hooks/server/update-trac "$refname" "$oldrev" "$newrev" && sh /srv/git/hooks/server/update-allow-tags-branches "$refname" "$oldrev" "$newrev" && sh /srv/git/hooks/server/update-prefer-rebase "$refname" "$oldrev" "$newrev" && diff --git a/server/locked_branches b/server/locked_branches new file mode 100644 index 0000000..e69de29 diff --git a/server/preserved_branches b/server/preserved_branches new file mode 100644 index 0000000..2bf5ad0 --- /dev/null +++ b/server/preserved_branches @@ -0,0 +1 @@ +stable diff --git a/server/update-lock-check.rb b/server/update-lock-check.rb new file mode 100755 index 0000000..d08a3c2 --- /dev/null +++ b/server/update-lock-check.rb @@ -0,0 +1,36 @@ +#! /usr/bin/ruby + +REFNAME = ARGV[0] +OLDREV = ARGV[1] +NEWREV = ARGV[2] + +DATA_DIR = '/srv/git/hooks/server/' + +def reject(message) + $stdout.puts "---------------------------------------------------------" + $stdout.puts "Commit #{NEWREV} rejected:" + $stdout.puts "\t#{message}" + $stdout.puts "---------------------------------------------------------" + $stdout.flush() + Kernel::exit(1) +end + +if(REFNAME =~ /^refs\/heads\/(.+)$/) + # Branch commit + commit_branch = $1 + locked_branches = IO::readlines(DATA_DIR + 'locked_branches').collect!(){|element| element.strip()} + if(locked_branches.include?(commit_branch)) + reject("Branch '#{commit_branch}' is locked.") + end + + if(NEWREV =~ /^0{40}$/) + # Branch deletion + preserved_branches = IO::readlines(DATA_DIR + 'preserved_branches').collect!(){|element| element.strip()} + if(preserved_branches.include?(commit_branch)) + reject("Branch '#{commit_branch}' cannot be deleted.") + end + end +end + +Kernel::exit(0) +