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: add config option for line length warning #1574

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

Open
Narwhal-fish wants to merge 50 commits into commitizen-tools:master
base: master
Choose a base branch
Loading
from Narwhal-fish:feat/Add-config-option-for-line-length-warning
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
312ca49
refactor(ParseArgs): simplify __call__ function body
bearomorphism Jun 12, 2025
56ef1e0
refactor(ExpectedExit): make the constructor more compact
bearomorphism Jun 12, 2025
8cf7acd
refactor(ScmProvider): replace sorted with max
bearomorphism Jun 12, 2025
fb04e28
refactor(git): remove redundant if branch
bearomorphism Jun 12, 2025
1a1fdc6
fix(Bump): rewrite --get-next NotAllowed error message for consistency
bearomorphism Jun 13, 2025
93f0f27
fix(Changelog): fix _export_template variable type
bearomorphism Jun 13, 2025
7a531db
refactor(TagRules): extract tag_formats property and simplify list co...
bearomorphism Jun 13, 2025
9163ae2
refactor(Init): use ternary operator
bearomorphism Jun 10, 2025
6a90185
refactor(bump): use a loop to shorten a series of similar NotAllowed ...
bearomorphism Jun 9, 2025
c169e09
fix: raise NoVersionSpecifiedError if version is None, and adjust cal...
bearomorphism Jun 13, 2025
0fa668d
docs(taplo): add toml formatter
bearomorphism May 25, 2025
d9f5b49
docs(pre-commit): add taplo to pre-commit hook
bearomorphism May 25, 2025
aa9ab24
refactor(Changelog): remove unnecessary intermediate variables for be...
bearomorphism Jun 13, 2025
3d635d2
refactor(changelog): shorten condition expression and early return
bearomorphism Jun 12, 2025
68c4360
refactor(Init): extract _get_config_data for readability
bearomorphism Jun 11, 2025
05c1722
refactor(process_commit_message): better type and early return
bearomorphism Jun 12, 2025
4a1c516
build: remove not needed importlib-metadata dependency for python >= ...
bearomorphism Jun 10, 2025
84706e1
docs(defaults): deprecate type Questions
bearomorphism Jun 10, 2025
936352b
docs(customization.md): fix grammar mistake, add title to code blocks
bearomorphism Jun 10, 2025
7dccbf6
docs(bump.md): add titles to code blocks and fix minor grammar issues
bearomorphism Jun 11, 2025
189cf0b
ci(github-actions): set organization to true for JamesIves/github-spo...
Lee-W Jun 13, 2025
1d92a05
ci(deps): bump dawidd6/action-homebrew-bump-formula from 4 to 5
dependabot[bot] Jun 16, 2025
fe48353
docs(config.md): Document glob pattern support in `version_files`
edgarrmondragon Jul 12, 2025
eca443d
docs(third-party-commitizen.md): Add cz-path info
Tatsh Jul 14, 2025
83d9308
ci(github-actions): fix sponsorship page generation
Lee-W Jul 15, 2025
40d3062
docs(README): install into dev dependency when using uv
timsu92 Aug 6, 2025
89600f0
docs(README): ensure line break
timsu92 Aug 6, 2025
a69d441
refactor(init): remote extra words
timsu92 Aug 6, 2025
6828582
feat: implement message length limit for commit messages
Narwhal-fish Aug 11, 2025
c300b70
docs(config): add message length limit configuration option
Narwhal-fish Aug 12, 2025
b8918a1
refactor(Init): fix unbounded variable in _ask_tag_format
bearomorphism Jun 10, 2025
30baeab
test(Init): improve coverage for _ask_tag_format
bearomorphism Jun 10, 2025
e70c0a6
fix(ExitCode): add from_str in ExitCode and replace parse_no_raise wi...
bearomorphism Jun 12, 2025
c162290
refactor: use None instead of 0 for message_length_limit and update r...
Narwhal-fish Aug 13, 2025
999f298
Merge branch 'v4-9-0-test' into feat/Add-config-option-for-line-lengt...
Narwhal-fish Aug 13, 2025
d417cf7
fix(Init): fix a typo in _ask_version_provider options and remove unn...
bearomorphism Jun 10, 2025
0c4085e
Merge branch 'v4-9-0-test' into feat/Add-config-option-for-line-lengt...
Narwhal-fish Aug 13, 2025
af6aa62
style: fix line length formatting in check.py
actions-user Aug 13, 2025
1118f65
fix(init): make welcome message easier to read
bearomorphism Jun 9, 2025
e28e3ce
refactor(Init): remove unnecessary methods from ProjectInfo and refac...
bearomorphism Jun 10, 2025
a498804
test(Init): cover _ask_tag test
bearomorphism Jun 10, 2025
d9058b6
fix(init): use pre-push as pre-commit stage
timsu92 Aug 6, 2025
445f013
test(init): check "pre-" is showing in outputs
timsu92 Aug 6, 2025
0b374af
refactor(Init): remove the variable values_to_add and the update_conf...
bearomorphism Jun 11, 2025
f8be15a
test(Init): improve test coverage on config initialization
bearomorphism Jun 11, 2025
f30ae2e
refactor(changelog): shorten generate_tree_from_commits
bearomorphism Jun 12, 2025
7cd62fb
feat(check): add check against default branch
bearomorphism Jun 3, 2025
3b00235
test(changelog): ensure error on missing changelog template filename
ongdisheng Jul 6, 2025
69db5b4
fix(dependencies): update tomlkit version to >=0.8.0,<1.0.0
Narwhal-fish Aug 19, 2025
db902f9
Merge branch 'v4-9-0-test' into feat/Add-config-option-for-line-lengt...
Narwhal-fish Aug 24, 2025
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
23 changes: 11 additions & 12 deletions .github/workflows/docspublish.yml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
workflow_dispatch:

