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

Support creating the changelog based on pull requests only #656

Closed
1 task done
landerss1 opened this issue May 26, 2024 · 7 comments
Closed
1 task done

Support creating the changelog based on pull requests only #656

landerss1 opened this issue May 26, 2024 · 7 comments
Assignees
Labels
feature/request New feature or request question Further information is requested

Comments

@landerss1
Copy link

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

It's very common to use branch protection rules with GitHub to require a pull request before merging. With this in place, it's actually not that relevant to use the individual commits to create the changelog. Instead, you would rather use the PR titles alone with the commit-parsers to get the group, scope and so on. However, currently there is no support for doing this as

  1. You can not limit the commits to pull requests only
  2. The commit parsers don't allow parsing the pr_title attribute (maybe they do, but as not all commits are pull requests it doesn't work)

Desired solution

When using GitHub, add a config flag that allows you to fetch only pull requests, e.g pull_requests_only = true. Furthermore, allow the commit parsers to use the pr_title field instead of the message field to set the group and scope.

Alternatives considered

Have tried pre-processing to modify the commit message, but sometimes there's a lot of commit messages in there when there's an associated PR, and it makes it very hard to make any sense of the contents of the message.

Additional context

No response

@landerss1 landerss1 added the feature/request New feature or request label May 26, 2024
@orhun
Copy link
Owner

orhun commented May 26, 2024

I think adding a new configuration option for this might be too much.

Instead, you can simply achieve this by filtering by the github attribute in the template. For example:

{% if commit.github.pr_number %}
  [#{{ commit.github.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.github.pr_number }})
{%- endif -%}

The commit parsers don't allow parsing the pr_title attribute (maybe they do, but as not all commits are pull requests it doesn't work)

The example I gave above will likely work in this case because we are checking if the pr_number exists.

Hope this helps! 🐻

@landerss1
Copy link
Author

I'm already using the suggested technique to filter out the commits, but it doesn't solve the case where the commit message don't allow me to use a parser to group them properly. So my fallback now is to use a catch all and assign a miscellaneous group, but the result is that PR:s that clearly should have a different group now end up in the miscellaneous group. If I could use the pr_title for the parser it wouldn't be a problem.

@orhun
Copy link
Owner

orhun commented May 27, 2024

Can you share some example commits and snippet from your configuration (especially commit_parsers)?

If I could use the pr_title for the parser it wouldn't be a problem.

That would be straightforward to implement actually 🤔

@orhun orhun added the question Further information is requested label Jun 1, 2024
@sandstrom
Copy link

I'm also interested in this one, we have the exact same problem.

We would like to mimic what Githubs built-in changelog generator does, which is to to list only the PRs, with the titles and some other metadata, grouped based on a label.

https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes

@orhun
Copy link
Owner

orhun commented Oct 29, 2024

This should be now possible after #758 (simply use github.pr_title for the parser)

See https://git-cliff.org/blog/2.5.0#-grouping-by-arbitrary-fields

@orhun orhun closed this as completed Oct 29, 2024
@sandstrom
Copy link

@orhun Awesome! 😄

@landerss1
Copy link
Author

That's good news. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/request New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants