Skip to content

feat: add tag_prefix and fix changelog for monorepo #3

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

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions commitizen/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def tag_included_in_changelog(
return True


def get_version_tags(scheme: type[BaseVersion], tags: list[GitTag]) -> list[GitTag]:
def get_version_tags(scheme: type[BaseVersion], tags: list[GitTag], prefix: str = "") -> list[GitTag]:
valid_tags: list[GitTag] = []
for tag in tags:
try:
scheme(tag.name)
except InvalidVersion:
out.warn(f"InvalidVersion {tag}")
scheme(tag.name.replace(prefix, ''))
except InvalidVersion as e:
out.warn(f"InvalidVersion hey {tag}")

Choose a reason for hiding this comment

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

hey!

else:
valid_tags.append(tag)

Expand Down
2 changes: 2 additions & 0 deletions commitizen/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Settings(TypedDict, total=False):
version_scheme: str | None
version_type: str | None
tag_format: str
tag_prefix: str | None
bump_message: str | None
allow_abort: bool
allowed_prefixes: list[str]
Expand Down Expand Up @@ -76,6 +77,7 @@ class Settings(TypedDict, total=False):
"version_provider": "commitizen",
"version_scheme": None,
"tag_format": "$version", # example v$version
"tag_prefix": "",
"bump_message": None, # bumped v$current_version to $new_version
"allow_abort": False,
"allowed_prefixes": [
Expand Down
5 changes: 4 additions & 1 deletion commitizen/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,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(prefix: str, dateformat: str = "%Y-%m-%d") -> list[GitTag]:
inner_delimiter = "---inner_delimiter---"
formatter = (
f'"%(refname:lstrip=2){inner_delimiter}'
Expand All @@ -181,6 +181,9 @@ def get_tags(dateformat: str = "%Y-%m-%d") -> list[GitTag]:
for line in c.out.split("\n")[:-1]
]

if prefix:
git_tags = [tag for tag in git_tags if tag.name.startswith(prefix)]

return git_tags


Expand Down