git_changelog ¤
git-changelog package.
Automatic Changelog generator using Jinja2 templates.
Modules:
-
build
–Deprecated. Import from
git_changelog
directly. -
cli
–Deprecated. Import from
git_changelog
directly. -
commit
–Deprecated. Import from
git_changelog
directly. -
providers
–Deprecated. Import from
git_changelog
directly. -
templates
–Deprecated. Import from
git_changelog
directly. -
versioning
–Deprecated. Import from
git_changelog
directly.
Classes:
-
AngularConvention
–Angular commit message convention.
-
BasicConvention
–Basic commit message convention.
-
Bitbucket
–A parser for the Bitbucket references.
-
Changelog
–The main changelog class.
-
Commit
–A class to represent a commit.
-
CommitConvention
–A base class for a convention of commit messages.
-
ConventionalCommitConvention
–Conventional commit message convention.
-
GitHub
–A parser for the GitHub references.
-
GitLab
–A parser for the GitLab references.
-
PEP440Bumper
–PEP 440 version bumper.
-
PEP440Version
–PEP 440 version.
-
ParsedVersion
–Base class for versioning schemes.
-
ProviderRefParser
–A base class for specific providers reference parsers.
-
Ref
–A class to represent a reference and its URL.
-
RefDef
–A class to store a reference regular expression and URL building string.
-
RefRe
–An enum helper to store parts of regular expressions for references.
-
Section
–A list of commits grouped by section_type.
-
SemVerBumper
–SemVer version bumper.
-
SemVerVersion
–SemVer version.
-
Templates
–Helper to pick a template on the command line.
-
Version
–A class to represent a changelog version.
-
VersionBumper
–Base class for version bumpers.
Functions:
-
build_and_render
–Build a changelog and render it.
-
bump
–Bump a version. Deprecated, use
bump_semver
instead. -
configure_env
–Configure the Jinja environment.
-
get_custom_template
–Get a custom template instance.
-
get_parser
–Return the CLI argument parser.
-
get_release_notes
–Get release notes from existing changelog.
-
get_template
–Get a builtin template instance.
-
get_version
–Return the current
git-changelog
version. -
main
–Run the main program.
-
output_release_notes
–Print release notes from existing changelog.
-
parse_pep440
–Parse a PEP version.
-
parse_semver
–Parse a SemVer version.
-
parse_settings
–Parse arguments and config files to build the final settings set.
-
parse_version
–Parse a version. Deprecated, use
bump_semver
instead. -
read_config
–Find config files and initialize settings with the one of highest priority.
-
render
–Render a changelog.
-
version_prefix
–Return a version and its optional
v
prefix.
Attributes:
-
CONVENTIONS
–Available commit message conventions.
-
ConventionType
–The type of convention used for commits.
-
DEFAULT_CHANGELOG_FILE
–Default changelog file name.
-
DEFAULT_CONFIG_FILES
–Default configuration files read by git-changelog.
-
DEFAULT_MARKER_LINE
–Default marker line for finding insertion points.
-
DEFAULT_SETTINGS
(dict[str, Any]
) –Default settings for the CLI.
-
DEFAULT_VERSIONING
–Default versioning strategy.
-
DEFAULT_VERSION_REGEX
–Default version regex for finding versions.
-
JINJA_ENV
–The Jinja environment.
-
PEP440Strategy
–PEP 440 versioning strategies.
-
SemVerStrategy
–SemVer versioning strategies.
-
TEMPLATES_PATH
–The path to the templates directory.
-
bump_pep440
–Bump a PEP 440 version.
-
bump_semver
–Bump a SemVer version.
CONVENTIONS module-attribute
¤
CONVENTIONS = ('angular', 'conventional', 'basic')
Available commit message conventions.
ConventionType module-attribute
¤
ConventionType = Union[
str, CommitConvention, type[CommitConvention]
]
The type of convention used for commits.
DEFAULT_CHANGELOG_FILE module-attribute
¤
DEFAULT_CHANGELOG_FILE = 'CHANGELOG.md'
Default changelog file name.
DEFAULT_CONFIG_FILES module-attribute
¤
DEFAULT_CONFIG_FILES = [
"pyproject.toml",
".git-changelog.toml",
"config/git-changelog.toml",
".config/git-changelog.toml",
str(Path(user_config_dir()) / "git-changelog.toml"),
]
Default configuration files read by git-changelog.
DEFAULT_MARKER_LINE module-attribute
¤
DEFAULT_MARKER_LINE = '<!-- insertion marker -->'
Default marker line for finding insertion points.
DEFAULT_SETTINGS module-attribute
¤
DEFAULT_SETTINGS: dict[str, Any] = {
"bump": None,
"bump_latest": None,
"convention": "basic",
"filter_commits": None,
"in_place": False,
"input": DEFAULT_CHANGELOG_FILE,
"marker_line": DEFAULT_MARKER_LINE,
"omit_empty_versions": False,
"output": stdout,
"parse_refs": False,
"parse_trailers": False,
"provider": None,
"release_notes": False,
"bumped_version": False,
"repository": ".",
"sections": None,
"template": "keepachangelog",
"jinja_context": {},
"version_regex": DEFAULT_VERSION_REGEX,
"versioning": DEFAULT_VERSIONING,
"zerover": True,
}
Default settings for the CLI.
DEFAULT_VERSIONING module-attribute
¤
DEFAULT_VERSIONING = 'semver'
Default versioning strategy.
DEFAULT_VERSION_REGEX module-attribute
¤
DEFAULT_VERSION_REGEX = '^## \\[(?P<version>v?[^\\]]+)'
Default version regex for finding versions.
PEP440Strategy module-attribute
¤
PEP440Strategy = Literal[
"epoch",
"release",
"major",
"minor",
"micro",
"patch",
"pre",
"alpha",
"beta",
"candidate",
"post",
"dev",
"major+alpha",
"major+beta",
"major+candidate",
"major+dev",
"major+alpha+dev",
"major+beta+dev",
"major+candidate+dev",
"minor+alpha",
"minor+beta",
"minor+candidate",
"minor+dev",
"minor+alpha+dev",
"minor+beta+dev",
"minor+candidate+dev",
"micro+alpha",
"micro+beta",
"micro+candidate",
"micro+dev",
"micro+alpha+dev",
"micro+beta+dev",
"micro+candidate+dev",
"alpha+dev",
"beta+dev",
"candidate+dev",
]
PEP 440 versioning strategies.
SemVerStrategy module-attribute
¤
SemVerStrategy = Literal[
"major", "minor", "patch", "release"
]
SemVer versioning strategies.
bump_semver module-attribute
¤
bump_semver = SemVerBumper(__args__)
Bump a SemVer version.
AngularConvention ¤
Bases: CommitConvention
Angular commit message convention.
Methods:
-
is_major
–Tell if this commit is worth a major bump.
-
is_minor
–Tell if this commit is worth a minor bump.
-
parse_commit
–Parse the commit to extract information.
-
parse_subject
–Parse the subject of the commit (
<type>[(scope)]: Subject
).
Attributes:
-
BREAK_REGEX
(Pattern
) –The commit message breaking change regex.
-
DEFAULT_RENDER
(list[str]
) –The default sections to render.
-
SUBJECT_REGEX
(Pattern
) –The commit message subject regex.
-
TYPES
(dict[str, str]
) –The commit message types.
-
TYPE_REGEX
(Pattern
) –The commit message type regex.
BREAK_REGEX class-attribute
¤
The commit message breaking change regex.
DEFAULT_RENDER class-attribute
¤
DEFAULT_RENDER: list[str] = [
TYPES["feat"],
TYPES["fix"],
TYPES["revert"],
TYPES["refactor"],
TYPES["perf"],
]
The default sections to render.
SUBJECT_REGEX class-attribute
¤
SUBJECT_REGEX: Pattern = compile(
f"^(?P<type>({join(keys())}))(?:\((?P<scope>.+)\))?: (?P<subject>.+)$"
)
The commit message subject regex.
TYPES class-attribute
¤
TYPES: dict[str, str] = {
"build": "Build",
"chore": "Chore",
"ci": "Continuous Integration",
"deps": "Dependencies",
"doc": "Docs",
"docs": "Docs",
"feat": "Features",
"fix": "Bug Fixes",
"perf": "Performance Improvements",
"ref": "Code Refactoring",
"refactor": "Code Refactoring",
"revert": "Reverts",
"style": "Style",
"test": "Tests",
"tests": "Tests",
}
The commit message types.
is_major ¤
Tell if this commit is worth a major bump.
Parameters:
-
commit_message
(str
) –The commit message.
Returns:
-
bool
–Whether it's a major commit.
Source code in src/git_changelog/_internal/commit.py
520 521 522 523 524 525 526 527 528 529 |
|
is_minor ¤
Tell if this commit is worth a minor bump.
Parameters:
-
commit_type
(str
) –The commit type.
Returns:
-
bool
–Whether it's a minor commit.
Source code in src/git_changelog/_internal/commit.py
509 510 511 512 513 514 515 516 517 518 |
|
parse_commit ¤
Parse the commit to extract information.
Parameters:
-
commit
(Commit
) –The commit to parse.
Returns:
Source code in src/git_changelog/_internal/commit.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
|
parse_subject ¤
Parse the subject of the commit (<type>[(scope)]: Subject
).
Parameters:
-
commit_subject
(str
) –The commit message subject.
Returns:
Source code in src/git_changelog/_internal/commit.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
|
BasicConvention ¤
Bases: CommitConvention
Basic commit message convention.
Methods:
-
is_major
–Tell if this commit is worth a major bump.
-
is_minor
–Tell if this commit is worth a minor bump.
-
parse_commit
–Parse the commit to extract information.
-
parse_type
–Parse the type of the commit given its subject.
Attributes:
-
BREAK_REGEX
(Pattern
) –The commit message breaking change regex.
-
DEFAULT_RENDER
(list[str]
) –The default sections to render.
-
TYPES
(dict[str, str]
) –The commit message types.
-
TYPE_REGEX
(Pattern
) –The commit message type regex.
BREAK_REGEX class-attribute
¤
The commit message breaking change regex.
DEFAULT_RENDER class-attribute
¤
The default sections to render.
TYPES class-attribute
¤
TYPES: dict[str, str] = {
"add": "Added",
"fix": "Fixed",
"change": "Changed",
"remove": "Removed",
"merge": "Merged",
"doc": "Documented",
}
The commit message types.
TYPE_REGEX class-attribute
¤
The commit message type regex.
is_major ¤
Tell if this commit is worth a major bump.
Parameters:
-
commit_message
(str
) –The commit message.
Returns:
-
bool
–Whether it's a major commit.
Source code in src/git_changelog/_internal/commit.py
418 419 420 421 422 423 424 425 426 427 |
|
is_minor ¤
Tell if this commit is worth a minor bump.
Parameters:
-
commit_type
(str
) –The commit type.
Returns:
-
bool
–Whether it's a minor commit.
Source code in src/git_changelog/_internal/commit.py
407 408 409 410 411 412 413 414 415 416 |
|
parse_commit ¤
Parse the commit to extract information.
Parameters:
-
commit
(Commit
) –The commit to parse.
Returns:
Source code in src/git_changelog/_internal/commit.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
|
parse_type ¤
Parse the type of the commit given its subject.
Parameters:
-
commit_subject
(str
) –The commit message subject.
Returns:
-
str
–The commit type.
Source code in src/git_changelog/_internal/commit.py
393 394 395 396 397 398 399 400 401 402 403 404 405 |
|
Bitbucket ¤
Bases: ProviderRefParser
A parser for the Bitbucket references.
Parameters:
-
namespace
(str
) –The Bitbucket namespace.
-
project
(str
) –The Bitbucket project.
-
url
(str | None
, default:None
) –The Bitbucket URL.
Methods:
-
build_ref_url
–Build the URL for a reference type and a dictionary of matched groups.
-
get_compare_url
–Get the URL for a tag comparison.
-
get_refs
–Find all references in the given text.
-
get_tag_url
–Get the URL for a git tag.
-
parse_refs
–Parse references in the given text.
Attributes:
-
REF
(dict[str, RefDef]
) –The reference definitions for the provider.
-
commit_max_length
–The maximum length of a commit hash.
-
commit_min_length
–The minimum length of a commit hash.
-
namespace
(str
) –The namespace for the provider.
-
project
(str
) –The project for the provider.
-
project_url
(str
) –The project URL for the provider.
-
tag_url
(str
) –The tag URL for the provider.
-
url
(str
) –The base URL for the provider.
Source code in src/git_changelog/_internal/providers.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
REF class-attribute
¤
REF: dict[str, RefDef] = {
"issues": RefDef(
regex=compile(
BB + NP + "?issue\\s*" + format(symbol="#"), I
),
url_string="{base_url}/{namespace}/{project}/issues/{ref}",
),
"merge_requests": RefDef(
regex=compile(
BB
+ NP
+ "?pull request\\s*"
+ format(symbol="#"),
I,
),
url_string="{base_url}/{namespace}/{project}/pull-request/{ref}",
),
"commits": RefDef(
regex=compile(
BB
+ format(
np=NP,
commit=format(
min=commit_min_length,
max=commit_max_length,
),
ba=BA,
),
I,
),
url_string="{base_url}/{namespace}/{project}/commits/{ref}",
),
"commits_ranges": RefDef(
regex=compile(
BB
+ format(
np=NP,
commit_range=format(
min=commit_min_length,
max=commit_max_length,
),
),
I,
),
url_string="{base_url}/{namespace}/{project}/branches/compare/{ref}#diff",
),
"mentions": RefDef(
regex=compile(BB + MENTION, I),
url_string="{base_url}/{ref}",
),
}
The reference definitions for the provider.
commit_max_length class-attribute
instance-attribute
¤
commit_max_length = 40
The maximum length of a commit hash.
commit_min_length class-attribute
instance-attribute
¤
commit_min_length = 8
The minimum length of a commit hash.
project_url class-attribute
instance-attribute
¤
project_url: str = '{base_url}/{namespace}/{project}'
The project URL for the provider.
tag_url class-attribute
instance-attribute
¤
tag_url: str = (
"{base_url}/{namespace}/{project}/commits/tag/{ref}"
)
The tag URL for the provider.
url class-attribute
instance-attribute
¤
url: str = 'https://bitbucket.org'
The base URL for the provider.
build_ref_url ¤
Build the URL for a reference type and a dictionary of matched groups.
Parameters:
Returns:
-
str
–The built URL.
Source code in src/git_changelog/_internal/providers.py
382 383 384 385 386 387 388 |
|
get_compare_url ¤
Get the URL for a tag comparison.
Parameters:
Returns:
-
str
–The comparison URL.
Source code in src/git_changelog/_internal/providers.py
393 394 |
|
get_refs ¤
Find all references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/_internal/providers.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
get_tag_url ¤
Get the URL for a git tag.
Parameters:
-
tag
(str
) –The git tag.
Returns:
-
str
–The tag URL.
Source code in src/git_changelog/_internal/providers.py
390 391 |
|
parse_refs ¤
Parse references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/_internal/providers.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
Changelog ¤
Changelog(
repository: str | Path,
*,
provider: ProviderRefParser
| type[ProviderRefParser]
| None = None,
convention: ConventionType | None = None,
parse_provider_refs: bool = False,
parse_trailers: bool = False,
sections: list[str] | None = None,
bump_latest: bool = False,
bump: str | None = None,
zerover: bool = True,
filter_commits: str | None = None,
versioning: Literal["semver", "pep440"] = "semver",
)
The main changelog class.
Parameters:
-
repository
(str | Path
) –The repository (directory) for which to build the changelog.
-
provider
(ProviderRefParser | type[ProviderRefParser] | None
, default:None
) –The provider to use (github.com, gitlab.com, etc.).
-
convention
(ConventionType | None
, default:None
) –The commit convention to use (angular, etc.).
-
parse_provider_refs
(bool
, default:False
) –Whether to parse provider-specific references in the commit messages.
-
parse_trailers
(bool
, default:False
) –Whether to parse Git trailers in the commit messages.
-
sections
(list[str] | None
, default:None
) –The sections to render (features, bug fixes, etc.).
-
bump_latest
(bool
, default:False
) –Deprecated, use
bump="auto"
instead. Whether to try and bump latest version to guess new one. -
bump
(str | None
, default:None
) –Whether to try and bump to a given version.
-
zerover
(bool
, default:True
) –Keep major version at zero, even for breaking changes.
-
filter_commits
(str | None
, default:None
) –The Git revision-range used to filter commits in git-log (e.g:
v1.0.1..
).
Methods:
-
get_log
–Get the
git log
output. -
get_remote_url
–Get the git remote URL for the repository.
-
parse_commits
–Parse the output of 'git log' into a list of commits.
-
run_git
–Run a git command in the chosen repository.
Attributes:
-
CONVENTION
(dict[str, type[CommitConvention]]
) –Available commit message conventions.
-
FORMAT
(str
) –Format string for the changelog.
-
MARKER
(str
) –Marker for the changelog.
-
commits
(list[Commit]
) –The list of parsed commits.
-
convention
(CommitConvention
) –The commit convention to use.
-
filter_commits
(str | None
) –The Git revision-range used to filter commits in git-log (e.g:
v1.0.1..
). -
parse_provider_refs
(bool
) –Whether to parse provider-specific references in the commit messages.
-
parse_trailers
(bool
) –Whether to parse Git trailers in the commit messages.
-
provider
–The provider to use (github.com, gitlab.com, etc.).
-
raw_log
(str
) –The raw Git log output.
-
remote_url
(str
) –The remote URL of the repository.
-
repository
(str | Path
) –The repository (directory) for which to build the changelog.
-
sections
–The sections to include in the changelog.
-
tag_commits
(list[Commit]
) –The list of tagged commits.
-
version_bumper
–The version bumper function.
-
version_parser
–The version parser function.
-
versions_dict
–The dictionary of versions.
-
versions_list
–The list of versions.
-
zerover
(bool
) –Whether to keep major version at zero, even for breaking changes.
Source code in src/git_changelog/_internal/build.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
CONVENTION class-attribute
¤
CONVENTION: dict[str, type[CommitConvention]] = {
"basic": BasicConvention,
"angular": AngularConvention,
"conventional": ConventionalCommitConvention,
}
Available commit message conventions.
FORMAT class-attribute
¤
Format string for the changelog.
MARKER class-attribute
¤
MARKER: str = '--GIT-CHANGELOG MARKER--'
Marker for the changelog.
convention instance-attribute
¤
convention: CommitConvention = convention
The commit convention to use.
filter_commits instance-attribute
¤
filter_commits: str | None = filter_commits
The Git revision-range used to filter commits in git-log (e.g: v1.0.1..
).
parse_provider_refs instance-attribute
¤
parse_provider_refs: bool = parse_provider_refs
Whether to parse provider-specific references in the commit messages.
parse_trailers instance-attribute
¤
parse_trailers: bool = parse_trailers
Whether to parse Git trailers in the commit messages.
provider instance-attribute
¤
provider = provider
The provider to use (github.com, gitlab.com, etc.).
repository instance-attribute
¤
The repository (directory) for which to build the changelog.
tag_commits instance-attribute
¤
The list of tagged commits.
zerover instance-attribute
¤
zerover: bool = zerover
Whether to keep major version at zero, even for breaking changes.
get_log ¤
get_log() -> str
Get the git log
output.
Returns:
-
str
–The output of the
git log
command, with a particular format.
Source code in src/git_changelog/_internal/build.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
get_remote_url ¤
get_remote_url() -> str
Get the git remote URL for the repository.
Returns:
-
str
–The origin remote URL.
Source code in src/git_changelog/_internal/build.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
parse_commits ¤
Parse the output of 'git log' into a list of commits.
The commits build a Git commit graph by referencing their parent commits. Commits are ordered from newest to oldest.
Returns:
Source code in src/git_changelog/_internal/build.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
|
run_git ¤
Run a git command in the chosen repository.
Parameters:
-
*args
(str
, default:()
) –Arguments passed to the git command.
Returns:
-
str
–The git command output.
Source code in src/git_changelog/_internal/build.py
334 335 336 337 338 339 340 341 342 343 |
|
Commit ¤
Commit(
commit_hash: str,
author_name: str = "",
author_email: str = "",
author_date: str | datetime = "",
committer_name: str = "",
committer_email: str = "",
committer_date: str | datetime = "",
refs: str = "",
subject: str = "",
body: list[str] | None = None,
url: str = "",
*,
parse_trailers: bool = False,
parent_hashes: str | list[str] = "",
commits_map: dict[str, Commit] | None = None,
version_parser: Callable[
[str], tuple[ParsedVersion, str]
]
| None = None,
)
A class to represent a commit.
Parameters:
-
commit_hash
(str
) –The commit hash.
-
author_name
(str
, default:''
) –The author name.
-
author_email
(str
, default:''
) –The author email.
-
author_date
(str | datetime
, default:''
) –The authoring date (datetime or UTC timestamp).
-
committer_name
(str
, default:''
) –The committer name.
-
committer_email
(str
, default:''
) –The committer email.
-
committer_date
(str | datetime
, default:''
) –The committing date (datetime or UTC timestamp).
-
refs
(str
, default:''
) –The commit refs.
-
subject
(str
, default:''
) –The commit message subject.
-
body
(list[str] | None
, default:None
) –The commit message body.
-
url
(str
, default:''
) –The commit URL.
-
parse_trailers
(bool
, default:False
) –Whether to parse Git trailers.
Methods:
-
update_with_convention
–Apply the convention-parsed data to this commit.
-
update_with_provider
–Apply the provider-parsed data to this commit.
Attributes:
-
author_date
(datetime
) –The author date.
-
author_email
(str
) –The author email.
-
author_name
(str
) –The author name.
-
body
(list[str]
) –The commit body.
-
body_without_trailers
–The commit body without trailers.
-
committer_date
(datetime
) –The committer date.
-
committer_email
(str
) –The committer email.
-
committer_name
(str
) –The committer name.
-
convention
(dict[str, Any]
) –The commit message convention.
-
hash
(str
) –The commit hash.
-
parent_commits
(list[Commit]
) –Parent commits of this commit.
-
parent_hashes
–The parent commit hashes.
-
subject
(str
) –The commit subject.
-
tag
(str
) –The commit tag.
-
text_refs
(dict[str, list[Ref]]
) –The commit text references.
-
trailers
(list[tuple[str, str]]
) –The commit trailers.
-
url
(str
) –The commit URL.
-
version
(str
) –The commit version.
Source code in src/git_changelog/_internal/commit.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
body_without_trailers instance-attribute
¤
body_without_trailers = body
The commit body without trailers.
update_with_convention ¤
update_with_convention(
convention: CommitConvention,
) -> None
Apply the convention-parsed data to this commit.
Parameters:
-
convention
(CommitConvention
) –The convention to use.
Source code in src/git_changelog/_internal/commit.py
232 233 234 235 236 237 238 |
|
update_with_provider ¤
update_with_provider(
provider: ProviderRefParser, parse_refs: bool = True
) -> None
Apply the provider-parsed data to this commit.
Parameters:
-
provider
(ProviderRefParser
) –The provider to use.
-
parse_refs
(bool
, default:True
) –Whether to parse references for this provider.
Source code in src/git_changelog/_internal/commit.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
CommitConvention ¤
Bases: ABC
A base class for a convention of commit messages.
Methods:
-
parse_commit
–Parse the commit to extract information.
Attributes:
-
BREAK_REGEX
(Pattern
) –The commit message breaking change regex.
-
DEFAULT_RENDER
(list[str]
) –The sections rendered by default.
-
TYPES
(dict[str, str]
) –The commit message types.
-
TYPE_REGEX
(Pattern
) –The commit message type regex.
parse_commit abstractmethod
¤
Parse the commit to extract information.
Parameters:
-
commit
(Commit
) –The commit to parse.
Returns:
Source code in src/git_changelog/_internal/commit.py
304 305 306 307 308 309 310 311 312 313 314 |
|
ConventionalCommitConvention ¤
Bases: AngularConvention
Conventional commit message convention.
Methods:
-
is_major
–Tell if this commit is worth a major bump.
-
is_minor
–Tell if this commit is worth a minor bump.
-
parse_commit
–Parse the commit to extract information.
-
parse_subject
–Parse the subject of the commit (
<type>[(scope)]: Subject
).
Attributes:
-
BREAK_REGEX
(Pattern
) –The commit message breaking change regex.
-
DEFAULT_RENDER
(list[str]
) –The default sections to render.
-
SUBJECT_REGEX
(Pattern
) –The commit message subject regex.
-
TYPES
(dict[str, str]
) –The commit message types.
-
TYPE_REGEX
(Pattern
) –The commit message type regex.
BREAK_REGEX class-attribute
¤
The commit message breaking change regex.
DEFAULT_RENDER class-attribute
¤
DEFAULT_RENDER: list[str] = DEFAULT_RENDER
The default sections to render.
SUBJECT_REGEX class-attribute
¤
SUBJECT_REGEX: Pattern = compile(
f"^(?P<type>({join(keys())}))(?:\((?P<scope>.+)\))?(?P<breaking>!)?: (?P<subject>.+)$"
)
The commit message subject regex.
is_major ¤
Tell if this commit is worth a major bump.
Parameters:
-
commit_message
(str
) –The commit message.
Returns:
-
bool
–Whether it's a major commit.
Source code in src/git_changelog/_internal/commit.py
520 521 522 523 524 525 526 527 528 529 |
|
is_minor ¤
Tell if this commit is worth a minor bump.
Parameters:
-
commit_type
(str
) –The commit type.
Returns:
-
bool
–Whether it's a minor commit.
Source code in src/git_changelog/_internal/commit.py
509 510 511 512 513 514 515 516 517 518 |
|
parse_commit ¤
Parse the commit to extract information.
Parameters:
-
commit
(Commit
) –The commit to parse.
Returns:
Source code in src/git_changelog/_internal/commit.py
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
|
parse_subject ¤
Parse the subject of the commit (<type>[(scope)]: Subject
).
Parameters:
-
commit_subject
(str
) –The commit message subject.
Returns:
Source code in src/git_changelog/_internal/commit.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
|
GitHub ¤
Bases: ProviderRefParser
A parser for the GitHub references.
Parameters:
-
namespace
(str
) –The Bitbucket namespace.
-
project
(str
) –The Bitbucket project.
-
url
(str | None
, default:None
) –The Bitbucket URL.
Methods:
-
build_ref_url
–Build the URL for a reference type and a dictionary of matched groups.
-
get_compare_url
–Get the URL for a tag comparison.
-
get_refs
–Find all references in the given text.
-
get_tag_url
–Get the URL for a git tag.
-
parse_refs
–Parse references in the given text.
Attributes:
-
REF
(dict[str, RefDef]
) –The reference definitions for the provider.
-
commit_max_length
–The maximum length of a commit hash.
-
commit_min_length
–The minimum length of a commit hash.
-
namespace
(str
) –The namespace for the provider.
-
project
(str
) –The project for the provider.
-
project_url
(str
) –The project URL for the provider.
-
tag_url
(str
) –The tag URL for the provider.
-
url
(str
) –The base URL for the provider.
Source code in src/git_changelog/_internal/providers.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
REF class-attribute
¤
REF: dict[str, RefDef] = {
"issues": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="#"), I
),
url_string="{base_url}/{namespace}/{project}/issues/{ref}",
),
"commits": RefDef(
regex=compile(
BB
+ format(
np=NP,
commit=format(
min=commit_min_length,
max=commit_max_length,
),
ba=BA,
),
I,
),
url_string="{base_url}/{namespace}/{project}/commit/{ref}",
),
"commits_ranges": RefDef(
regex=compile(
BB
+ format(
np=NP,
commit_range=format(
min=commit_min_length,
max=commit_max_length,
),
),
I,
),
url_string="{base_url}/{namespace}/{project}/compare/{ref}",
),
"mentions": RefDef(
regex=compile(BB + MENTION, I),
url_string="{base_url}/{ref}",
),
}
The reference definitions for the provider.
commit_max_length class-attribute
instance-attribute
¤
commit_max_length = 40
The maximum length of a commit hash.
commit_min_length class-attribute
instance-attribute
¤
commit_min_length = 8
The minimum length of a commit hash.
project_url class-attribute
instance-attribute
¤
project_url: str = '{base_url}/{namespace}/{project}'
The project URL for the provider.
tag_url class-attribute
instance-attribute
¤
tag_url: str = (
"{base_url}/{namespace}/{project}/releases/tag/{ref}"
)
The tag URL for the provider.
url class-attribute
instance-attribute
¤
url: str = 'https://github.com'
The base URL for the provider.
build_ref_url ¤
Build the URL for a reference type and a dictionary of matched groups.
Parameters:
Returns:
-
str
–The built URL.
Source code in src/git_changelog/_internal/providers.py
211 212 213 214 215 216 217 |
|
get_compare_url ¤
Get the URL for a tag comparison.
Parameters:
Returns:
-
str
–The comparison URL.
Source code in src/git_changelog/_internal/providers.py
222 223 |
|
get_refs ¤
Find all references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/_internal/providers.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
get_tag_url ¤
Get the URL for a git tag.
Parameters:
-
tag
(str
) –The git tag.
Returns:
-
str
–The tag URL.
Source code in src/git_changelog/_internal/providers.py
219 220 |
|
parse_refs ¤
Parse references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/_internal/providers.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
GitLab ¤
Bases: ProviderRefParser
A parser for the GitLab references.
Parameters:
-
namespace
(str
) –The Bitbucket namespace.
-
project
(str
) –The Bitbucket project.
-
url
(str | None
, default:None
) –The Bitbucket URL.
Methods:
-
build_ref_url
–Build the URL for a reference type and a dictionary of matched groups.
-
get_compare_url
–Get the URL for a tag comparison.
-
get_refs
–Find all references in the given text.
-
get_tag_url
–Get the URL for a git tag.
-
parse_refs
–Parse references in the given text.
Attributes:
-
REF
(dict[str, RefDef]
) –The reference definitions for the provider.
-
commit_max_length
–The maximum length of a commit hash.
-
commit_min_length
–The minimum length of a commit hash.
-
namespace
(str
) –The namespace for the provider.
-
project
(str
) –The project for the provider.
-
project_url
(str
) –The project URL for the provider.
-
tag_url
(str
) –The tag URL for the provider.
-
url
(str
) –The base URL for the provider.
Source code in src/git_changelog/_internal/providers.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
REF class-attribute
¤
REF: dict[str, RefDef] = {
"issues": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="#"), I
),
url_string="{base_url}/{namespace}/{project}/issues/{ref}",
),
"merge_requests": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="!"), I
),
url_string="{base_url}/{namespace}/{project}/merge_requests/{ref}",
),
"snippets": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="\\$"), I
),
url_string="{base_url}/{namespace}/{project}/snippets/{ref}",
),
"labels_ids": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="~"), I
),
url_string="{base_url}/{namespace}/{project}/issues?label_name[]={ref}",
),
"labels_one_word": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="~"), I
),
url_string="{base_url}/{namespace}/{project}/issues?label_name[]={ref}",
),
"labels_multi_word": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="~"), I
),
url_string="{base_url}/{namespace}/{project}/issues?label_name[]={ref}",
),
"milestones_ids": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="%"), I
),
url_string="{base_url}/{namespace}/{project}/milestones/{ref}",
),
"milestones_one_word": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="%"), I
),
url_string="{base_url}/{namespace}/{project}/milestones",
),
"milestones_multi_word": RefDef(
regex=compile(
BB + NP + "?" + format(symbol="%"), I
),
url_string="{base_url}/{namespace}/{project}/milestones",
),
"commits": RefDef(
regex=compile(
BB
+ format(
np=NP,
commit=format(
min=commit_min_length,
max=commit_max_length,
),
ba=BA,
),
I,
),
url_string="{base_url}/{namespace}/{project}/commit/{ref}",
),
"commits_ranges": RefDef(
regex=compile(
BB
+ format(
np=NP,
commit_range=format(
min=commit_min_length,
max=commit_max_length,
),
),
I,
),
url_string="{base_url}/{namespace}/{project}/compare/{ref}",
),
"mentions": RefDef(
regex=compile(BB + MENTION, I),
url_string="{base_url}/{ref}",
),
}
The reference definitions for the provider.
commit_max_length class-attribute
instance-attribute
¤
commit_max_length = 40
The maximum length of a commit hash.
commit_min_length class-attribute
instance-attribute
¤
commit_min_length = 8
The minimum length of a commit hash.
project_url class-attribute
instance-attribute
¤
project_url: str = '{base_url}/{namespace}/{project}'
The project URL for the provider.
tag_url class-attribute
instance-attribute
¤
tag_url: str = "{base_url}/{namespace}/{project}/tags/{ref}"
The tag URL for the provider.
url class-attribute
instance-attribute
¤
url: str = 'https://gitlab.com'
The base URL for the provider.
build_ref_url ¤
Build the URL for a reference type and a dictionary of matched groups.
Parameters:
Returns:
-
str
–The built URL.
Source code in src/git_changelog/_internal/providers.py
311 312 313 314 315 316 317 318 319 |
|
get_compare_url ¤
Get the URL for a tag comparison.
Parameters:
Returns:
-
str
–The comparison URL.
Source code in src/git_changelog/_internal/providers.py
324 325 |
|
get_refs ¤
Find all references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/_internal/providers.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
get_tag_url ¤
Get the URL for a git tag.
Parameters:
-
tag
(str
) –The git tag.
Returns:
-
str
–The tag URL.
Source code in src/git_changelog/_internal/providers.py
321 322 |
|
parse_refs ¤
Parse references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/_internal/providers.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
PEP440Bumper ¤
Bases: VersionBumper
PEP 440 version bumper.
Parameters:
Methods:
-
__call__
–Bump a PEP 440 version.
Attributes:
-
initial
(str
) –The initial version.
-
strategies
–The supported bumping strategies.
Source code in src/git_changelog/_internal/versioning.py
673 674 675 676 677 678 679 680 |
|
__call__ ¤
__call__(
version: str,
strategy: PEP440Strategy = "micro",
*,
zerover: bool = False,
trim: bool = False,
) -> str
Bump a PEP 440 version.
Parameters:
-
version
(str
) –The version to bump.
-
strategy
(PEP440Strategy
, default:'micro'
) –The part of the version to bump.
-
zerover
(bool
, default:False
) –Keep major version at zero, even for breaking changes.
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Returns:
-
str
–The bumped version.
Source code in src/git_changelog/_internal/versioning.py
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 |
|
PEP440Version ¤
Bases: Version
, ParsedVersion
PEP 440 version.
Methods:
-
__eq__
–Implement
==
comparison. -
__ge__
–Implement
>=
comparison. -
__gt__
–Implement
>
comparison. -
__le__
–Implement
<=
comparison. -
__lt__
–Implement
<
comparison. -
__ne__
–Implement
!=
comparison. -
bump_alpha
–Bump alpha-release.
-
bump_beta
–Bump beta-release.
-
bump_candidate
–Bump candidate release.
-
bump_dev
–Bump dev-release.
-
bump_epoch
–Bump epoch.
-
bump_major
–Bump major.
-
bump_micro
–Bump micro.
-
bump_minor
–Bump minor.
-
bump_post
–Bump post-release.
-
bump_pre
–Bump pre-release.
-
bump_release
–Bump given release level.
-
dent_alpha
–Dent to alpha-release.
-
dent_beta
–Dent to beta-release.
-
dent_candidate
–Dent to candidate release.
-
dent_dev
–Dent to dev-release.
-
dent_pre
–Dent to pre-release.
-
from_parts
–Build a version from its parts.
__eq__ ¤
Implement ==
comparison.
Source code in src/git_changelog/_internal/versioning.py
72 73 74 |
|
__ge__ ¤
Implement >=
comparison.
Source code in src/git_changelog/_internal/versioning.py
76 77 78 |
|
__gt__ ¤
Implement >
comparison.
Source code in src/git_changelog/_internal/versioning.py
80 81 82 |
|
__le__ ¤
Implement <=
comparison.
Source code in src/git_changelog/_internal/versioning.py
68 69 70 |
|
__lt__ ¤
Implement <
comparison.
Source code in src/git_changelog/_internal/versioning.py
64 65 66 |
|
__ne__ ¤
Implement !=
comparison.
Source code in src/git_changelog/_internal/versioning.py
84 85 86 |
|
bump_alpha ¤
bump_alpha() -> PEP440Version
Bump alpha-release.
Examples:
>>> PEP440Version("1").bump_alpha()
ValueError: Cannot bump from release to alpha pre-release (use `dent_alpha`)
>>> PEP440Version("1a0").bump_alpha()
<Version('1a1')>
>>> PEP440Version("1a0").bump_alpha("a")
<Version('1a1')>
>>> PEP440Version("1a0.post0").bump_alpha()
<Version('1a1')>
Returns:
-
PEP440Version
–Version with same epoch, same release, bumped alpha pre-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
bump_beta ¤
bump_beta() -> PEP440Version
Bump beta-release.
Examples:
>>> PEP440Version("1").bump_beta()
ValueError: Cannot bump from release to beta pre-release (use `dent_beta`)
>>> PEP440Version("1b0").bump_beta()
<Version('1b1')>
>>> PEP440Version("1b0").bump_beta()
<Version('1b1')>
>>> PEP440Version("1b0.post0").bump_beta()
<Version('1b1')>
Returns:
-
PEP440Version
–Version with same epoch, same release, bumped beta pre-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
|
bump_candidate ¤
bump_candidate() -> PEP440Version
Bump candidate release.
Examples:
>>> PEP440Version("1").bump_candidate()
ValueError: Cannot bump from release to candidate pre-release (use `dent_candidate`)
>>> PEP440Version("1c0").bump_candidate()
<Version('1rc1')>
>>> PEP440Version("1c0").bump_candidate()
<Version('1rc1')>
>>> PEP440Version("1c0.post0").bump_candidate()
<Version('1rc1')>
Returns:
-
PEP440Version
–Version with same epoch, same release, bumped candidate pre-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
|
bump_dev ¤
bump_dev() -> PEP440Version
Bump dev-release.
Examples:
>>> PEP440Version("1").bump_dev()
ValueError: Cannot bump from release to dev-release (use `dent_dev`)
>>> PEP440Version("1a0").bump_dev()
ValueError: Cannot bump from alpha to dev-release (use `dent_dev`)
>>> PEP440Version("1b1").bump_dev()
ValueError: Cannot bump from beta to dev-release (use `dent_dev`)
>>> PEP440Version("1rc2").bump_dev()
ValueError: Cannot bump from candidate to dev-release (use `dent_dev`)
>>> PEP440Version("1.post0").bump_dev()
ValueError: Cannot bump from post to dev-release (use `dent_dev`)
>>> PEP440Version("1a0.dev1").bump_dev()
<Version('1a0.dev2')>
Returns:
-
PEP440Version
–Version with same epoch, same release, same pre-release, same post-release and bumped dev-release.
Source code in src/git_changelog/_internal/versioning.py
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
bump_epoch ¤
bump_epoch() -> PEP440Version
Bump epoch.
Examples:
>>> PEP440Version("1.0").bump_epoch()
<Version('1!1.0')>
>>> PEP440Version("0!1.0").bump_epoch()
<Version('1!1.0')>
>>> PEP440Version("1!1.0").bump_epoch()
<Version('2!1.0')>
>>> PEP440Version("1.0a2.post3").bump_epoch()
<Version('2!1.0')>
Returns:
-
PEP440Version
–Version with bumped epoch, same release, and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
bump_major ¤
bump_major(*, trim: bool = False) -> PEP440Version
Bump major.
Parameters:
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Examples:
>>> PEP440Version("1").bump_major()
<Version('2')>
>>> PEP440Version("1.1").bump_major()
<Version('2.0')>
>>> PEP440Version("1.1.1").bump_major()
<Version('2.0.0')>
>>> PEP440Version("1.1.1").bump_major(trim=True)
<Version('2')>
>>> PEP440Version("1a2.post3").bump_major()
<Version('2')>
Returns:
-
PEP440Version
–Version with same epoch, bumped major and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
|
bump_micro ¤
bump_micro(*, trim: bool = False) -> PEP440Version
Bump micro.
Parameters:
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Examples:
>>> PEP440Version("1").bump_micro()
<Version('1.0.1')>
>>> PEP440Version("1.1").bump_micro()
<Version('1.1.1')>
>>> PEP440Version("1.1.1").bump_micro()
<Version('1.1.2')>
>>> PEP440Version("1.1.1").bump_micro()
<Version('1.1.2')>
>>> PEP440Version("1.1.1.1").bump_micro()
<Version('1.1.2.0')>
>>> PEP440Version("1.1.1.1").bump_micro(trim=True)
<Version('1.1.2')>
>>> PEP440Version("1a2.post3").bump_micro()
<Version('1.0.1')>
Returns:
-
PEP440Version
–Version with same epoch, same major, same minor, bumped micro and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
bump_minor ¤
bump_minor(*, trim: bool = False) -> PEP440Version
Bump minor.
Parameters:
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Examples:
>>> PEP440Version("1").bump_minor()
<Version('1.1')>
>>> PEP440Version("1.1").bump_minor()
<Version('1.2')>
>>> PEP440Version("1.1.1").bump_minor()
<Version('1.2.0')>
>>> PEP440Version("1.1.1").bump_minor(trim=True)
<Version('1.2')>
>>> PEP440Version("1a2.post3").bump_minor()
<Version('1.1')>
Returns:
-
PEP440Version
–Version with same epoch, same major, bumped minor and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
bump_post ¤
bump_post() -> PEP440Version
Bump post-release.
Examples:
>>> PEP440Version("1").bump_post()
<Version('1.post0')>
>>> PEP440Version("1.post0").bump_post()
<Version('1.post1')>
>>> PEP440Version("1a0.post0").bump_post()
<Version('1a0.post1')>
>>> PEP440Version("1.post0.dev1").bump_post()
<Version('1.post1')>
Returns:
-
PEP440Version
–Version with same epoch, same release, same pre-release, bumped post-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
|
bump_pre ¤
bump_pre(
pre: Literal["a", "b", "c", "rc"] | None = None,
) -> PEP440Version
Bump pre-release.
Parameters:
-
pre
(Literal['a', 'b', 'c', 'rc'] | None
, default:None
) –Kind of pre-release to bump.
- a means alpha
- b means beta
- c or rc means (release) candidate
Examples:
>>> PEP440Version("1").bump_pre()
ValueError: Cannot bump from release to alpha pre-release (use `dent_pre`)
>>> PEP440Version("1a0").bump_pre()
<Version('1a1')>
>>> PEP440Version("1a0").bump_pre("a")
<Version('1a1')>
>>> PEP440Version("1a0.post0").bump_pre()
<Version('1a1')>
>>> PEP440Version("1b2").bump_pre("a")
ValueError: Cannot bump from beta to alpha pre-release (use `dent_alpha`)
>>> PEP440Version("1c2").bump_pre("a")
ValueError: Cannot bump from candidate to alpha pre-release (use `dent_alpha`)
>>> PEP440Version("1").bump_pre("b")
ValueError: Cannot bump from release to beta pre-release (use `dent_beta`)
>>> PEP440Version("1a2").bump_pre("b")
<Version('1b0')>
>>> PEP440Version("1b2").bump_pre("b")
<Version('1b3')>
>>> PEP440Version("1c2").bump_pre("b")
ValueError: Cannot bump from candidate to beta pre-release (use `dent_beta`)
>>> PEP440Version("1").bump_pre("c")
ValueError: Cannot bump from release to candidate pre-release (use `dent_candidate`)
>>> PEP440Version("1a2").bump_pre("c")
<Version('1rc0')>
>>> PEP440Version("1b2").bump_pre("rc")
<Version('1rc0')>
>>> PEP440Version("1rc2").bump_pre("c")
<Version('1rc3')>
Returns:
-
PEP440Version
–Version with same epoch, same release, bumped pre-release and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
|
bump_release ¤
bump_release(
level: int | None = None, *, trim: bool = False
) -> PEP440Version
Bump given release level.
Parameters:
-
level
(int | None
, default:None
) –The release level to bump.
- 0 means major
- 1 means minor
- 2 means micro (patch)
- 3+ don't have names
- None means move from pre-release to release (unchanged)
-
trim
(bool
, default:False
) –Whether to trim all zeroes on the right after bumping.
Examples:
>>> PEP440Version("1").bump_release(0)
<Version('2')>
>>> PEP440Version("1.1").bump_release(0)
<Version('2.0')>
>>> PEP440Version("1.1.1").bump_release(0)
<Version('2.0.0')>
>>> PEP440Version("1.1.1").bump_release(0, trim=True)
<Version('2')>
>>> PEP440Version("1a2.post3").bump_release(0)
<Version('2')>
>>> PEP440Version("1").bump_release(1)
<Version('1.1')>
>>> PEP440Version("1.1").bump_release(1)
<Version('1.2')>
>>> PEP440Version("1.1.1").bump_release(1)
<Version('1.2.0')>
>>> PEP440Version("1.1.1").bump_release(1, trim=True)
<Version('1.2')>
>>> PEP440Version("1a2.post3").bump_release(1)
<Version('1.1')>
>>> PEP440Version("1a0").bump_release()
<Version('1')>
>>> PEP440Version("1b1").bump_release()
<Version('1')>
>>> PEP440Version("1rc2").bump_release()
<Version('1')>
>>> PEP440Version("1a2.dev0").bump_release()
<Version('1')>
>>> PEP440Version("1post0").bump_release()
ValueError: Cannot bump from post-release to release
Returns:
-
PEP440Version
–Version with same epoch, bumped release level, and the right parts reset to 0 or nothing.
Source code in src/git_changelog/_internal/versioning.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
dent_alpha ¤
dent_alpha() -> PEP440Version
Dent to alpha-release.
Examples:
>>> PEP440Version("1").dent_alpha()
<Version('1a0')>
>>> PEP440Version("1a0").dent_alpha()
ValueError: Cannot dent alpha pre-releases
>>> PEP440Version("1b0").dent_alpha()
ValueError: Cannot dent beta pre-releases
>>> PEP440Version("1rc0").dent_alpha()
ValueError: Cannot dent candidate pre-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to alpha pre-release.
Source code in src/git_changelog/_internal/versioning.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
|
dent_beta ¤
dent_beta() -> PEP440Version
Dent to beta-release.
Examples:
>>> PEP440Version("1").dent_beta()
<Version('1b0')>
>>> PEP440Version("1a0").dent_beta()
ValueError: Cannot dent alpha pre-releases
>>> PEP440Version("1b0").dent_beta()
ValueError: Cannot dent beta pre-releases
>>> PEP440Version("1rc0").dent_beta()
ValueError: Cannot dent candidate pre-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to beta pre-release.
Source code in src/git_changelog/_internal/versioning.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
|
dent_candidate ¤
dent_candidate() -> PEP440Version
Dent to candidate release.
Examples:
>>> PEP440Version("1").dent_candidate()
<Version('1rc0')>
>>> PEP440Version("1a0").dent_candidate()
ValueError: Cannot dent alpha pre-releases
>>> PEP440Version("1b0").dent_candidate()
ValueError: Cannot dent beta pre-releases
>>> PEP440Version("1rc0").dent_candidate()
ValueError: Cannot dent candidate pre-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to candidate pre-release.
Source code in src/git_changelog/_internal/versioning.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
|
dent_dev ¤
dent_dev() -> PEP440Version
Dent to dev-release.
Examples:
>>> PEP440Version("1").dent_dev()
<Version('1.dev0')>
>>> PEP440Version("1a0").dent_dev()
<Version('1a0.dev0')>
>>> PEP440Version("1b1").dent_dev()
<Version('1b1.dev0')>
>>> PEP440Version("1c2").dent_dev()
<Version('1rc2.dev0')>
>>> PEP440Version("1.post0").dent_dev()
<Version('1.post0.dev0')>
>>> PEP440Version("1a0.dev1").dent_dev()
ValueError: Cannot dent dev-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to dev-release.
Source code in src/git_changelog/_internal/versioning.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
|
dent_pre ¤
dent_pre(
pre: Literal["a", "b", "c", "rc"] | None = None,
) -> PEP440Version
Dent to pre-release.
This method dents a release down to an alpha, beta or candidate pre-release.
Parameters:
-
pre
(Literal['a', 'b', 'c', 'rc'] | None
, default:None
) –Kind of pre-release to bump.
- a means alpha
- b means beta
- c or rc means (release) candidate
Examples:
>>> PEP440Version("1").dent_pre()
<Version('1a0')>
>>> PEP440Version("1").dent_pre("a")
<Version('1a0')>
>>> PEP440Version("1a0").dent_pre("a")
ValueError: Cannot dent alpha pre-releases
>>> PEP440Version("1").dent_pre("b")
<Version('1b0')>
>>> PEP440Version("1b0").dent_pre("b")
ValueError: Cannot dent beta pre-releases
>>> PEP440Version("1").dent_pre("c")
<Version('1rc0')>
>>> PEP440Version("1").dent_pre("rc")
<Version('1rc0')>
>>> PEP440Version("1rc0").dent_pre("c")
ValueError: Cannot dent candidate pre-releases
Returns:
-
PEP440Version
–Version with same epoch and release dented to pre-release.
Source code in src/git_changelog/_internal/versioning.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
|
from_parts classmethod
¤
from_parts(
epoch: int | None = None,
release: tuple[int, ...] | None = None,
pre: tuple[str, int] | None = None,
post: int | None = None,
dev: int | None = None,
) -> PEP440Version
Build a version from its parts.
Parameters:
-
epoch
(int | None
, default:None
) –Version's epoch number.
-
release
(tuple[int, ...] | None
, default:None
) –Version's release numbers.
-
pre
(tuple[str, int] | None
, default:None
) –Version's prerelease kind and number.
-
post
(int | None
, default:None
) –Version's post number.
-
dev
(int | None
, default:None
) –Version's dev number.
Returns:
-
PEP440Version
–A PEP 440 version.
Source code in src/git_changelog/_internal/versioning.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
ParsedVersion ¤
Bases: Protocol
Base class for versioning schemes.
Methods:
-
__eq__
–Implement
==
comparison. -
__ge__
–Implement
>=
comparison. -
__gt__
–Implement
>
comparison. -
__le__
–Implement
<=
comparison. -
__lt__
–Implement
<
comparison. -
__ne__
–Implement
!=
comparison.
__eq__ ¤
Implement ==
comparison.
Source code in src/git_changelog/_internal/versioning.py
72 73 74 |
|
__ge__ ¤
Implement >=
comparison.
Source code in src/git_changelog/_internal/versioning.py
76 77 78 |
|
__gt__ ¤
Implement >
comparison.
Source code in src/git_changelog/_internal/versioning.py
80 81 82 |
|
__le__ ¤
Implement <=
comparison.
Source code in src/git_changelog/_internal/versioning.py
68 69 70 |
|
__lt__ ¤
Implement <
comparison.
Source code in src/git_changelog/_internal/versioning.py
64 65 66 |
|
ProviderRefParser ¤
Bases: ABC
A base class for specific providers reference parsers.
Parameters:
-
namespace
(str
) –The Bitbucket namespace.
-
project
(str
) –The Bitbucket project.
-
url
(str | None
, default:None
) –The Bitbucket URL.
Methods:
-
build_ref_url
–Build the URL for a reference type and a dictionary of matched groups.
-
get_compare_url
–Get the URL for a tag comparison.
-
get_refs
–Find all references in the given text.
-
get_tag_url
–Get the URL for a git tag.
-
parse_refs
–Parse references in the given text.
Attributes:
-
REF
(dict[str, RefDef]
) –The reference definitions for the provider.
-
namespace
(str
) –The namespace for the provider.
-
project
(str
) –The project for the provider.
-
url
(str
) –The URL for the provider.
Source code in src/git_changelog/_internal/providers.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
build_ref_url ¤
Build the URL for a reference type and a dictionary of matched groups.
Parameters:
Returns:
-
str
–The built URL.
Source code in src/git_changelog/_internal/providers.py
126 127 128 129 130 131 132 133 134 135 136 |
|
get_compare_url abstractmethod
¤
Get the URL for a tag comparison.
Parameters:
Returns:
-
str
–The comparison URL.
Source code in src/git_changelog/_internal/providers.py
150 151 152 153 154 155 156 157 158 159 160 161 |
|
get_refs ¤
Find all references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/_internal/providers.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
get_tag_url abstractmethod
¤
Get the URL for a git tag.
Parameters:
-
tag
(str
) –The git tag.
Returns:
-
str
–The tag URL.
Source code in src/git_changelog/_internal/providers.py
138 139 140 141 142 143 144 145 146 147 148 |
|
parse_refs ¤
Parse references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/_internal/providers.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
Ref ¤
A class to represent a reference and its URL.
Parameters:
Attributes:
Source code in src/git_changelog/_internal/providers.py
37 38 39 40 41 42 43 44 45 46 47 |
|
RefDef ¤
A class to store a reference regular expression and URL building string.
Parameters:
-
regex
(Pattern
) –The regular expression to match the reference.
-
url_string
(str
) –The URL string to format using matched groups.
Attributes:
-
regex
–The regular expression to match the reference.
-
url_string
–The URL string to format using matched groups.
Source code in src/git_changelog/_internal/providers.py
56 57 58 59 60 61 62 63 64 65 66 |
|
RefRe ¤
An enum helper to store parts of regular expressions for references.
Attributes:
-
BA
–Blank after the reference.
-
BB
–Blank before the reference.
-
COMMIT
–Commit hash.
-
COMMIT_RANGE
–Commit range.
-
ID
–Issue or pull request ID.
-
MENTION
–Mention.
-
MULTI_WORD
–Multi word reference.
-
NP
–Namespace and project.
-
ONE_WORD
–One word reference.
BA class-attribute
instance-attribute
¤
BA = '(?:[\\s,]|$)'
BB class-attribute
instance-attribute
¤
BB = '(?:^|[\\s,])'
COMMIT class-attribute
instance-attribute
¤
COMMIT = '(?P<ref>[0-9a-f]{{{min},{max}}})'
Commit hash.
COMMIT_RANGE class-attribute
instance-attribute
¤
COMMIT_RANGE = "(?P<ref>[0-9a-f]{{{min},{max}}}\\.\\.\\.[0-9a-f]{{{min},{max}}})"
Commit range.
MENTION class-attribute
instance-attribute
¤
MENTION = '@(?P<ref>\\w[-\\w]*)'
MULTI_WORD class-attribute
instance-attribute
¤
MULTI_WORD = '{symbol}(?P<ref>"\\w[- \\w]*")'
Multi word reference.
NP class-attribute
instance-attribute
¤
NP = '(?:(?P<namespace>[-\\w]+)/)?(?P<project>[-\\w]+)'
ONE_WORD class-attribute
instance-attribute
¤
ONE_WORD = '{symbol}(?P<ref>\\w*[-a-z_ ][-\\w]*)'
One word reference.
Section ¤
A list of commits grouped by section_type.
Parameters:
-
section_type
(str
, default:''
) –The section section_type.
-
commits
(list[Commit] | None
, default:None
) –The list of commits.
Attributes:
Source code in src/git_changelog/_internal/build.py
74 75 76 77 78 79 80 81 82 83 84 |
|
SemVerBumper ¤
Bases: VersionBumper
SemVer version bumper.
Parameters:
Methods:
-
__call__
–Bump a SemVer version.
Attributes:
-
initial
(str
) –The initial version.
-
strategies
–The supported bumping strategies.
Source code in src/git_changelog/_internal/versioning.py
673 674 675 676 677 678 679 680 |
|
__call__ ¤
__call__(
version: str,
strategy: SemVerStrategy = "patch",
*,
zerover: bool = True,
) -> str
Bump a SemVer version.
Parameters:
-
version
(str
) –The version to bump.
-
strategy
(SemVerStrategy
, default:'patch'
) –The bumping strategy to use.
-
zerover
(bool
, default:True
) –Keep major version at zero, even for breaking changes.
Returns:
-
str
–The bumped version.
Source code in src/git_changelog/_internal/versioning.py
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 |
|
SemVerVersion ¤
Bases: Version
, ParsedVersion
SemVer version.
Methods:
-
__eq__
–Implement
==
comparison. -
__ge__
–Implement
>=
comparison. -
__gt__
–Implement
>
comparison. -
__le__
–Implement
<=
comparison. -
__lt__
–Implement
<
comparison. -
__ne__
–Implement
!=
comparison. -
bump_major
–Bump the major version.
-
bump_minor
–Bump the minor version.
-
bump_patch
–Bump the patch version.
-
bump_release
–Bump from a pre-release to the same, regular release.
__eq__ ¤
Implement ==
comparison.
Source code in src/git_changelog/_internal/versioning.py
72 73 74 |
|
__ge__ ¤
Implement >=
comparison.
Source code in src/git_changelog/_internal/versioning.py
76 77 78 |
|
__gt__ ¤
Implement >
comparison.
Source code in src/git_changelog/_internal/versioning.py
80 81 82 |
|
__le__ ¤
Implement <=
comparison.
Source code in src/git_changelog/_internal/versioning.py
68 69 70 |
|
__lt__ ¤
Implement <
comparison.
Source code in src/git_changelog/_internal/versioning.py
64 65 66 |
|
__ne__ ¤
Implement !=
comparison.
Source code in src/git_changelog/_internal/versioning.py
84 85 86 |
|
bump_major ¤
bump_major() -> SemVerVersion
Bump the major version.
Source code in src/git_changelog/_internal/versioning.py
92 93 94 |
|
bump_minor ¤
bump_minor() -> SemVerVersion
Bump the minor version.
Source code in src/git_changelog/_internal/versioning.py
96 97 98 |
|
bump_patch ¤
bump_patch() -> SemVerVersion
Bump the patch version.
Source code in src/git_changelog/_internal/versioning.py
100 101 102 |
|
bump_release ¤
bump_release() -> SemVerVersion
Bump from a pre-release to the same, regular release.
Returns:
-
SemVerVersion
–The same version, without pre-release or build metadata.
Source code in src/git_changelog/_internal/versioning.py
104 105 106 107 108 109 110 |
|
Templates ¤
Bases: tuple
Helper to pick a template on the command line.
Methods:
-
__contains__
–Check if the template is in the list.
__contains__ ¤
Check if the template is in the list.
Source code in src/git_changelog/_internal/cli.py
96 97 98 99 100 |
|
Version ¤
Version(
tag: str = "",
date: date | None = None,
sections: list[Section] | None = None,
commits: list[Commit] | None = None,
url: str = "",
compare_url: str = "",
)
A class to represent a changelog version.
Parameters:
-
tag
(str
, default:''
) –The version tag.
-
date
(date | None
, default:None
) –The version date.
-
sections
(list[Section] | None
, default:None
) –The version sections.
-
commits
(list[Commit] | None
, default:None
) –The version commits.
-
url
(str
, default:''
) –The version URL.
-
compare_url
(str
, default:''
) –The version 'compare' URL.
Methods:
-
add_commit
–Register the given commit and add it to the relevant section based on its message convention.
Attributes:
-
commits
(list[Commit]
) –The version commits.
-
compare_url
(str
) –The version 'compare' URL.
-
date
–The version date.
-
is_major
(bool
) –Tell if this version is a major one.
-
is_minor
(bool
) –Tell if this version is a minor one.
-
next_version
(Version | None
) –The next version.
-
planned_tag
(str | None
) –The planned version tag.
-
previous_version
(Version | None
) –The previous version.
-
sections_dict
(dict[str, Section]
) –The version sections (dict).
-
sections_list
(list[Section]
) –The version sections (list).
-
tag
–The version tag.
-
typed_sections
(list[Section]
) –Return typed sections only.
-
untyped_section
(Section | None
) –Return untyped section if any.
-
url
(str
) –The version URL.
Source code in src/git_changelog/_internal/build.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
sections_dict instance-attribute
¤
The version sections (dict).
sections_list instance-attribute
¤
The version sections (list).
typed_sections property
¤
add_commit ¤
add_commit(commit: Commit) -> None
Register the given commit and add it to the relevant section based on its message convention.
Parameters:
-
commit
(Commit
) –The git commit.
Source code in src/git_changelog/_internal/build.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
VersionBumper ¤
Base class for version bumpers.
Parameters:
Methods:
-
__call__
–Bump a version.
Attributes:
-
initial
(str
) –The initial version.
-
strategies
–The supported bumping strategies.
Source code in src/git_changelog/_internal/versioning.py
673 674 675 676 677 678 679 680 |
|
__call__ ¤
Bump a version.
Parameters:
-
version
(str
) –The version to bump.
-
strategy
(str
, default:...
) –The bumping strategy.
-
**kwargs
(Any
, default:{}
) –Additional bumper-specific arguments.
Returns:
-
str
–The bumped version.
Source code in src/git_changelog/_internal/versioning.py
682 683 684 685 686 687 688 689 690 691 692 693 |
|
build_and_render ¤
build_and_render(
repository: str,
template: str,
convention: str | CommitConvention,
parse_refs: bool = False,
parse_trailers: bool = False,
sections: list[str] | None = None,
in_place: bool = False,
output: str | TextIO | None = None,
version_regex: str = DEFAULT_VERSION_REGEX,
marker_line: str = DEFAULT_MARKER_LINE,
bump_latest: bool = False,
omit_empty_versions: bool = False,
provider: str | None = None,
bump: str | None = None,
zerover: bool = True,
filter_commits: str | None = None,
jinja_context: dict[str, Any] | None = None,
versioning: Literal["pep440", "semver"] = "semver",
**kwargs: Any,
) -> tuple[Changelog, str]
Build a changelog and render it.
This function returns the changelog instance and the rendered contents, but also updates the specified output file (side-effect) or writes to stdout.
Parameters:
-
repository
(str
) –Path to a local repository.
-
template
(str
) –Name of a builtin template, or path to a custom template (prefixed with
path:
). -
convention
(str | CommitConvention
) –Name of a commit message style/convention.
-
parse_refs
(bool
, default:False
) –Whether to parse provider-specific references (GitHub/GitLab issues, PRs, etc.).
-
parse_trailers
(bool
, default:False
) –Whether to parse Git trailers.
-
sections
(list[str] | None
, default:None
) –Sections to render (features, bug fixes, etc.).
-
in_place
(bool
, default:False
) –Whether to update the changelog in-place.
-
output
(str | TextIO | None
, default:None
) –Output/changelog file.
-
version_regex
(str
, default:DEFAULT_VERSION_REGEX
) –Regular expression to match versions in an existing changelog file.
-
marker_line
(str
, default:DEFAULT_MARKER_LINE
) –Marker line used to insert contents in an existing changelog.
-
bump_latest
(bool
, default:False
) –Deprecated, use --bump=auto instead. Whether to try and bump the latest version to guess the new one.
-
omit_empty_versions
(bool
, default:False
) –Whether to omit empty versions from the output.
-
provider
(str | None
, default:None
) –Provider class used by this repository.
-
bump
(str | None
, default:None
) –Whether to try and bump to a given version.
-
zerover
(bool
, default:True
) –Keep major version at zero, even for breaking changes.
-
filter_commits
(str | None
, default:None
) –The Git revision-range used to filter commits in git-log.
-
jinja_context
(dict[str, Any] | None
, default:None
) –Key/value pairs passed to the Jinja template.
-
versioning
(Literal['pep440', 'semver']
, default:'semver'
) –Versioning scheme to use when grouping commits and bumping versions.
-
**kwargs
(Any
, default:{}
) –Swallowing kwargs to allow passing all settings at once.
Raises:
-
ValueError
–When some arguments are incompatible or missing.
Returns:
Source code in src/git_changelog/_internal/cli.py
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 |
|
bump ¤
bump(
version: str,
part: Literal["major", "minor", "patch"] = "patch",
*,
zerover: bool = True,
) -> str
Bump a version. Deprecated, use bump_semver
instead.
Parameters:
-
version
(str
) –The version to bump.
-
part
(Literal['major', 'minor', 'patch']
, default:'patch'
) –The part of the version to bump (major, minor, or patch).
-
zerover
(bool
, default:True
) –Keep major version at zero, even for breaking changes.
Returns:
-
str
–The bumped version.
Source code in src/git_changelog/_internal/build.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
configure_env ¤
configure_env(env: Environment) -> None
Configure the Jinja environment.
Parameters:
-
env
(Environment
) –The environment to configure.
Source code in src/git_changelog/_internal/templates/__init__.py
20 21 22 23 24 25 26 |
|
get_custom_template ¤
Get a custom template instance.
Parameters:
Returns:
-
Template
–The Jinja template.
Source code in src/git_changelog/_internal/templates/__init__.py
29 30 31 32 33 34 35 36 37 38 |
|
get_parser ¤
get_parser() -> ArgumentParser
Return the CLI argument parser.
Returns:
-
ArgumentParser
–An argparse parser.
Source code in src/git_changelog/_internal/cli.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
get_release_notes ¤
get_release_notes(
input_file: str | Path = "CHANGELOG.md",
version_regex: str = DEFAULT_VERSION_REGEX,
marker_line: str = DEFAULT_MARKER_LINE,
) -> str
Get release notes from existing changelog.
This will return the latest entry in the changelog.
Parameters:
-
input_file
(str | Path
, default:'CHANGELOG.md'
) –The changelog to read from.
-
version_regex
(str
, default:DEFAULT_VERSION_REGEX
) –A regular expression to match version entries.
-
marker_line
(str
, default:DEFAULT_MARKER_LINE
) –The insertion marker line in the changelog.
Returns:
-
str
–The latest changelog entry.
Source code in src/git_changelog/_internal/cli.py
823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 |
|
get_template ¤
get_template(name: str) -> Template
Get a builtin template instance.
Parameters:
-
name
(str
) –The template name.
Returns:
-
Template
–The Jinja template.
Source code in src/git_changelog/_internal/templates/__init__.py
41 42 43 44 45 46 47 48 49 50 |
|
get_version ¤
get_version() -> str
Return the current git-changelog
version.
Returns:
-
str
–The current
git-changelog
version.
Source code in src/git_changelog/_internal/cli.py
103 104 105 106 107 108 109 110 111 112 |
|
main ¤
Run the main program.
This function is executed when you type git-changelog
or python -m git_changelog
.
Parameters:
Returns:
-
int
–An exit code.
Source code in src/git_changelog/_internal/cli.py
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 |
|
output_release_notes ¤
output_release_notes(
input_file: str = "CHANGELOG.md",
version_regex: str = DEFAULT_VERSION_REGEX,
marker_line: str = DEFAULT_MARKER_LINE,
output_file: str | TextIO | None = None,
) -> None
Print release notes from existing changelog.
This will print the latest entry in the changelog.
Parameters:
-
input_file
(str
, default:'CHANGELOG.md'
) –The changelog to read from.
-
version_regex
(str
, default:DEFAULT_VERSION_REGEX
) –A regular expression to match version entries.
-
marker_line
(str
, default:DEFAULT_MARKER_LINE
) –The insertion marker line in the changelog.
-
output_file
(str | TextIO | None
, default:None
) –Where to print/write the release notes.
Source code in src/git_changelog/_internal/cli.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 |
|
parse_pep440 ¤
parse_pep440(version: str) -> tuple[PEP440Version, str]
Parse a PEP version.
Returns:
-
tuple[PEP440Version, str]
–A PEP 440 version instance with useful methods.
Source code in src/git_changelog/_internal/versioning.py
657 658 659 660 661 662 663 664 |
|
parse_semver ¤
parse_semver(version: str) -> tuple[SemVerVersion, str]
Parse a SemVer version.
Returns:
-
tuple[SemVerVersion, str]
–A semver version instance with useful methods.
Source code in src/git_changelog/_internal/versioning.py
647 648 649 650 651 652 653 654 |
|
parse_settings ¤
Parse arguments and config files to build the final settings set.
Parameters:
Returns:
-
dict
–A dictionary with the final settings.
Source code in src/git_changelog/_internal/cli.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
|
parse_version ¤
parse_version(version: str) -> tuple[SemVerVersion, str]
Parse a version. Deprecated, use bump_semver
instead.
Parameters:
-
version
(str
) –The version to parse.
Returns:
-
semver_version
(SemVerVersion
) –The semantic version.
-
prefix
(str
) –The version prefix.
Source code in src/git_changelog/_internal/build.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
read_config ¤
read_config(
config_file: Sequence[str | Path]
| str
| Path
| None = DEFAULT_CONFIG_FILES,
) -> dict
Find config files and initialize settings with the one of highest priority.
Parameters:
-
config_file
(Sequence[str | Path] | str | Path | None
, default:DEFAULT_CONFIG_FILES
) –A path or list of paths to configuration file(s); or
None
to disable config file settings. Default: a list of paths given bygit_changelog.DEFAULT_CONFIG_FILES
.
Returns:
-
dict
–A settings dictionary. Default settings if no config file is found or
config_file
isNone
.
Source code in src/git_changelog/_internal/cli.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
|
render ¤
render(
changelog: Changelog,
template: str,
in_place: bool = False,
output: str | TextIO | None = None,
version_regex: str = DEFAULT_VERSION_REGEX,
marker_line: str = DEFAULT_MARKER_LINE,
bump_latest: bool = False,
bump: str | None = None,
jinja_context: dict[str, Any] | None = None,
) -> str
Render a changelog.
This function updates the specified output file (side-effect) or writes to stdout.
Parameters:
-
changelog
(Changelog
) –The changelog to render.
-
template
(str
) –Name of a builtin template, or path to a custom template (prefixed with
path:
). -
in_place
(bool
, default:False
) –Whether to update the changelog in-place.
-
output
(str | TextIO | None
, default:None
) –Output/changelog file.
-
version_regex
(str
, default:DEFAULT_VERSION_REGEX
) –Regular expression to match versions in an existing changelog file.
-
marker_line
(str
, default:DEFAULT_MARKER_LINE
) –Marker line used to insert contents in an existing changelog.
-
bump_latest
(bool
, default:False
) –Deprecated, use --bump=auto instead. Whether to try and bump the latest version to guess the new one.
-
bump
(str | None
, default:None
) –Whether to try and bump to a given version.
-
jinja_context
(dict[str, Any] | None
, default:None
) –Key/value pairs passed to the Jinja template.
Raises:
-
ValueError
–When some arguments are incompatible or missing.
Returns:
-
str
–The rendered changelog.
Source code in src/git_changelog/_internal/cli.py
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
|
version_prefix ¤
Return a version and its optional v
prefix.
Parameters:
-
version
(str
) –The full version.
Returns:
Source code in src/git_changelog/_internal/versioning.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
|
build ¤
Deprecated. Import from git_changelog
directly.
cli ¤
Deprecated. Import from git_changelog
directly.
commit ¤
Deprecated. Import from git_changelog
directly.
providers ¤
Deprecated. Import from git_changelog
directly.
templates ¤
Deprecated. Import from git_changelog
directly.
versioning ¤
Deprecated. Import from git_changelog
directly.