MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / BaseCommitizen

Class BaseCommitizen

commitizen/cz/base.py:38–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36
37
38class BaseCommitizen(metaclass=ABCMeta):
39 bump_pattern: str | None = None
40 bump_map: Mapping[str, str | None] | None = None
41 bump_map_major_version_zero: Mapping[str, str | None] | None = None
42 default_style_config: list[tuple[str, str]] = [
43 ("qmark", "fg:#ff9d00 bold"),
44 ("question", "bold"),
45 ("answer", "fg:#ff9d00 bold"),
46 ("pointer", "fg:#ff9d00 bold"),
47 ("highlighted", "fg:#ff9d00 bold"),
48 ("selected", "fg:#cc5454"),
49 ("separator", "fg:#cc5454"),
50 ("instruction", ""),
51 ("text", ""),
52 ("disabled", "fg:#858585 italic"),
53 ]
54
55 # The whole subject will be parsed as a message by default
56 # This allows supporting changelog for any rule system.
57 # It can be modified per rule
58 commit_parser: str | None = r"(?P<message>.*)"
59 changelog_pattern: str | None = r".*"
60 change_type_map: dict[str, str] | None = None
61 change_type_order: list[str] | None = None
62
63 # Executed per message parsed by the commitizen
64 changelog_message_builder_hook: MessageBuilderHook | None = None
65
66 # Executed only at the end of the changelog generation
67 changelog_hook: Callable[[str, str | None], str] | None = None
68
69 # Executed for each release in the changelog
70 changelog_release_hook: ChangelogReleaseHook | None = None
71
72 # Plugins can override templates and provide extra template data
73 template_loader: BaseLoader = PackageLoader("commitizen", "templates")
74 template_extras: dict[str, Any] = {}
75
76 def __init__(self, config: BaseConfig) -> None:
77 self.config = config
78 if not self.config.settings.get("style"):
79 self.config.settings.update({"style": BaseCommitizen.default_style_config})
80
81 def filter_commits(self, commits: list[git.GitCommit]) -> list[git.GitCommit]:
82 """Select commits shared by bump and changelog operations.
83
84 Custom rules can override this method when both operations should use the
85 same subset of commits.
86
87 Args:
88 commits: The commits available to the current operation.
89
90 Returns:
91 The commits that the rule considers relevant.
92 """
93 return commits
94
95 def filter_commits_before_bump(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected