Skip to content
Open
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
28 changes: 28 additions & 0 deletions __tests__/branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,34 @@ describe('getBranchName', () => {
expect(result).toEqual('head-branch-name');
});
});

describe('Branch name matching', () => {
describe('when checking for case-insensitive match', () => {
// Test case 1: with mixed case in the branch name
beforeEach(() => {
github.context.payload.pull_request!.head = {
ref: 'feature-123-Refactor'
};
});

it('returns the head branch name in lowercase', () => {
const result = getBranchName('head');
expect(result).toEqual('feature-123-refactor');
});

// Test case 2: with uppercase in the branch name
beforeEach(() => {
github.context.payload.pull_request!.head = {
ref: 'feature-123-REFACTOR'
};
});

it('returns the head branch name in lowercase', () => {
const result = getBranchName('head');
expect(result).toEqual('feature-123-refactor');
});
});
});
});

describe('checkAllBranch', () => {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ function getBranchName(branchBase) {
return (_a = pullRequest.base) === null || _a === void 0 ? void 0 : _a.ref;
}
else {
return (_b = pullRequest.head) === null || _b === void 0 ? void 0 : _b.ref;
return (_b = pullRequest.head) === null || _b === void 0 ? void 0 : _b.ref.toLowerCase();
}
}
function checkAnyBranch(regexps, branchBase) {
Expand Down
2 changes: 1 addition & 1 deletion src/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function getBranchName(branchBase: BranchBase): string | undefined {
if (branchBase === 'base') {
return pullRequest.base?.ref;
} else {
return pullRequest.head?.ref;
return pullRequest.head?.ref.toLowerCase();
}
}

Expand Down