Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to exclude labels #16

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ All configuration values, except `GITHUB_TOKEN`, are optional.

* `PR_LABELS`: Controls which labels _autoupdate_ will look for when monitoring PRs. Only used if `PR_FILTER="labelled"`. This can be either a single label or a comma-separated list of labels.

* `EXCLUDED_LABELS`: Controls which labels _autoupdate_ will ignore for when monitoring PRs. This option works with all `PR_FILTER` options, and it will be evaluated after it. This can be either a single label or a comma-separated list of labels.

* `MERGE_MSG`: A custom message to use when creating the merge commit from the destination branch to your pull request's branch.

* `RETRY_COUNT`: The number of times a branch update should be attempted before _autoupdate_ gives up (default: `"5"`).
Expand Down
10 changes: 10 additions & 0 deletions src/autoupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ class AutoUpdater {
}
}

const exclidedLabels = this.config.excludedLabels();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick - could you rename this to excludedLabels?

for (const label of pull.labels) {
if (exclidedLabels.includes(label.name)) {
ghCore.info(
`Pull request has excluded label '${label.name}', skipping update.`
);
return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a chance this may not work if PR_FILTER=labelled and a label matches - see line 167 above.

Would it make more sense if this exclusion check was done before anything else? i.e. moving this block up to just below line 143, before the if (prFilter === 'labelled') check.

}
}

ghCore.info('All checks pass and PR branch is behind base branch.');
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions src/config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class ConfigLoader {
return rawLabels.split(',').map((label) => label.trim());
}

excludedLabels() {
const rawLabels = this.getValue('EXCLUDED_LABELS', false, '');
return rawLabels.split(',').map((label) => label.trim());
}

mergeMsg() {
const msg = this.getValue(
'MERGE_MSG',
Expand Down