mirror of
https://github.com/actions/labeler.git
synced 2025-12-11 03:58:05 +00:00
Run the build command
This commit is contained in:
196
dist/index.js
vendored
196
dist/index.js
vendored
@@ -1,6 +1,106 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ 8045:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.checkBranch = exports.getBranchName = exports.toBranchMatchConfig = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
function toBranchMatchConfig(config) {
|
||||
if (!config['head-branch'] || config['base-branch']) {
|
||||
return {};
|
||||
}
|
||||
const branchConfig = {
|
||||
headBranch: config['head-branch'],
|
||||
baseBranch: config['base-branch']
|
||||
};
|
||||
if (branchConfig.headBranch) {
|
||||
const patterns = branchConfig.headBranch;
|
||||
if (typeof patterns === 'string') {
|
||||
branchConfig.headBranch = [patterns];
|
||||
}
|
||||
}
|
||||
if (branchConfig.baseBranch) {
|
||||
const patterns = branchConfig.baseBranch;
|
||||
if (typeof patterns === 'string') {
|
||||
branchConfig.baseBranch = [patterns];
|
||||
}
|
||||
}
|
||||
return branchConfig;
|
||||
}
|
||||
exports.toBranchMatchConfig = toBranchMatchConfig;
|
||||
function getBranchName(branchBase) {
|
||||
var _a, _b;
|
||||
const pullRequest = github.context.payload.pull_request;
|
||||
if (!pullRequest) {
|
||||
return undefined;
|
||||
}
|
||||
if (branchBase === 'base') {
|
||||
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;
|
||||
}
|
||||
}
|
||||
exports.getBranchName = getBranchName;
|
||||
function checkBranch(glob, branchBase) {
|
||||
const branchName = getBranchName(branchBase);
|
||||
if (!branchName) {
|
||||
core.debug(` no branch name`);
|
||||
return false;
|
||||
}
|
||||
core.debug(` checking "branch" pattern against ${branchName}`);
|
||||
const matchers = glob.map(g => new RegExp(g));
|
||||
for (const matcher of matchers) {
|
||||
if (matchBranchPattern(matcher, branchName)) {
|
||||
core.debug(` "branch" patterns matched against ${branchName}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
core.debug(` "branch" patterns did not match against ${branchName}`);
|
||||
return false;
|
||||
}
|
||||
exports.checkBranch = checkBranch;
|
||||
function matchBranchPattern(matcher, branchName) {
|
||||
core.debug(` - ${matcher}`);
|
||||
if (matcher.test(branchName)) {
|
||||
core.debug(` "branch" pattern matched`);
|
||||
return true;
|
||||
}
|
||||
core.debug(` ${matcher} did not match`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5272:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
@@ -44,6 +144,7 @@ const core = __importStar(__nccwpck_require__(2186));
|
||||
const github = __importStar(__nccwpck_require__(5438));
|
||||
const yaml = __importStar(__nccwpck_require__(1917));
|
||||
const minimatch_1 = __nccwpck_require__(3973);
|
||||
const branch_1 = __nccwpck_require__(8045);
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
@@ -96,14 +197,6 @@ function getPrNumber() {
|
||||
}
|
||||
return pullRequest.number;
|
||||
}
|
||||
function getBranchName() {
|
||||
var _a;
|
||||
const pullRequest = github.context.payload.pull_request;
|
||||
if (!pullRequest) {
|
||||
return undefined;
|
||||
}
|
||||
return (_a = pullRequest.head) === null || _a === void 0 ? void 0 : _a.ref;
|
||||
}
|
||||
function getChangedFiles(client, prNumber) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const listFilesOptions = client.rest.pulls.listFiles.endpoint.merge({
|
||||
@@ -155,13 +248,42 @@ function getLabelGlobMapFromObject(configObject) {
|
||||
}
|
||||
return labelGlobs;
|
||||
}
|
||||
function toMatchConfig(config) {
|
||||
if (typeof config === 'string') {
|
||||
function toChangedFilesMatchConfig(config) {
|
||||
if (!config['changed-files']) {
|
||||
return {};
|
||||
}
|
||||
const changedFiles = config['changed-files'];
|
||||
// If the value provided is a string or an array of strings then default to `any` matching
|
||||
if (typeof changedFiles === 'string') {
|
||||
return {
|
||||
any: [config]
|
||||
changedFiles: {
|
||||
any: [changedFiles]
|
||||
}
|
||||
};
|
||||
}
|
||||
return config;
|
||||
const changedFilesMatchConfig = {
|
||||
changedFiles: {}
|
||||
};
|
||||
if (Array.isArray(changedFiles)) {
|
||||
if (changedFiles.every(entry => typeof entry === 'string')) {
|
||||
changedFilesMatchConfig.changedFiles = {
|
||||
any: changedFiles
|
||||
};
|
||||
}
|
||||
else {
|
||||
// If it is not an array of strings then it should be array of further config options
|
||||
// so assign them to our `changedFilesMatchConfig`
|
||||
changedFiles.forEach(element => {
|
||||
Object.assign(changedFilesMatchConfig.changedFiles, element);
|
||||
});
|
||||
}
|
||||
}
|
||||
return changedFilesMatchConfig;
|
||||
}
|
||||
function toMatchConfig(config) {
|
||||
const changedFilesConfig = toChangedFilesMatchConfig(config);
|
||||
const branchConfig = (0, branch_1.toBranchMatchConfig)(config);
|
||||
return Object.assign(Object.assign({}, changedFilesConfig), branchConfig);
|
||||
}
|
||||
function printPattern(matcher) {
|
||||
return (matcher.negate ? '!' : '') + matcher.pattern;
|
||||
@@ -215,51 +337,25 @@ function checkAll(changedFiles, globs) {
|
||||
core.debug(` "all" patterns matched all files`);
|
||||
return true;
|
||||
}
|
||||
function matchBranchPattern(matcher, branchName) {
|
||||
core.debug(` - ${printPattern(matcher)}`);
|
||||
if (matcher.match(branchName)) {
|
||||
core.debug(` "branch" pattern matched`);
|
||||
return true;
|
||||
}
|
||||
core.debug(` ${printPattern(matcher)} did not match`);
|
||||
return false;
|
||||
}
|
||||
function checkBranch(glob) {
|
||||
const branchName = getBranchName();
|
||||
if (!branchName) {
|
||||
core.debug(` no branch name`);
|
||||
return false;
|
||||
}
|
||||
core.debug(` checking "branch" pattern against ${branchName}`);
|
||||
if (Array.isArray(glob)) {
|
||||
const matchers = glob.map(g => new minimatch_1.Minimatch(g));
|
||||
for (const matcher of matchers) {
|
||||
if (matchBranchPattern(matcher, branchName)) {
|
||||
core.debug(` "branch" patterns matched against ${branchName}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
core.debug(` "branch" patterns did not match against ${branchName}`);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
const matcher = new minimatch_1.Minimatch(glob);
|
||||
return matchBranchPattern(matcher, branchName);
|
||||
}
|
||||
}
|
||||
function checkMatch(changedFiles, matchConfig) {
|
||||
if (matchConfig.all !== undefined) {
|
||||
if (!checkAll(changedFiles, matchConfig.all)) {
|
||||
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 (matchConfig.any !== undefined) {
|
||||
if (!checkAny(changedFiles, matchConfig.any)) {
|
||||
if (((_b = matchConfig.changedFiles) === null || _b === void 0 ? void 0 : _b.any) !== undefined) {
|
||||
if (!checkAny(changedFiles, matchConfig.changedFiles.any)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (matchConfig.branch !== undefined) {
|
||||
if (!checkBranch(matchConfig.branch)) {
|
||||
if (matchConfig.headBranch !== undefined) {
|
||||
if (!(0, branch_1.checkBranch)(matchConfig.headBranch, 'head')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (matchConfig.baseBranch !== undefined) {
|
||||
if (!(0, branch_1.checkBranch)(matchConfig.baseBranch, 'base')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user