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

Added exclude-contributors and no-contributors-template configuration options #898

Merged
merged 5 commits into from Sep 6, 2021

Conversation

ThomasKasene
Copy link
Contributor

As I mentioned in #569, I think it would be nice if we, as repository owners, would be able to remove ourselves from the list of contributors, so that we can more easily highlight 3rd party contributions.

I'm no JS developer myself and know precious little about Node, but I've made a best effort at adding a configuration option named exclude-contributors which removes specified usernames from the $CONTRIBUTORS variable.

I decided to not exclude the names that come from commit.author.name because if I understand the API correctly, they are not necessarily unique.

PS: I'm not sure if I committed all the necessary files, so that's something that the reviewer should double-check. I'm also not sure if I set up my development environment properly; there was one test suite that failed, even before I started making my changes:

 test/config.test.js
  ● Test suite failed to run

    Call retries were exceeded

      at ChildProcessWorker.initialize (node_modules/jest-worker/build/workers/ChildProcessWorker.js:193:21)

@ThomasKasene
Copy link
Contributor Author

Actually, I just realized that since I'm filtering values away, there's a chance the else-block here will end in an ArrayIndexOutOfBoundsException or something similar:

  const sortedContributors = Array.from(contributors).sort()
  if (sortedContributors.length > 1) {
    return (
      sortedContributors.slice(0, sortedContributors.length - 1).join(', ') +
      ' and ' +
      sortedContributors.slice(-1)
    )
  } else {
    return sortedContributors[0]
  }

I suppose it ought to be re-written into something like this:

  } else if (sortedContributors.length == 1) {
    return sortedContributors[0]
  } else {
    // What here?
  }

but then, what of the remaining branch? Should I also add a new configuration option called something like no-contributors-template that can be used here?

@ThomasKasene ThomasKasene marked this pull request as draft June 19, 2021 18:44
@ThomasKasene
Copy link
Contributor Author

I wrote the code for a no-contributors-template option too, but I'm waiting for feedback from @jetersen or somebody else before I commit it to this branch, since they might want it as a separate pull request.

@jetersen
Copy link
Member

could simply change it to the following

  } else if (sortedContributors.length == 1) {
    return sortedContributors[0]
  }

The method does not require to return any value.

@ThomasKasene
Copy link
Contributor Author

Interesting. I suppose that's another piece of weirdness of JavaScript. In that case, it is certainly an option, but what will the result be if the function doesn't return anything? If it's an empty String, then I think I would still like to be able to customize the message. Consider the following template:

template: |
  ## Contributors
  $CONTRIBUTORS

If all the contributors are filtered away, the release notes would contain the "Contributors" header, but nothing underneath it, which would look a little awkward.

But if you wish, I can add your suggestion to this branch, and submit a separate pull request for a no-contributors-template option?

@jetersen
Copy link
Member

jetersen commented Jun 20, 2021

Perhaps move all the header, filtering and sorting together and simply check if length is zero after contributors are filtered than return before adding the header. Feel free to push to this PR otherwise you are making it hard for me to review ☺️

@ThomasKasene
Copy link
Contributor Author

ThomasKasene commented Jun 20, 2021

Maybe we're misunderstanding one another, but I was talking about the template option, not a contributors-template (which currently doesn't exist); there's no header being added inside contributorsSentence. Maybe I could've been more clear and written a complete example:

exclude-contributors:
  - dependabot

template: |
  $CHANGES

  ## Contributors
  $CONTRIBUTORS

If a release is being made that only contains changes by dependabot, then the last part of the release notes would contain the "Contributors" header, but nothing else below it.

Given the same changes by dependabot, but with the following configuration, then at least there would be a little message under the header so it wouldn't look so empty:

exclude-contributors:
  - 'dependabot'

no-contributors-template: 'No third-party contributions this release.'

template: |
  $CHANGES

  ## Contributors
  $CONTRIBUTORS

I think these two options (exclude-contributors and no-contributors-template) are two that can be reviewed separately because they don't really affect one another (apart from the fact that they both add config to the signature of contributorsSentence), but it's up to you! 😃

@ThomasKasene ThomasKasene marked this pull request as ready for review June 20, 2021 10:40
@ThomasKasene ThomasKasene changed the title Added exclude-contributors configuration option Added exclude-contributors and no-contributors-template configuration options Jun 20, 2021
@jetersen
Copy link
Member

jetersen commented Sep 6, 2021

@ThomasKasene could you try and build with yarn to reduce the changes in dist folder?

yarn prettier && yarn lint --fix && yarn build

@ThomasKasene
Copy link
Contributor Author

@jetersen Absolutely! I'll take a look at it soon.

Do you want me to undo the spacing on the "Configuration Options" table in README.md as well? My lines ended up being a bit long and so I decided to expand the "width" of the other rows as well, but I realize now that it might cause unnecessary merge conflicts.

@jetersen
Copy link
Member

jetersen commented Sep 6, 2021

@ThomasKasene the linter will take care of it.

@ThomasKasene
Copy link
Contributor Author

Okay, nothing happened when I ran your suggested commands. I guess that means I either did it correctly by hand, or that the linter wasn't applied. Either way, dist/index.js got a little better now.

@jetersen
Copy link
Member

jetersen commented Sep 6, 2021

git merge master & yarn install is important :)

Anyhow ended up doing it for ya

@jetersen jetersen merged commit e5149cf into release-drafter:master Sep 6, 2021
@jetersen jetersen added the type: feature New feature or request label Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants