Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Introduce tag_regex option with smart default#692

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
robertschweizer wants to merge6 commits intocommitizen-tools:master
base:master
Choose a base branch
Loading
fromrobertschweizer:filter-tags

Conversation

robertschweizer
Copy link
Contributor

Description

Closes#519

CLI flag name: --tag-regex

Heavily inspired by#537, but extends it with a smart default value to exclude non-release tags. This was suggested in#519 (comment)

I separated commits to make review easier.

Checklist

  • Add test cases to all the changes you introduce
  • Run./scripts/format and./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

Steps to Test This Pull Request

Additional context

@codecov
Copy link

codecovbot commentedMar 23, 2023
edited
Loading

Codecov Report

Patch coverage:97.72% and project coverage change:+0.69 🎉

Comparison is base(f04a719) 97.35% compared to head(8eea9ea) 98.04%.

❗ Current head8eea9ea differs from pull request most recent heade58e56f. Consider uploading reports for the commite58e56f to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@##           master     #692      +/-   ##==========================================+ Coverage   97.35%   98.04%   +0.69%==========================================  Files          42       41       -1       Lines        2041     1742     -299     ==========================================- Hits         1987     1708     -279+ Misses         54       34      -20
FlagCoverage Δ
unittests98.04% <97.72%> (+0.69%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
commitizen/bump.py100.00% <ø> (ø)
commitizen/cli.py93.93% <ø> (-0.27%)⬇️
commitizen/commands/init.py88.03% <66.66%> (+0.59%)⬆️
commitizen/changelog.py99.43% <100.00%> (-0.07%)⬇️
commitizen/commands/bump.py97.48% <100.00%> (-0.67%)⬇️
commitizen/commands/changelog.py98.94% <100.00%> (ø)
commitizen/defaults.py100.00% <100.00%> (ø)
commitizen/git.py98.61% <100.00%> (+0.01%)⬆️
commitizen/tags.py100.00% <100.00%> (ø)

... and9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment?Let us know in this issue.

We've been using this default already in `normalize_tag`,but setting this value in the settings dict is cleaner.
config_path and changelog_path rely on the modified CWD provided bytmp_commitizen_project, so they should use this fixture.
Closescommitizen-tools#519CLI flag name: --tag-regexHeavily inspired bycommitizen-tools#537, but extendsit with a smart default value to exclude non-release tags. This wassuggested incommitizen-tools#519 (comment)
@robertschweizer
Copy link
ContributorAuthor

It looks like these changes need some reworking because they partially duplicate what was done in3a1af6a.

Would you merge this if I rework it? It didn't get a review before.

VersionProtocol = Any


def tag_from_version(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

version_to_tag looks more straightforward to me

Suggested change
deftag_from_version(
defveresion_to_tag(

@@ -163,7 +164,9 @@ def get_tags(dateformat: str = "%Y-%m-%d") -> List[GitTag]:
forlineinc.out.split("\n")[:-1]
]

returngit_tags
filtered_git_tags= [tfortingit_tagsifpattern.fullmatch(t.name)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

maybe we can use git command to filter . but it's not requried.

@Lee-W
Copy link
Member

Hi@robertschweizer sorry for the late reply. I briefly walk through it. I like the idea and will definitely take a look after reworked 🙂

@robertschweizer
Copy link
ContributorAuthor

Sorry, I don't have much time at the moment. I started rebasing the first commit and opened#775 to get that merged.

To continue here (not sure if I will find the time myself), it's important to consider:

  • My use-case is to ignore tags in the changelog that we don't care about when runningcz bump --changelog. I probably don't need atag_regex.
  • cz bump --changelog sets the--incremental flag. This finds the previous version with a different logic thancz bump. The first line matchingversion_schema'sparser in the existing changelog is used as previous version.
    This version is then formatted withtag_format and searched for in existing tags with a similarity threshold of 0.89.
  • Suspected bugs incz changelog:
    • Existing tags (get_tags() function) and--rev-range values are validated by constructing the configuredversion_scheme on them.
      This means it matchespackaging.Version._regex instead ofBaseVersion.parser.
      BothSemVer andPep440 version providers thus usepackaging's PEP440 version matcher here.
      • The two standards require different pattern matching
    • --incremental usesversion_schema but ignorestag_format to search changelog.
      • Probablycz bump --changelog should pass the current (previous) release version explicitly, to make searching of the existing changelog unnecessary.
        • This would probably fix my use-case already.
      • It's probably rather restrictive to require the changelog to contain the used Git tag names.
  • ScmProvider should really use some smarter default regex matching when a non-standardtag_format is set. Maybe using placeholders other than$version intag_format should be deprecated to make this easier. The$version string can now be configured usingversion_scheme.

@Lee-W@noirbizarre

@woile
Copy link
Member

Looks good, hopefully we can merge it soon

Copy link
Member

@noirbizarrenoirbizarre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Seems to go the right way.
I added a few suggestions.

self.tag_format = args.get("tag_format") or self.config.settings.get(
"tag_format"
self.tag_format: str = args.get("tag_format") or self.config.settings.get(
"tag_format", DEFAULT_SETTINGS["tag_format"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You don't need to inject default there, default are already loaded and overwritten by actual settings


Type: `str`

Default: Based on `tag_format`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Default:Based on`tag_format`
Default:Computed from`tag_format`

or

Suggested change
Default:Based on`tag_format`
Default:Extrapolated from`tag_format`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not related to this PR, can you remove this ?

@@ -140,7 +141,7 @@ def get_filenames_in_commit(git_reference: str = ""):
raiseGitCommandError(c.err)


defget_tags(dateformat:str="%Y-%m-%d")->List[GitTag]:
defget_tags(dateformat:str="%Y-%m-%d",*,pattern:re.Pattern)->List[GitTag]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Make the pattern filtering optional:

Suggested change
defget_tags(dateformat:str="%Y-%m-%d",*,pattern:re.Pattern)->List[GitTag]:
defget_tags(dateformat:str="%Y-%m-%d",*,pattern:re.Pattern|None=None)->List[GitTag]:


from commitizen.tags import make_tag_pattern, tag_from_version

TAG_FORMATS: Dict[str, Dict[str, list]] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

As a failsafe, add a case for the minimal$version that should always work:

Suggested change
TAG_FORMATS:Dict[str,Dict[str,list]]= {
TAG_FORMATS:Dict[str,Dict[str,list]]= {
"$version": {
"tags_per_version": [
("1.2.3","1.2.3"),
("1.2.3a2","1.2.3a2"),
("1.2.3b2","1.2.3b2"),
("1.2.3+1.0.0","1.2.3+1.0.0"),
],
"invalid_tags": ["v1.2.3","unknown-tag","1-2-3","ver1.0.0"]
},

@AlexeySanko
Copy link

Looks as great feature for monorepo. Any update on it?

@woile
Copy link
Member

@robertschweizer do you think you could rebase? thanks!

@robertschweizer
Copy link
ContributorAuthor

Sorry, I won't have time to look into this in the next weeks.

@noirbizarre
Copy link
Member

I am wondering if#1297 is not providing somehow the same feature, but I might be wrong.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@noirbizarrenoirbizarrenoirbizarre left review comments

@Lee-WLee-WLee-W left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

generate changelog only from tags matching specific patterns
5 participants
@robertschweizer@Lee-W@woile@AlexeySanko@noirbizarre

[8]ページ先頭

©2009-2025 Movatter.jp