jobs:
update-cli-screenshots:
Expand Down Expand Up @@ -58,21 +59,19 @@ jobs:
python -m pip install -U pip poetry poethepoet
poetry --version
poetry install --no-root --only documentation
- name: Build docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry doc:build
- name: Generate Sponsors 💖
uses: JamesIves/github-sponsors-readme-action@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_FOR_ORG }}
file: "docs/README.md"
- name: Push doc to Github Page
uses: peaceiris/actions-gh-pages@v4
organization: true
- name: Build docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
poetry doc:build
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
personal_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
publish_branch: gh-pages
publish_dir: ./site
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
folder: ./site # The folder the action should deploy.
branch: gh-pages
2 changes: 1 addition & 1 deletion .github/workflows/homebrewpublish.yml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
echo "project_version=$(cz version --project)" >> $GITHUB_ENV
- name: Update Homebrew formula
uses: dawidd6/action-homebrew-bump-formula@v4
uses: dawidd6/action-homebrew-bump-formula@v5
with:
token: ${{secrets.PERSONAL_ACCESS_TOKEN}}
formula: commitizen
Expand Down
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
- id: debug-statements
- id: no-commit-to-branch
- id: check-merge-conflict
- id: check-toml
- id: check-toml # TOML linter (syntax checker)
- id: check-yaml
args: [ '--unsafe' ] # for mkdocs.yml
- id: detect-private-key
Expand Down Expand Up @@ -55,17 +55,22 @@ repos:
stages:
- post-commit

- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format

- repo: local
hooks:
- id: format
name: Format
name: Format Python code via Poetry
language: system
pass_filenames: false
entry: poetry format
types: [ python ]

- id: linter and test
name: Linters
name: Linters via Poetry
language: system
pass_filenames: false
entry: poetry lint
Expand Down
4 changes: 4 additions & 0 deletions .taplo.toml
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include = ["pyproject.toml", ".taplo.toml"]

