build ¤
The module responsible for building the data.
Classes:
-
Changelog
–The main changelog class.
-
Section
–A list of commits grouped by section_type.
-
Version
–A class to represent a changelog version.
Functions:
-
bump
–Bump a version. Deprecated, use
bump_semver
instead. -
parse_version
–Parse a version. Deprecated, use
bump_semver
instead.
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.
Source code in src/git_changelog/build.py
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 |
|
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/build.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
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/build.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
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/build.py
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 |
|
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/build.py
298 299 300 301 302 303 304 305 306 307 |
|
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.
Source code in src/git_changelog/build.py
73 74 75 76 77 78 79 80 81 |
|
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:
-
is_major
(bool
) –Tell if this version is a major one.
-
is_minor
(bool
) –Tell if this version is a minor one.
-
typed_sections
(list[Section]
) –Return typed sections only.
-
untyped_section
(Section | None
) –Return untyped section if any.
Source code in src/git_changelog/build.py
87 88 89 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 |
|
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/build.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
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/build.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
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/build.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|