mirror of
https://github.com/actions/labeler.git
synced 2025-12-12 12:37:48 +00:00
Fix some typos in the branch checks
This commit is contained in:
@@ -21,8 +21,8 @@ describe('getBranchName', () => {
|
|||||||
|
|
||||||
describe('when no branch is specified', () => {
|
describe('when no branch is specified', () => {
|
||||||
it('returns the head branch name', () => {
|
it('returns the head branch name', () => {
|
||||||
const result = getBranchName('base');
|
const result = getBranchName();
|
||||||
expect(result).toEqual('base-branch-name');
|
expect(result).toEqual('head-branch-name');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ describe('run', () => {
|
|||||||
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
expect(removeLabelMock).toHaveBeenCalledTimes(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds labels based on the branch names that match the glob pattern', async () => {
|
it('adds labels based on the branch names that match the regexp pattern', async () => {
|
||||||
github.context.payload.pull_request!.head = {ref: 'test/testing-time'};
|
github.context.payload.pull_request!.head = {ref: 'test/testing-time'};
|
||||||
usingLabelerConfigYaml('branches.yml');
|
usingLabelerConfigYaml('branches.yml');
|
||||||
await run();
|
await run();
|
||||||
@@ -118,7 +118,7 @@ describe('run', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds multiple labels based on branch names that match different glob patterns', async () => {
|
it('adds multiple labels based on branch names that match different regexp patterns', async () => {
|
||||||
github.context.payload.pull_request!.head = {
|
github.context.payload.pull_request!.head = {
|
||||||
ref: 'test/feature/123'
|
ref: 'test/feature/123'
|
||||||
};
|
};
|
||||||
|
|||||||
22
dist/index.js
vendored
22
dist/index.js
vendored
@@ -34,7 +34,7 @@ exports.checkBranch = exports.getBranchName = exports.toBranchMatchConfig = void
|
|||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const github = __importStar(__nccwpck_require__(5438));
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
function toBranchMatchConfig(config) {
|
function toBranchMatchConfig(config) {
|
||||||
if (!config['head-branch'] || config['base-branch']) {
|
if (!config['head-branch'] && !config['base-branch']) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const branchConfig = {
|
const branchConfig = {
|
||||||
@@ -340,26 +340,26 @@ function checkAll(changedFiles, globs) {
|
|||||||
function checkMatch(changedFiles, matchConfig) {
|
function checkMatch(changedFiles, matchConfig) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
if (((_a = matchConfig.changedFiles) === null || _a === void 0 ? void 0 : _a.all) !== undefined) {
|
if (((_a = matchConfig.changedFiles) === null || _a === void 0 ? void 0 : _a.all) !== undefined) {
|
||||||
if (!checkAll(changedFiles, matchConfig.changedFiles.all)) {
|
if (checkAll(changedFiles, matchConfig.changedFiles.all)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (((_b = matchConfig.changedFiles) === null || _b === void 0 ? void 0 : _b.any) !== undefined) {
|
if (((_b = matchConfig.changedFiles) === null || _b === void 0 ? void 0 : _b.any) !== undefined) {
|
||||||
if (!checkAny(changedFiles, matchConfig.changedFiles.any)) {
|
if (checkAny(changedFiles, matchConfig.changedFiles.any)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matchConfig.headBranch !== undefined) {
|
if (matchConfig.headBranch !== undefined) {
|
||||||
if (!(0, branch_1.checkBranch)(matchConfig.headBranch, 'head')) {
|
if ((0, branch_1.checkBranch)(matchConfig.headBranch, 'head')) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matchConfig.baseBranch !== undefined) {
|
if (matchConfig.baseBranch !== undefined) {
|
||||||
if (!(0, branch_1.checkBranch)(matchConfig.baseBranch, 'base')) {
|
if ((0, branch_1.checkBranch)(matchConfig.baseBranch, 'base')) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
function addLabels(client, prNumber, labels) {
|
function addLabels(client, prNumber, labels) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export interface BranchMatchConfig {
|
|||||||
type BranchBase = 'base' | 'head';
|
type BranchBase = 'base' | 'head';
|
||||||
|
|
||||||
export function toBranchMatchConfig(config: any): BranchMatchConfig {
|
export function toBranchMatchConfig(config: any): BranchMatchConfig {
|
||||||
if (!config['head-branch'] || config['base-branch']) {
|
if (!config['head-branch'] && !config['base-branch']) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user