[formatting]
indent_string = " "
42 changes: 23 additions & 19 deletions commitizen/changelog.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import re
from collections import OrderedDict, defaultdict
from collections.abc import Generator, Iterable, Mapping, Sequence
from collections.abc import Generator, Iterable, Mapping, MutableMapping, Sequence
from dataclasses import dataclass
from datetime import date
from typing import TYPE_CHECKING, Any
Expand Down Expand Up @@ -167,8 +167,8 @@ def process_commit_message(
hook: MessageBuilderHook | None,
parsed: re.Match[str],
commit: GitCommit,
changes: dict[str | None, list],
change_type_map: dict[str, str] | None = None,
ref_changes: MutableMapping[str | None, list],
change_type_map: Mapping[str, str] | None = None,
) -> None:
message: dict[str, Any] = {
"sha1": commit.rev,
Expand All @@ -178,13 +178,16 @@ def process_commit_message(
**parsed.groupdict(),
}

if processed := hook(message, commit) if hook else message:
messages = [processed] if isinstance(processed, dict) else processed
for msg in messages:
change_type = msg.pop("change_type", None)
if change_type_map:
change_type = change_type_map.get(change_type, change_type)
changes[change_type].append(msg)
processed_msg = hook(message, commit) if hook else message
if not processed_msg:
return

messages = [processed_msg] if isinstance(processed_msg, dict) else processed_msg
for msg in messages:
change_type = msg.pop("change_type", None)
if change_type_map:
change_type = change_type_map.get(change_type, change_type)
ref_changes[change_type].append(msg)


def generate_ordered_changelog_tree(
Expand Down Expand Up @@ -251,6 +254,7 @@ def incremental_build(
unreleased_start = metadata.unreleased_start
unreleased_end = metadata.unreleased_end
latest_version_position = metadata.latest_version_position

skip = False
output_lines: list[str] = []
for index, line in enumerate(lines):
Expand All @@ -260,9 +264,7 @@ def incremental_build(
skip = False
if (
latest_version_position is None
or isinstance(latest_version_position, int)
and isinstance(unreleased_end, int)
and latest_version_position > unreleased_end
or latest_version_position > unreleased_end
):
continue

Expand All @@ -271,13 +273,15 @@ def incremental_build(

if index == latest_version_position:
output_lines.extend([new_content, "\n"])

output_lines.append(line)
if not isinstance(latest_version_position, int):
if output_lines and output_lines[-1].strip():
# Ensure at least one blank line between existing and new content.
output_lines.append("\n")
output_lines.append(new_content)

if latest_version_position is not None:
return output_lines

if output_lines and output_lines[-1].strip():
# Ensure at least one blank line between existing and new content.
output_lines.append("\n")
output_lines.append(new_content)
return output_lines


Expand Down
11 changes: 3 additions & 8 deletions commitizen/cli.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,13 @@ def __call__(
) -> None:
if not isinstance(values, str):
return
if "=" not in values:

key, sep, value = values.partition("=")
if not key or not sep:
raise InvalidCommandArgumentError(
f"Option {option_string} expect a key=value format"
)
kwargs = getattr(namespace, self.dest, None) or {}
key, value = values.split("=", 1)
if not key:
raise InvalidCommandArgumentError(
f"Option {option_string} expect a key=value format"
)
kwargs[key] = value.strip("'\"")
setattr(namespace, self.dest, kwargs)

Expand Down Expand Up @@ -163,7 +160,6 @@ def __call__(
{
"name": ["-l", "--message-length-limit"],
"type": int,
"default": 0,
"help": "length limit of the commit message; 0 for no limit",
},
{
Expand Down Expand Up @@ -495,7 +491,6 @@ def __call__(
{
"name": ["-l", "--message-length-limit"],
"type": int,
"default": 0,
"help": "length limit of the commit message; 0 for no limit",
},
],
Expand Down
61 changes: 22 additions & 39 deletions commitizen/commands/bump.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
NoPatternMapError,
NotAGitProjectError,
NotAllowed,
NoVersionSpecifiedError,
)
from commitizen.providers import get_provider
from commitizen.tags import TagRules
Expand Down Expand Up @@ -163,11 +162,7 @@ def _find_increment(self, commits: list[git.GitCommit]) -> Increment | None:
def __call__(self) -> None:
"""Steps executed to bump."""
provider = get_provider(self.config)

try:
current_version = self.scheme(provider.get_version())
except TypeError:
raise NoVersionSpecifiedError()
current_version = self.scheme(provider.get_version())

increment = self.arguments["increment"]
prerelease = self.arguments["prerelease"]
Expand All @@ -177,36 +172,22 @@ def __call__(self) -> None:
build_metadata = self.arguments["build_metadata"]
get_next = self.arguments["get_next"]
allow_no_commit = self.arguments["allow_no_commit"]
major_version_zero = self.arguments["major_version_zero"]

if manual_version:
if increment:
raise NotAllowed("--increment cannot be combined with MANUAL_VERSION")

if prerelease:
raise NotAllowed("--prerelease cannot be combined with MANUAL_VERSION")

if devrelease is not None:
raise NotAllowed("--devrelease cannot be combined with MANUAL_VERSION")

if is_local_version:
raise NotAllowed(
"--local-version cannot be combined with MANUAL_VERSION"
)

if build_metadata:
raise NotAllowed(
"--build-metadata cannot be combined with MANUAL_VERSION"
)

if self.bump_settings["major_version_zero"]:
raise NotAllowed(
"--major-version-zero cannot be combined with MANUAL_VERSION"
)

if get_next:
raise NotAllowed("--get-next cannot be combined with MANUAL_VERSION")

if self.bump_settings["major_version_zero"] and current_version.release[0]:
for val, option in (
(increment, "--increment"),
(prerelease, "--prerelease"),
(devrelease is not None, "--devrelease"),
(is_local_version, "--local-version"),
(build_metadata, "--build-metadata"),
(major_version_zero, "--major-version-zero"),
(get_next, "--get-next"),
):
if val:
raise NotAllowed(f"{option} cannot be combined with MANUAL_VERSION")

if major_version_zero and current_version.release[0]:
raise NotAllowed(
f"--major-version-zero is meaningless for current version {current_version}"
)
Expand All @@ -215,11 +196,13 @@ def __call__(self) -> None:
raise NotAllowed("--local-version cannot be combined with --build-metadata")

if get_next:
# if trying to use --get-next, we should not allow --changelog or --changelog-to-stdout
if self.changelog_flag or self.changelog_to_stdout:
raise NotAllowed(
"--changelog or --changelog-to-stdout is not allowed with --get-next"
)
for value, option in (
(self.changelog_flag, "--changelog"),
(self.changelog_to_stdout, "--changelog-to-stdout"),
):
if value:
raise NotAllowed(f"{option} cannot be combined with --get-next")

# --get-next is a special case, taking precedence over config for 'update_changelog_on_bump'
self.changelog_config = False
# Setting dry_run to prevent any unwanted changes to the repo or files
Expand Down
Loading
Loading

AltStyle によって変換されたページ (->オリジナル) /