Effectiveness of Tool: Branch Renaming Script - Samvera Branch Renaming Working Group

 Table of Content

Setup

  • Create a test repo with a master branch, issues, PRs - See samvera-labs/branch-renaming-wg for a script to do this.
  • Within the test repo, create a wiki page that references a branch in master.
  • Create a Fork of the test repo.
  • Clone the test repo to your local machine

Tool: Renaming Script

Reference: 

Case Study:

https://github.com/kelynch/branch-renaming-test

Ran:

# set up test repo at ~/code/branch-renaming-test
git clone https://gist.githubusercontent.com/escowles/eed4567d818f77811311386df8e71133
# move the script and make it executable
mv eed4567d818f77811311386df8e71133/rename-master-to-main.sh ~/code/hold/rename.sh
cd ~/code/hold/
chmod 755 rename.sh 
# export your GitHub token
echo $GITHUB_TOKEN=xyz
./rename.sh kelynch branch-renaming-test
git fetch 
git branch -d master
# remote branch cannot be deleted before protection rules are updated

Checklist:

  • renames master to main
    • branch dropdown defaults to main
    • master is not in the branch dropdown (this requires manual removal)
  • Settings → Branches
    • main is the default branch
    • branch rules were copied over to main
    • master branch is not in the branch dropdown under Default branch
    • master branch is not listed in the Branch protection rules area
  • updates issues
    • changes reference to a sha in master to the same sha in main
    • changes links to code in master branch to the same code in main
  • updates PRs
    • updates 'commit into' branch to main for all PRs
    • updates links to code in master branch to the same code in main
  • wiki updated (None as expected)
    • updates links to code in master branch to the same code in main (NOTE: Even though the link text and URL were not changed, GitHub forwards all 404 to the default branch which is main.) (N/A)
  • local git repo (None as expected)
    • Switches local to "main"
    • Deletes local "master"
  • working with Forks
    • TBD
  • README and other document - not changed

Locations text "master" still exists (mostly found via github search):

  • Links to code outside this repository
  • Issues and PRs made to master before renaming
  • Integrations
  • Forks
  • Documentation

Evaluation:

This script provides a quick and easy interface to replace "master" with "main" on a GitHub repository and update the local to "main."  It is intentionally conservative in its approach and does not delete branches on the local or remote, so all removal of "master" should be done manually.  This script may be especially useful when used with GitHub's upcoming seamless transition tooling.