-
-
Save edblack1/00050b9d66bfab1532c47bb8f2af4df1 to your computer and use it in GitHub Desktop.
Revisions
-
cagerton revised this gist
Sep 23, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,9 @@ #!/usr/bin/env ruby # pre-receive hook to block 'push -f' on master # For Phabricator, save this as: # $REPO/hooks/pre-receive-phabricator.d/no_push_f_master.rb # Remember to chmod +x # Ref: http://git-scm.com/book/en/Customizing-Git-An-Example-Git-Enforced-Policy args = STDIN.readline.chomp.split(" ") -
cagerton renamed this gist
Sep 23, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
cagerton created this gist
Sep 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ #!/usr/bin/env ruby # pre-receive hook to block 'push -f' on master # For Phabricator (remember to chmod +x): # $REPO/hooks/pre-receive-phabricator.d/no_push_f_master.rb # Ref: http://git-scm.com/book/en/Customizing-Git-An-Example-Git-Enforced-Policy args = STDIN.readline.chomp.split(" ") $oldrev, $newrev, $refspec = args # paranoid input check: SHA_RE = /^[\da-f]{40}$/i if $oldrev !~ SHA_RE or $newrev !~ SHA_RE then puts "invalid input?" exit 1 end # enforces fast-forward only pushes: def check_fast_forward missed_refs = `git rev-list #{$newrev}..#{$oldrev}` missed_ref_count = missed_refs.split("\n").size if missed_ref_count > 0 puts "[POLICY] Cannot push a non fast-forward reference" puts "[POLICY] missed ref count: #{missed_ref_count}" exit 1 end end # don't allow deletes def check_delete if /0{40}/ =~ $newrev then puts "[POLICY] delete rejected" exit 1 end end # enforcing on master if $refspec == "refs/heads/master" puts "[POLICY:master]" check_delete check_fast_forward end