git_changelog ¤
git-changelog package.
Automatic Changelog generator using Jinja2 templates.
Modules:
-
build
–The module responsible for building the data.
-
cli
–Module that contains the command line application.
-
commit
–Module containing the commit logic.
-
debug
–Debugging utilities.
-
providers
–Module containing the parsing utilities for git providers.
-
templates
–The subpackage containing the builtin templates.
-
versioning
–Utilities to handle different versioning schemes such as SemVer and PEP 440.
Classes:
-
Bitbucket
–A parser for the Bitbucket references.
-
Changelog
–The main changelog class.
-
Commit
–A class to represent a commit.
-
GitHub
–A parser for the GitHub references.
-
GitLab
–A parser for the GitLab references.
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:
-
get_refs
–Find all references in the given text.
-
parse_refs
–Parse references in the given text.
Source code in src/git_changelog/providers.py
64 65 66 67 68 69 70 71 72 73 74 |
|
get_refs ¤
Find all references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/providers.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
parse_refs ¤
Parse references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/providers.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
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 |
|
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:
-
parent_commits
(list[Commit]
) –Parent commits of this commit.
Source code in src/git_changelog/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 |
|
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/commit.py
215 216 217 218 219 220 221 |
|
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/commit.py
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 |
|
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:
-
get_refs
–Find all references in the given text.
-
parse_refs
–Parse references in the given text.
Source code in src/git_changelog/providers.py
64 65 66 67 68 69 70 71 72 73 74 |
|
get_refs ¤
Find all references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/providers.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
parse_refs ¤
Parse references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/providers.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
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:
-
get_refs
–Find all references in the given text.
-
parse_refs
–Parse references in the given text.
Source code in src/git_changelog/providers.py
64 65 66 67 68 69 70 71 72 73 74 |
|
get_refs ¤
Find all references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/providers.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
parse_refs ¤
Parse references in the given text.
Parameters:
Returns:
Source code in src/git_changelog/providers.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|