mirror of
https://github.com/actions/labeler.git
synced 2025-12-12 12:37:48 +00:00
Make getBranchName argument non-optional
This commit is contained in:
@@ -23,13 +23,6 @@ describe('getBranchName', () => {
|
|||||||
expect(result).toEqual('head-branch-name');
|
expect(result).toEqual('head-branch-name');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when no branch is specified', () => {
|
|
||||||
it('returns the head branch name', () => {
|
|
||||||
const result = getBranchName();
|
|
||||||
expect(result).toEqual('head-branch-name');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('checkBranch', () => {
|
describe('checkBranch', () => {
|
||||||
@@ -45,14 +38,14 @@ describe('checkBranch', () => {
|
|||||||
describe('when a single pattern is provided', () => {
|
describe('when a single pattern is provided', () => {
|
||||||
describe('and the pattern matches the head branch', () => {
|
describe('and the pattern matches the head branch', () => {
|
||||||
it('returns true', () => {
|
it('returns true', () => {
|
||||||
const result = checkBranch(['^test']);
|
const result = checkBranch(['^test'], 'head');
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('and the pattern does not match the head branch', () => {
|
describe('and the pattern does not match the head branch', () => {
|
||||||
it('returns false', () => {
|
it('returns false', () => {
|
||||||
const result = checkBranch(['^feature/']);
|
const result = checkBranch(['^feature/'], 'head');
|
||||||
expect(result).toBe(false);
|
expect(result).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -61,21 +54,21 @@ describe('checkBranch', () => {
|
|||||||
describe('when multiple patterns are provided', () => {
|
describe('when multiple patterns are provided', () => {
|
||||||
describe('and at least one pattern matches', () => {
|
describe('and at least one pattern matches', () => {
|
||||||
it('returns true', () => {
|
it('returns true', () => {
|
||||||
const result = checkBranch(['^test/', '^feature/']);
|
const result = checkBranch(['^test/', '^feature/'], 'head');
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('and all patterns match', () => {
|
describe('and all patterns match', () => {
|
||||||
it('returns true', () => {
|
it('returns true', () => {
|
||||||
const result = checkBranch(['^test/', '/feature/']);
|
const result = checkBranch(['^test/', '/feature/'], 'head');
|
||||||
expect(result).toBe(true);
|
expect(result).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('and no patterns match', () => {
|
describe('and no patterns match', () => {
|
||||||
it('returns false', () => {
|
it('returns false', () => {
|
||||||
const result = checkBranch(['^feature/', '/test$']);
|
const result = checkBranch(['^feature/', '/test$'], 'head');
|
||||||
expect(result).toBe(false);
|
expect(result).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export function toBranchMatchConfig(config: any): BranchMatchConfig {
|
|||||||
return branchConfig;
|
return branchConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBranchName(branchBase?: BranchBase): string | undefined {
|
export function getBranchName(branchBase: BranchBase): string | undefined {
|
||||||
const pullRequest = github.context.payload.pull_request;
|
const pullRequest = github.context.payload.pull_request;
|
||||||
if (!pullRequest) {
|
if (!pullRequest) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -50,7 +50,7 @@ export function getBranchName(branchBase?: BranchBase): string | undefined {
|
|||||||
|
|
||||||
export function checkBranch(
|
export function checkBranch(
|
||||||
regexps: string[],
|
regexps: string[],
|
||||||
branchBase?: BranchBase
|
branchBase: BranchBase
|
||||||
): boolean {
|
): boolean {
|
||||||
const branchName = getBranchName(branchBase);
|
const branchName = getBranchName(branchBase);
|
||||||
if (!branchName) {
|
if (!branchName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user