adds a changelog tag parser to filter tags (--tag-parser; tag_parser)
Description
Some repositories have tags that are not matching the bump version pattern (e.g. alpha/beta release) #519.
It makes sense to be able to filter those out. See this "Expected Behavior" section for an example.
The first commit:
- feat: adds the filtering.
Subsequent commits (probably best reviewing each commit individually):
- test: adds a test for when a "feat:" commit is tagged. Previously only "bump:" commits were tagged.
- refactor: the linter was complaining. Mostly a copy/paste to reduce function complexity.
- refactor: further refactoring to reduce the number of
if(by avoiding an optional).
Checklist
- [x] Add test cases to all the changes you introduce
- [x] Run
./scripts/formatand./scripts/testlocally to ensure this change passes linter check and test - [x] Test the changes on the local machine manually
- [x] Update the documentation for the changes
Expected behavior
originally:
## v1.1.0(2022-02-13)
### Feat
- add more
## v1.1.0-beta (2022-02-13)
### Feat
- add new
## v1.0.0 (2022-02-13)
### Feat
- initial
once filtered with cz changelog --dry-run --tag-parser 'v[0-9]*\.[0-9]*\.[0-9]*' will be:
## v1.1.0 (2022-02-13)
### Feat
- add more
- add new
## v1.0.0 (2022-02-13)
### Feat
- initial
Similar can be done with the toml option: tag_parser: "v[0-9]*\\.[0-9]*\\.[0-9]*". Note toml required an extra \.
Steps to Test This Pull Request
scripts/test
In the case below there is a filterable tag as the first commit.
## v1.2.0-beta (2022-02-13)
### Feat
- another thing
## v1.1.0 (2022-02-13)
### Feat
- add more
- add new
## v1.0.0 (2022-02-13)
### Feat
- initial
Question:
- Should the
v1.2.0-betatag:- stay as
## v1.2.0-beta? - be replaced with
## Unreleased? - Maybe
## Prerelease tag: v1.2.0-beta? - be customizable?
- stay as
- No test in place yet.
Additional context
#519
@hongkongkiwi sorry that it took some time to get back to making this PR.
Codecov Report
Merging #537 (fbabc2a) into master (7b69599) will increase coverage by
0.02%. The diff coverage is100.00%.
@@ Coverage Diff @@
## master #537 +/- ##
==========================================
+ Coverage 97.92% 97.94% +0.02%
==========================================
Files 39 39
Lines 1540 1557 +17
==========================================
+ Hits 1508 1525 +17
Misses 32 32
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 97.94% <100.00%> (+0.02%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| commitizen/cli.py | 93.93% <ø> (ø) |
|
| commitizen/__version__.py | 100.00% <100.00%> (ø) |
|
| commitizen/changelog.py | 96.73% <100.00%> (-0.53%) |
:arrow_down: |
| commitizen/commands/bump.py | 96.42% <100.00%> (+1.23%) |
:arrow_up: |
| commitizen/commands/changelog.py | 96.77% <100.00%> (+0.18%) |
:arrow_up: |
| commitizen/commands/check.py | 100.00% <100.00%> (ø) |
|
| commitizen/cz/__init__.py | 100.00% <100.00%> (ø) |
|
| commitizen/defaults.py | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 7916511...fbabc2a. Read the comment docs.