Update our commit hooks to use 'main' as the bleeding edge branch.
authorWard Vandewege <ward@curii.com>
Thu, 17 Jun 2021 14:24:50 +0000 (10:24 -0400)
committerWard Vandewege <ward@curii.com>
Thu, 17 Jun 2021 14:24:50 +0000 (10:24 -0400)
refs #17817

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

git/hooks/check-copyright-headers.rb
git/hooks/coding-standards.rb
git/hooks/enforce-dco-signoff.rb

index b4b8d94c4835661d5cdd0104de3e28eb3f0b326d..2f6b20d2a063ba46ac8f21c35987abbfbe204482 100755 (executable)
@@ -50,13 +50,13 @@ def check_copyright_headers
     all_objects = []
     commits = []
   elsif ($oldrev[0,6] ==  '000000')
-    if $refname != 'refs/heads/master'
+    if $refname != 'refs/heads/main'
       # A new branch was pushed. Check all new commits in this branch.
-      puts "git rev-list --objects master..#{$newrev} | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'"
-      blob_objects  = `git rev-list --objects master..#{$newrev} | git cat-file --follow-symlinks --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'`.split("\n")
-      commit_objects  = `git rev-list --objects master..#{$newrev} | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^commit //p'`.split("\n")
+      puts "git rev-list --objects main..#{$newrev} | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'"
+      blob_objects  = `git rev-list --objects main..#{$newrev} | git cat-file --follow-symlinks --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^blob //p'`.split("\n")
+      commit_objects  = `git rev-list --objects main..#{$newrev} | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)'| sed -n 's/^commit //p'`.split("\n")
       all_objects = blob_objects + commit_objects
-      commits = `git rev-list master..#{$newrev}`.split("\n")
+      commits = `git rev-list main..#{$newrev}`.split("\n")
     else
       # When does this happen?
       puts "UNEXPECTED ERROR"
index 4097d1a0f1a2fc9667853ff3da2c2d467e02dacb..14fb158f41f43bc6bfeabd59d7e5ca8a91147c84 100755 (executable)
@@ -22,9 +22,9 @@ def blacklist bl
     # A branch is being deleted. Do not check old commits for DCO signoff!
     all_revs    = []
   elsif ($oldrev[0,6] ==  '000000')
-    if $refname != 'refs/heads/master'
+    if $refname != 'refs/heads/main'
       # A new branch was pushed. Check all new commits in this branch.
-      all_revs  = `git log --pretty=format:%H master..#{$newrev}`.split("\n")
+      all_revs  = `git log --pretty=format:%H main..#{$newrev}`.split("\n")
     else
       # When does this happen?
       all_revs  = [$newrev]
@@ -45,8 +45,8 @@ end
 
 blacklist ['26d74dc0524c87c5dcc0c76040ce413a4848b57a']
 
-# Only enforce policy on the master branch
-exit 0 if $refname != 'refs/heads/master'
+# Only enforce policy on the main branch
+exit 0 if $refname != 'refs/heads/main'
 
 puts "Enforcing Policies..."
 puts "(#{$refname}) (#{$oldrev[0,6]}) (#{$newrev[0,6]})"
@@ -54,9 +54,9 @@ puts "(#{$refname}) (#{$oldrev[0,6]}) (#{$newrev[0,6]})"
 $regex = /\[ref: (\d+)\]/
 
 $broken_commit_message = /Please enter a commit message to explain why this merge is necessary/
-$wrong_way_merge_master = /Merge( remote-tracking)? branch '([^\/]+\/)?master' into/
-$merge_master = /Merge branch '[^']+'((?! into)| into master)/
-$pull_merge = /Merge branch 'master' of /
+$wrong_way_merge_main = /Merge( remote-tracking)? branch '([^\/]+\/)?master' into/
+$merge_main = /Merge branch '[^']+'((?! into)| into master)/
+$pull_merge = /Merge branch 'main' of /
 $refs_or_closes_or_no_issue = /(refs #|closes #|fixes #|no issue #)/i
 
 # enforced custom commit message format
@@ -69,10 +69,10 @@ def check_message_format
 
   merge_revs.each do |rev|
     message = `git cat-file commit #{rev} | sed '1,/^$/d'`
-    if $wrong_way_merge_master.match(message)
-      puts "\n[POLICY] Only non-fast-forward merges into master are allowed. Please"
-      puts "reset your master branch:"
-      puts "  git reset --hard origin/master"
+    if $wrong_way_merge_main.match(message)
+      puts "\n[POLICY] Only non-fast-forward merges into main are allowed. Please"
+      puts "reset your main branch:"
+      puts "  git reset --hard origin/main"
       puts "and then merge your branch with the --no-ff option:"
       puts "  git merge your-branch --no-ff\n"
       puts "Remember to add a reference to an issue number in the merge commit!\n"
@@ -85,9 +85,9 @@ def check_message_format
       broken = true
       no_ff = true
     elsif $pull_merge.match(message)
-      puts "\n[POLICY] This appears to be a git pull merge of remote master into local"
-      puts "master.  In order to maintain a linear first-parent history of master,"
-      puts "please reset your branch and remerge or rebase using the latest master.\n"
+      puts "\n[POLICY] This appears to be a git pull merge of remote main into local"
+      puts "main.  In order to maintain a linear first-parent history of master,"
+      puts "please reset your branch and remerge or rebase using the latest main.\n"
       puts "\n******************************************************************\n"
       puts "\nOffending commit: #{rev}\n"
       puts "\nOffending commit message:\n\n"
@@ -95,9 +95,9 @@ def check_message_format
       puts "\n******************************************************************\n"
       puts "\n\n"
       broken = true
-    elsif not $merge_master.match(message) and not
+    elsif not $merge_main.match(message) and not
       puts "\n[POLICY] This does not appear to be a merge of a feature"
-      puts "branch into master.  Merges must follow the format"
+      puts "branch into main.  Merges must follow the format"
       puts "\"Merge branch 'feature-branch'\".\n"
       puts "\n******************************************************************\n"
       puts "\nOffending commit: #{rev}\n"
@@ -127,7 +127,7 @@ def check_message_format
     # this test will complain about *every* commit in the merge otherwise, obscuring
     # the real reason for the rejection (the no_ff merge)
     if not no_ff and not $refs_or_closes_or_no_issue.match(message)
-      puts "\n[POLICY] All commits to master must include an issue using \"refs #\" or"
+      puts "\n[POLICY] All commits to main must include an issue using \"refs #\" or"
       puts "\"closes #\", or specify \"no issue #\"\n"
       puts "\n******************************************************************\n"
       puts "\nOffending commit: #{rev}\n"
index 191a34b03afd0e33aaa975b45c0f41b231a3cc93..4541fa094e43f60d78fc5020344e86d4e4b2271c 100755 (executable)
@@ -30,9 +30,9 @@ def check_message_format
     # A branch is being deleted. Do not check old commits for DCO signoff!
     all_revs    = []
   elsif ($oldrev[0,6] ==  '000000')
-    if $refname != 'refs/heads/master'
+    if $refname != 'refs/heads/main'
       # A new branch was pushed. Check all new commits in this branch.
-      all_revs  = `git log --pretty=format:%H master..#{$newrev}`.split("\n")
+      all_revs  = `git log --pretty=format:%H main..#{$newrev}`.split("\n")
     else
       # When does this happen?
       all_revs  = [$newrev]