Skip to content

Commit

Permalink
Default to branch named "main"
Browse files Browse the repository at this point in the history
In cases where we can't figure out a baseline commit in our CI scripts,
we default to `origin/master`. This was the usual default branch name
back in the days, but it has since changed to `origin/main`. I'm making
the switch to "main" now.

This is a breaking change but one that is easy to make non-breaking if
you use a BASE_BRANCH=origin/master environment variable.
  • Loading branch information
trotzig committed Sep 27, 2024
1 parent 7ba2c31 commit d8db103
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bin/happo-ci-circleci
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Make the whole script fail on errors
set -euo pipefail

BASE_BRANCH=${BASE_BRANCH:-"origin/master"}
BASE_BRANCH=${BASE_BRANCH:-"origin/main"}
echo "Using ${BASE_BRANCH} as the default branch (change this with the BASE_BRANCH environment variable)"
PREVIOUS_SHA=$(git merge-base "${BASE_BRANCH}" "${CIRCLE_SHA1}")

Expand Down
4 changes: 2 additions & 2 deletions bin/happo-ci-travis
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# Make the whole script fail on errors
set -eou pipefail

BASE_BRANCH=${BASE_BRANCH:-"master"}
BASE_BRANCH=${BASE_BRANCH:-"main"}
echo "Using ${BASE_BRANCH} as the default branch (change this with the BASE_BRANCH environment variable)"

if [ ! -z "${TRAVIS_COMMIT_RANGE:-}" ]; then
# The PREVIOUS_SHA will be equal to the commit that the PR is based on (which
# is usually some commit on the master branch), or the commit that the last
# is usually some commit on the main branch), or the commit that the last
# build was triggered for. Travis gives us a range of commits. We need the
# first one.
PREVIOUS_SHA="${TRAVIS_COMMIT_RANGE//\.\..*/}"
Expand Down
12 changes: 6 additions & 6 deletions test/github_pull_request_event.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"type": "User",
"site_admin": false
},
"body": "This is a pretty simple change that we need to pull into master.",
"body": "This is a pretty simple change that we need to pull into main.",
"created_at": "2019-05-15T15:20:33Z",
"updated_at": "2019-05-15T15:20:33Z",
"closed_at": null,
Expand Down Expand Up @@ -166,16 +166,16 @@
"forks": 0,
"open_issues": 2,
"watchers": 0,
"default_branch": "master",
"default_branch": "main",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"delete_branch_on_merge": false
}
},
"base": {
"label": "Codertocat:master",
"ref": "master",
"label": "Codertocat:main",
"ref": "main",
"sha": "f95f852bd8fca8fcc58a9a2d6c842781e32a215e",
"user": {
"login": "Codertocat",
Expand Down Expand Up @@ -289,7 +289,7 @@
"forks": 0,
"open_issues": 2,
"watchers": 0,
"default_branch": "master",
"default_branch": "main",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
Expand Down Expand Up @@ -429,7 +429,7 @@
"forks": 0,
"open_issues": 2,
"watchers": 0,
"default_branch": "master"
"default_branch": "main"
},
"sender": {
"login": "Codertocat",
Expand Down
5 changes: 2 additions & 3 deletions test/github_push_event.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@
"forks": 1,
"open_issues": 2,
"watchers": 0,
"default_branch": "master",
"stargazers": 0,
"master_branch": "master"
"default_branch": "main",
"stargazers": 0
},
"pusher": {
"name": "Codertocat",
Expand Down

0 comments on commit d8db103

Please sign in to comment.