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

Feature request: exclude PRs with specific labels from commenting #361

Closed
ylemkimon opened this issue Apr 28, 2021 · 3 comments
Closed

Feature request: exclude PRs with specific labels from commenting #361

ylemkimon opened this issue Apr 28, 2021 · 3 comments

Comments

@ylemkimon
Copy link

This is somewhat similar to #359.

There may be some PRs that don't need release comments, such as dependency management and chores. It'd be nice to exclude them by labels like:

--- a/lib/success.js
+++ b/lib/success.js
@@ -28,6 +28,7 @@ module.exports = async (pluginConfig, context) => {
     successComment,
     failComment,
     failTitle,
+    excludeCommentLabels,
     releasedLabels,
     addReleases,
   } = resolveConfig(pluginConfig, context);
@@ -45,7 +46,8 @@ module.exports = async (pluginConfig, context) => {
     const releaseInfos = releases.filter((release) => Boolean(release.name));
     const shas = commits.map(({hash}) => hash);
 
-    const searchQueries = getSearchQueries(`repo:${owner}/${repo}+type:pr+is:merged`, shas).map(
+    const labelQuery = excludeCommentLabels ? excludeCommentLabels.map((label) => `+-label:"${label}"`).join('') : '';
+    const searchQueries = getSearchQueries(`repo:${owner}/${repo}+type:pr+is:merged${labelQuery}`, shas).map(
       async (q) => (await github.search.issuesAndPullRequests({q})).data.items
     );
@melink14
Copy link

I don't even think labels are needed; it was very surprising that this was posted for commits which were not part of the release spec.

Given that the plugin is given information on which commits are considered 'worth making a release' for, maybe there should be an option for 'only include version changing commits'?

<I can start a new issue for this but added it here because the reasoning for wanting it is the same; exclude chore/docs and other PRs which may not go to users>

@melink14
Copy link

I looked through the plugin development guide and it seems a filtered list of commits isn't passed through context so a preset based fix isn't as trivial as I thought.

It seems like the expectation is all filtering steps (analyze, generate notes) are expected to just use the same filtering logic independently.

github could do that too but it may be too ancillary compared to its core function so maybe a label based mechanism would be more palatable to the maintainers?

@babblebey
Copy link
Member

This is now possible in configuration with the successCommentCondition property following the merge of #874... You can set your conditions through lodash templates with access to the release context object

successCommentCondition: "<% return issue.label?.includes('specific-label-name') %>"

The above config sets you up for only comment/label issues and pull-requests with specific label, if you intend it to be PRs alone then you want to state for PRs alone like so....

successCommentCondition: "<% return issue.pull_request && issue.label?.includes('specific-label-name') %>"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants