Created
June 8, 2021 18:28
-
-
Save elrayle/45161cc23b7a6778f49aa37e9a5a80f3 to your computer and use it in GitHub Desktop.
Circle CI step to fail if branch name is master
This file contains 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 characters
- run: | |
name: Check for a branch named 'master' | |
command: | | |
git fetch --all --quiet --prune --prune-tags | |
if [[ -n "$(git branch --all --list master */master)" ]]; then | |
echo "A branch named 'master' was found. Please remove it." | |
echo "$(git branch --all --list master */master)" | |
fi | |
[[ -z "$(git branch --all --list master */master)" ]] |
Text for Issue:
NOTE: This applies if the repo uses Circle CI for integration testing.
Title
Add Circle CI step that fails if branch name is master
Description
### Descriptive summary
This repository’s default branch has already been renamed to `main` using GitHub’s renaming tool. In order to preserve automatic redirection of links that reference the old branch name `master` to the new default `main` branch, a branch with the old name should not be recreated.
CircleCI can be used to prevent the recreation of the old default branch name by preventing PRs with a branch named `master` from being merged by causing a test failure during continuous integration.
### Rationale
Git's default "master" branch derives from "master/slave" jargon which perpetuates systemic racist language and systems (see email [Replacing "master" reference in git branch names](https://mail.gnome.org/archives/desktop-devel-list/2019-May/msg00066.html)). To uphold our Code of Conduct, we must move away from the term "master" in our technical language (as well as words like blacklist or whitelist).
### Expected behavior
If a PR is submitted with a branch named master, the continuous integration tests should fail.
### Actual behavior
If a PR is submitted with a branch named master, the continuous integration tests will not fail because of the branch name.
### Related work
Background on the renaming effort is available in the [working group notes](https://samvera.atlassian.net/wiki/x/b5IYHg).
Text for PR
Title
Adds Circle CI step that fails if branch name is master
Description
Fixes _____
This PR adds the Circle CI step that fails if the branch name is master.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions:
Edit
.circleci/config.yml
and add the gist code to thesteps:
section under thecheckout
.Examples of this in use