Skip to content

Commit 87ae69b

Browse files
authored
Merge pull request #66 from shiftcode/#65-is-production
fix(is-production): crucial fix to detect `main` correctly as production
2 parents 4602438 + 67265eb commit 87ae69b

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/branch-utilities/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shiftcode/branch-utilities",
3-
"version": "5.0.1",
3+
"version": "5.0.2-pr65.0",
44
"description": "Utilities for local and ci to get branch name and stage",
55
"repository": "https://github.com/shiftcode/sc-commons-public",
66
"license": "MIT",

packages/branch-utilities/src/lib/base.utils.spec.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BranchInfo, getBranchInfo, parseBranchName } from './base.utils.js'
1+
import { BranchInfo, getBranchInfo, isProduction, isPullRequest, parseBranchName } from './base.utils.js'
22
import { CustomGitHubContext, GithubActionEnv, GitHubContext } from './types/index.js'
33
import { CustomScOverrideEnv } from './types/sc-override-env-var.type.js'
44

@@ -109,4 +109,31 @@ describe('base utils', () => {
109109
expect(() => parseBranchName('feat/copilot/fix-123')).toThrow()
110110
})
111111
})
112+
113+
describe('isProduction', () => {
114+
test.each([
115+
['main', true],
116+
['master', true],
117+
['prod', false],
118+
['xx1', false],
119+
['pr1', false],
120+
['pr1-main', false],
121+
['xx1-master', false],
122+
])("when '%s' it returns %s", (stageName, expected) => {
123+
expect(isProduction(stageName)).toBe(expected)
124+
})
125+
})
126+
127+
describe('isPullRequest', () => {
128+
test.each([
129+
['pr1', true],
130+
['pr123456', true],
131+
['xx1', false],
132+
['xx123', false],
133+
['main', false],
134+
['master', false],
135+
])("when '%s' it returns %s", (stageName, expected) => {
136+
expect(isPullRequest(stageName)).toBe(expected)
137+
})
138+
})
112139
})

packages/branch-utilities/src/lib/base.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export function parseBranchName(branchName: string): { branchId: number; branchN
165165
* @return returns true if the stage is 'master' or 'main', false if not
166166
*/
167167
export function isProduction(stageName: string): boolean {
168-
return REGEX_MASTER.test(stageName) ?? REGEX_MAIN.test(stageName)
168+
return REGEX_MASTER.test(stageName) || REGEX_MAIN.test(stageName)
169169
}
170170

171171
/**

packages/publish-helper/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shiftcode/publish-helper",
3-
"version": "4.1.1",
3+
"version": "4.1.2-pr65.0",
44
"description": "scripts for conventional (pre)releases",
55
"repository": "https://github.com/shiftcode/sc-commons-public",
66
"license": "MIT",
@@ -32,7 +32,7 @@
3232
"yargs": "^17.7.2"
3333
},
3434
"devDependencies": {
35-
"@shiftcode/branch-utilities": "^5.0.1",
35+
"@shiftcode/branch-utilities": "^5.0.2-pr65.0",
3636
"@types/yargs": "^17.0.32"
3737
},
3838
"peerDependencies": {

0 commit comments

Comments
 (0)