From 5b74674746a4e577b20a5c276b8238a191e685fb Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 25 Feb 2021 18:07:31 +0000 Subject: [PATCH] Prevent the creation of new branches from random users Because I've done this too many times --- hooks/pre-receive | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hooks/pre-receive b/hooks/pre-receive index f34d9db..a212b6e 100755 --- a/hooks/pre-receive +++ b/hooks/pre-receive @@ -156,6 +156,14 @@ if (empty($req_paths)) { $req_paths = ['']; // we can empty paths for trivial merge } +if ($pi->isNewBranch()) { + $authorizedUsers = $RMs + $weKnowWhatWeAreDoing; + if (!in_array($user, $authorizedUsers)) { + deny('You are not allowed to create a new branch, contact one of ' + . implode(', ', $authorizedUsers) . ' for the creation of a new branch.'); + } +} + if (isset($closedBranches[$repo_name])) { $closed = array_filter(array_keys($closedBranches[$repo_name]), function ($branch) use ($pi, $user, $closedBranches, $repo_name) {