-
-
Notifications
You must be signed in to change notification settings - Fork 281
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
c26e5bd
0aa98e1
10c7a9a
c0ff3af
c780f4e
e58e56f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
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)
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import os | ||
import re | ||
from enum import Enum | ||
from os import linesep | ||
from pathlib import Path | ||
|
@@ -140,7 +141,7 @@ def get_filenames_in_commit(git_reference: str = ""): | |
raise GitCommandError(c.err) | ||
|
||
|
||
def get_tags(dateformat: str = "%Y-%m-%d") -> List[GitTag]: | ||
def get_tags(dateformat: str = "%Y-%m-%d", *, pattern: re.Pattern) -> List[GitTag]: | ||
inner_delimiter = "---inner_delimiter---" | ||
formatter = ( | ||
f'"%(refname:lstrip=2){inner_delimiter}' | ||
|
@@ -163,7 +164,9 @@ def get_tags(dateformat: str = "%Y-%m-%d") -> List[GitTag]: | |
for line in c.out.split("\n")[:-1] | ||
] | ||
|
||
return git_tags | ||
filtered_git_tags = [t for t in git_tags if pattern.fullmatch(t.name)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
return filtered_git_tags | ||
|
||
|
||
def tag_exist(tag: str) -> bool: | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -42,6 +42,14 @@ Default: `$version` | |||||||||
|
||||||||||
Format for the git tag, useful for old projects, that use a convention like `"v1.2.1"`. [Read more][tag_format] | ||||||||||
|
||||||||||
### `tag_regex` | ||||||||||
|
||||||||||
Type: `str` | ||||||||||
|
||||||||||
Default: Based on `tag_format` | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
or
Suggested change
|
||||||||||
|
||||||||||
Tags must match this to be included in the changelog (e.g. `"([0-9.])*"` to exclude pre-releases). [Read more][tag_regex] | ||||||||||
|
||||||||||
### `update_changelog_on_bump` | ||||||||||
|
||||||||||
Type: `bool` | ||||||||||
|
@@ -339,6 +347,7 @@ setup( | |||||||||
|
||||||||||
[version_files]: bump.md#version_files | ||||||||||
[tag_format]: bump.md#tag_format | ||||||||||
[tag_regex]: changelog.md#tag_regex | ||||||||||
[bump_message]: bump.md#bump_message | ||||||||||
[major-version-zero]: bump.md#-major-version-zero | ||||||||||
[prerelease-offset]: bump.md#-prerelease_offset | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not related to this PR, can you remove this ? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[virtualenvs] | ||
in-project = true |
There was a problem hiding this comment.
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: