commitizen icon indicating copy to clipboard operation
commitizen copied to clipboard

adds a changelog tag parser to filter tags (--tag-parser; tag_parser)

Open bhelgs opened this issue 3 years ago • 2 comments

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:

  1. feat: adds the filtering.

Subsequent commits (probably best reviewing each commit individually):

  1. test: adds a test for when a "feat:" commit is tagged. Previously only "bump:" commits were tagged.
  2. refactor: the linter was complaining. Mostly a copy/paste to reduce function complexity.
  3. 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/format and ./scripts/test locally 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

  1. 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-beta tag:
    • stay as ## v1.2.0-beta?
    • be replaced with ## Unreleased?
    • Maybe ## Prerelease tag: v1.2.0-beta?
    • be customizable?
  • No test in place yet.

Additional context

#519

bhelgs avatar Jul 19 '22 23:07 bhelgs

@hongkongkiwi sorry that it took some time to get back to making this PR.

bhelgs avatar Jul 19 '22 23:07 bhelgs

Codecov Report

Merging #537 (fbabc2a) into master (7b69599) will increase coverage by 0.02%. The diff coverage is 100.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 data Powered by Codecov. Last update 7916511...fbabc2a. Read the comment docs.

codecov[bot] avatar Jul 19 '22 23:07 codecov[bot]