From 26d57e45a7216568795ed8566cbc5529c6fe1983 Mon Sep 17 00:00:00 2001 From: Ward Vandewege Date: Thu, 17 Jun 2021 10:24:50 -0400 Subject: [PATCH 1/1] Update our commit hooks to use 'main' as the bleeding edge branch. refs #17817 Arvados-DCO-1.1-Signed-off-by: Ward Vandewege --- git/hooks/check-copyright-headers.rb | 10 ++++---- git/hooks/coding-standards.rb | 34 ++++++++++++++-------------- git/hooks/enforce-dco-signoff.rb | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/git/hooks/check-copyright-headers.rb b/git/hooks/check-copyright-headers.rb index b4b8d94..2f6b20d 100755 --- a/git/hooks/check-copyright-headers.rb +++ b/git/hooks/check-copyright-headers.rb @@ -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" diff --git a/git/hooks/coding-standards.rb b/git/hooks/coding-standards.rb index 4097d1a..14fb158 100755 --- a/git/hooks/coding-standards.rb +++ b/git/hooks/coding-standards.rb @@ -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" diff --git a/git/hooks/enforce-dco-signoff.rb b/git/hooks/enforce-dco-signoff.rb index 191a34b..4541fa0 100755 --- a/git/hooks/enforce-dco-signoff.rb +++ b/git/hooks/enforce-dco-signoff.rb @@ -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] -- 2.30.2