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

allow limiting commits to scoped ones #749

Open
1 task done
tobiaskohlbau opened this issue Jul 8, 2024 · 4 comments
Open
1 task done

allow limiting commits to scoped ones #749

tobiaskohlbau opened this issue Jul 8, 2024 · 4 comments
Assignees
Labels
feature/request New feature or request

Comments

@tobiaskohlbau
Copy link

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

I have a monorepo where multiple projects are mixed into each other. This results in include and exclude path not being an option. I've tried to set a default scope for each commit parser and used scopes in each commit in order to assign it either to a specific project or an overlapping one. So for e.g. if a commit is affecting multiple projects we drop the scope within the commit title and fall back to a default scope called overlapping. The concrete problem is the lack of an option to filter commits by its scope in order to say for e.g. render the changelog for project A and every potentially overlapping commit.

Desired solution

It would be nice to have some kind of scope option to specify either in configuration or by cli argument to say: please filter every commit by the following scopes.

The desired call would look for e.g. like:

git cliff --scope "Project A" --scope overlapping --tag-pattern "projecta/.*"

Alternatives considered

I'm not aware of a good alternative, but please let me know if something else comes to mind.

Additional context

I've tinkered with the repository and tried to implement a proof of concept in tobiaskohlbau@6133504. I would like to work on this if it gets accepted but most likely need some guidance as I've never done Rust before (Best practices etc.).

@tobiaskohlbau tobiaskohlbau added the feature/request New feature or request label Jul 8, 2024
Copy link

welcome bot commented Jul 8, 2024

Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️

@orhun
Copy link
Owner

orhun commented Sep 15, 2024

Hey! Thanks for the issue and sorry for the delayed response.

Have you tried using the scope filter within commit_parsers, like so:

[git]
# regex for parsing and grouping commits
commit_parsers = [
  { message = "(www)", scope = "Application" }
]

Then you can use this scope for grouping in the template:

{% for group, commits in commits | group_by(attribute="scope") %}
#### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\

Check out the scoped template example to see if it works for you.

Let me know if there is anything else that I can help :)

@tobiaskohlbau
Copy link
Author

tobiaskohlbau commented Sep 16, 2024

Hi thanks for the reply.

IIRC the issue is that it's not possible to produce an changelog for a specific scope. The issue lies on the side of the collection not on the side of generation. Let's assume one releases Project A which has scope "projecta". In addition to everything scoped it's also desired to show common changes in such changelog. The changelog for each project should be generated by different invocations (different changelogs) as it's attached to the release for such subproject. Normally this would be done with include or exclude paths, to only include files changed within a subfolder. But in my scenario changes to common files outside the directory should be shown as well.

I'm suggesting filtering the commits similar to "include/exclude" on it's scope before passing it to the generating step.

@orhun
Copy link
Owner

orhun commented Sep 21, 2024

I see, I still feel like this might be somehow possible currently.

For me to understand this better and kickstart the implementation, can you help me come up with a test fixture?

I need a list of commits as follows, example configuration and expected output. e.g.

git init
git commit --allow-empty -m "Initial commit"

touch scope-a/x
git add scope-a
git commit  -m "feat(scope-a): add feature 1"

touch scope-a/y
git add scope-a
git commit  -m "feat(scope-b): add feature 1"

git tag v0.1.0

and then I need the command e.g. git cliff --include-path scope-a etc. etc. and lastly what you expect to see in the output 🐻

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
Projects
None yet
Development

No branches or pull requests

2 participants