mirror of
https://github.com/actions/labeler.git
synced 2025-12-10 11:41:56 +00:00
Added output (#60)
* Added output * removed formatting changes * more formatting changes * Fix merge conflicts * Small test refactoring * tests are passing * Add a test * Add a small jest mock for addLabels. Not used. * Add tests for more cases * get rid of an unused jest mock * fix review points * rebuild + minor README fix * fix review points * update tests * fix formatting * add tests, fix bug * cleanup --------- Co-authored-by: Daniel Shteremberg <dshteremberg@labelbox.com> Co-authored-by: Daniel Shteremberg <Daniel@Daniel-Shterembergs-MacBook-Pro.local> Co-authored-by: Patrick Ellis <patrick.j.ellis@gmail.com> Co-authored-by: Andrey Lobanovich <andrei.lobanovich@akvelon.com>
This commit is contained in:
committed by
GitHub
parent
375538a703
commit
0967ca812e
14
dist/index.js
vendored
14
dist/index.js
vendored
@@ -68,8 +68,8 @@ function run() {
|
||||
core.debug(`fetching changed files for pr #${prNumber}`);
|
||||
const changedFiles = yield getChangedFiles(client, prNumber);
|
||||
const labelGlobs = yield getLabelGlobs(client, configPath);
|
||||
const prLabels = pullRequest.labels.map(label => label.name);
|
||||
const allLabels = new Set(prLabels);
|
||||
const preexistingLabels = pullRequest.labels.map(l => l.name);
|
||||
const allLabels = new Set(preexistingLabels);
|
||||
for (const [label, globs] of labelGlobs.entries()) {
|
||||
core.debug(`processing ${label}`);
|
||||
if (checkGlobs(changedFiles, globs, dot)) {
|
||||
@@ -79,12 +79,16 @@ function run() {
|
||||
allLabels.delete(label);
|
||||
}
|
||||
}
|
||||
const labels = [...allLabels].slice(0, GITHUB_MAX_LABELS);
|
||||
const labelsToAdd = [...allLabels].slice(0, GITHUB_MAX_LABELS);
|
||||
const excessLabels = [...allLabels].slice(GITHUB_MAX_LABELS);
|
||||
try {
|
||||
if (!isListEqual(prLabels, labels)) {
|
||||
yield setLabels(client, prNumber, labels);
|
||||
let newLabels = [];
|
||||
if (!isListEqual(labelsToAdd, preexistingLabels)) {
|
||||
yield setLabels(client, prNumber, labelsToAdd);
|
||||
newLabels = labelsToAdd.filter(l => !preexistingLabels.includes(l));
|
||||
}
|
||||
core.setOutput('new-labels', newLabels.join(','));
|
||||
core.setOutput('all-labels', labelsToAdd.join(','));
|
||||
if (excessLabels.length) {
|
||||
core.warning(`Maximum of ${GITHUB_MAX_LABELS} labels allowed. Excess labels: ${excessLabels.join(', ')}`, { title: 'Label limit for a PR exceeded' });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user