Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: branch name compliance [DEVOP-147] #92

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/actions/pullRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ exports.validatePR = async function validatePR({ pullRequest, issue }) {

if (!isBranchNameValid(headRef)) {
throw new Error(
`This pull request is based on a branch with in invalid name: “${headRef}”. See https://www.notion.so/mobsuccess/Git-Guidelines-41996ef576cb4f29b7737772b74289c5#f9cadc10d949498dbe38c0eed08fd4f8`
`This pull request is based on a branch with in invalid name: “${headRef}”. See https://github.com/mobsuccess-devops/rfc/blob/master/docs/decisions/0009-convention-nommage-branch-pr.md and https://www.notion.so/mobsuccess/Git-Guidelines-41996ef576cb4f29b7737772b74289c5#f9cadc10d949498dbe38c0eed08fd4f8`
);
}

Expand Down
8 changes: 8 additions & 0 deletions lib/branch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
function isBranchNameValid(branchName) {
return (
// The following are the older branch prefixes, that are still valid, with
// discussions pending on the ADR #9 with a PR #35 still active at the time
// of writing, to maybe deprecate them. In the meantime we still have to
// allow branches using these prefixes, as no active ADR disallows their
// use.
!!branchName.match(
/^(core|feature|fix|hotfix|asset|rework|documentation)\/([a-z][a-z0-9._-]*)$/
) ||
!!branchName.match(
/^(feat|fix|chore|docs|refactor|test|revert|ci|perf|style|build|change|remove|poc|mobsuccessbot|dependabot)\/([a-z][a-z0-9._-]*)$/
) ||
Expand Down
15 changes: 8 additions & 7 deletions lib/branch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ describe("branch", () => {
])("Test branch %s should be valid", (branch) => {
expect(isBranchNameValid(branch)).toBe(true);
});
// Some tests were commented out, see #92.
test.each([
"core/foo--bar",
"core/foo--bar--z",
// "core/foo--bar",
// "core/foo--bar--z",
"foo/foo-bar",
"feature/foo",
"hotfix/foo",
"core/foo",
"asset/foo",
"documentation/foo",
// "feature/foo",
// "hotfix/foo",
// "core/foo",
// "asset/foo",
// "documentation/foo",
"chore",
"chore/",
"chore/FOO",
Expand Down
Loading