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

Missing optional scopes #8

Closed
stratosgear opened this issue Sep 6, 2021 · 3 comments
Closed

Missing optional scopes #8

stratosgear opened this issue Sep 6, 2021 · 3 comments
Assignees
Labels
feature/request New feature or request

Comments

@stratosgear
Copy link

stratosgear commented Sep 6, 2021

Is your feature request related to a problem? Please describe.
I cannot iterate over commits that are missing a scope.

According to the Tera docs of group-by, items that lack an attribute are discarded.

This means that if I want to have a scoped changelog, as per the git-cliff example, (and I do) then these commits are skipped from the changelog.

Describe the solution you'd like
I would like git-cliff to mark these commits in a specially named scope (maybe called unscoped? maybe have it configurable?) so I can iterate over them in my template and create a special section/heading for them

Describe alternatives you've considered
If git-cliff does not somehow mark these missing scopes, I do not believe there is an alternative on iterating over them.

Additional context
Some capture of the output of git-clif when scopes are missing:

# Changelog
All notable changes to this project will be documented in this file.

## [unreleased]

### Documentation

### Infrastructure

#### Ide

- Added git commit hooks for conventional messages
- Added suggested VS Code extensions

<!-- generated by git-cliff -->

Note the Documentation section that does not display any commits there (since the commit message is like docs: some commit message

@orhun
Copy link
Owner

orhun commented Sep 6, 2021

Hello! Thanks for submitting this. It's implemented in b5df656.

I thought it'd be best to make this configurable via commit_parsers so that a "default" scope can be used for each group:

commit_parsers = [
    { message = "^feat*", group = "Features", default_scope = "general"},
    { message = "^fix*", group = "Bug Fixes", default_scope = "other"},
    { message = "^doc*", group = "Documentation", default_scope = "unscoped"},
]

default_scope will be used if there's no "conventional scope" (in other words: if it's missing). So when you use the config values from above with the following git history:

* docs(config): support multiple file formats
* docs: some commit message

You get the following:

### Documentation

#### Config

- Document values

#### Unscoped

- Some commit message

I think this meets your requirements 😃

default_scope will be available with the next release but feel free to try it out now and report bugs if any.

@stratosgear
Copy link
Author

Sure, that would do fine!

Now, all I need is a new release so I can pull the new version in my build image so I can continue automating things. Sagol! :)

@orhun
Copy link
Owner

orhun commented Sep 11, 2021

v0.3.0 is released.

@orhun orhun closed this as completed Sep 11, 2021
kondanta added a commit to kondanta/git-cliff that referenced this issue Sep 19, 2021
Previously, cliff was sorting the commits by oldest first.
Like:

```
 - Support parsing the missing scopes with `default_scope` (orhun#8)
 - Support generating a changelog scoped to a directory (orhun#11)
```

As the PR numbers indicate, the first bullet point is definitely
older than the latter.

With this update, it will look like this:
```
 - Support generating a changelog scoped to a directory (orhun#11)
 - Support parsing the missing scopes with `default_scope` (orhun#8)
```

Signed-off-by: Taylan Dogan <[email protected]>
orhun added a commit that referenced this issue Sep 28, 2021
* refactor(changelog): sort commits by newest in CHANGELOG

Previously, cliff was sorting the commits by oldest first.
Like:

```
 - Support parsing the missing scopes with `default_scope` (#8)
 - Support generating a changelog scoped to a directory (#11)
```

As the PR numbers indicate, the first bullet point is definitely
older than the latter.

With this update, it will look like this:
```
 - Support generating a changelog scoped to a directory (#11)
 - Support parsing the missing scopes with `default_scope` (#8)
```

Signed-off-by: Taylan Dogan <[email protected]>

* refactor: add sorting flag

I don't expect any other sorting types will be added
so the logic consist of checking whether it is
`newest` or not.

One could argue with why wouldn't I make this a boolean.
My answer would be, in my opinion, it lose its meaning
because this is not something we want to enable or disable
but something that we want to decide which pattern
we want to use. So it is more like a semantic choice.

Signed-off-by: Taylan Dogan <[email protected]>

* docs(readme): move the explanation of sort flag to README.md

Co-authored-by: orhun <[email protected]>
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