mirror of
https://github.com/actions/labeler.git
synced 2025-12-12 04:27:34 +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', () => {
|
||||
it('returns the head branch name', () => {
|
||||
const result = getBranchName('base');
|
||||
expect(result).toEqual('base-branch-name');
|
||||
const result = getBranchName();
|
||||
expect(result).toEqual('head-branch-name');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('run', () => {
|
||||
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'};
|
||||
usingLabelerConfigYaml('branches.yml');
|
||||
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 = {
|
||||
ref: 'test/feature/123'
|
||||
};
|
||||
|
||||
20
dist/index.js
vendored
20
dist/index.js
vendored
@@ -34,7 +34,7 @@ exports.checkBranch = exports.getBranchName = exports.toBranchMatchConfig = void
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
function toBranchMatchConfig(config) {
|
||||
if (!config['head-branch'] || config['base-branch']) {
|
||||
if (!config['head-branch'] && !config['base-branch']) {
|
||||
return {};
|
||||
}
|
||||
const branchConfig = {
|
||||
@@ -340,26 +340,26 @@ function checkAll(changedFiles, globs) {
|
||||
function checkMatch(changedFiles, matchConfig) {
|
||||
var _a, _b;
|
||||
if (((_a = matchConfig.changedFiles) === null || _a === void 0 ? void 0 : _a.all) !== undefined) {
|
||||
if (!checkAll(changedFiles, matchConfig.changedFiles.all)) {
|
||||
return false;
|
||||
if (checkAll(changedFiles, matchConfig.changedFiles.all)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (((_b = matchConfig.changedFiles) === null || _b === void 0 ? void 0 : _b.any) !== undefined) {
|
||||
if (!checkAny(changedFiles, matchConfig.changedFiles.any)) {
|
||||
return false;
|
||||
if (checkAny(changedFiles, matchConfig.changedFiles.any)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchConfig.headBranch !== undefined) {
|
||||
if (!(0, branch_1.checkBranch)(matchConfig.headBranch, 'head')) {
|
||||
return false;
|
||||
if ((0, branch_1.checkBranch)(matchConfig.headBranch, 'head')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchConfig.baseBranch !== undefined) {
|
||||
if (!(0, branch_1.checkBranch)(matchConfig.baseBranch, 'base')) {
|
||||
return false;
|
||||
if ((0, branch_1.checkBranch)(matchConfig.baseBranch, 'base')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
function addLabels(client, prNumber, labels) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
|
||||
@@ -9,7 +9,7 @@ export interface BranchMatchConfig {
|
||||
type BranchBase = 'base' | 'head';
|
||||
|
||||
export function toBranchMatchConfig(config: any): BranchMatchConfig {
|
||||
if (!config['head-branch'] || config['base-branch']) {
|
||||
if (!config['head-branch'] && !config['base-branch']) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user