File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,34 @@ describe('getBranchName', () => {
24
24
expect ( result ) . toEqual ( 'head-branch-name' ) ;
25
25
} ) ;
26
26
} ) ;
27
+
28
+ describe ( 'Branch name matching' , ( ) => {
29
+ describe ( 'when checking for case-insensitive match' , ( ) => {
30
+ // Test case 1: with mixed case in the branch name
31
+ beforeEach ( ( ) => {
32
+ github . context . payload . pull_request ! . head = {
33
+ ref : 'feature-123-Refactor'
34
+ } ;
35
+ } ) ;
36
+
37
+ it ( 'returns the head branch name in lowercase' , ( ) => {
38
+ const result = getBranchName ( 'head' ) ;
39
+ expect ( result ) . toEqual ( 'feature-123-refactor' ) ;
40
+ } ) ;
41
+
42
+ // Test case 2: with uppercase in the branch name
43
+ beforeEach ( ( ) => {
44
+ github . context . payload . pull_request ! . head = {
45
+ ref : 'feature-123-REFACTOR'
46
+ } ;
47
+ } ) ;
48
+
49
+ it ( 'returns the head branch name in lowercase' , ( ) => {
50
+ const result = getBranchName ( 'head' ) ;
51
+ expect ( result ) . toEqual ( 'feature-123-refactor' ) ;
52
+ } ) ;
53
+ } ) ;
54
+ } ) ;
27
55
} ) ;
28
56
29
57
describe ( 'checkAllBranch' , ( ) => {
Original file line number Diff line number Diff line change @@ -531,7 +531,7 @@ function getBranchName(branchBase) {
531
531
return (_a = pullRequest.base) === null || _a === void 0 ? void 0 : _a.ref;
532
532
}
533
533
else {
534
- return (_b = pullRequest.head) === null || _b === void 0 ? void 0 : _b.ref;
534
+ return (_b = pullRequest.head) === null || _b === void 0 ? void 0 : _b.ref.toLowerCase() ;
535
535
}
536
536
}
537
537
function checkAnyBranch(regexps, branchBase) {
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export function getBranchName(branchBase: BranchBase): string | undefined {
36
36
if ( branchBase === 'base' ) {
37
37
return pullRequest . base ?. ref ;
38
38
} else {
39
- return pullRequest . head ?. ref ;
39
+ return pullRequest . head ?. ref . toLowerCase ( ) ;
40
40
}
41
41
}
42
42
You can’t perform that action at this time.
0 commit comments