@@ -74,6 +74,7 @@ build_and_render(
74
74
parse_trailers = True ,
75
75
parse_refs = False ,
76
76
sections = (" build" , " deps" , " feat" , " fix" , " refactor" ),
77
+ versioning = " pep440" ,
77
78
bump = " auto" ,
78
79
in_place = True ,
79
80
)
@@ -129,6 +130,7 @@ repository = "."
129
130
sections = [" fix" , " maint" ]
130
131
template = " angular"
131
132
version-regex = " ^## \\\\ [(?P<version>v?[^\\\\ ]]+)"
133
+ versioning = " semver"
132
134
zerover = true
133
135
```
134
136
@@ -150,6 +152,7 @@ repository = "."
150
152
sections = " fix,maint"
151
153
template = " keepachangelog"
152
154
version-regex = " ^## \\\\ [(?P<version>v?[^\\\\ ]]+)"
155
+ versioning = " semver"
153
156
zerover = true
154
157
```
155
158
@@ -421,8 +424,12 @@ git-changelog --filter-commits "2c0dbb8.."
421
424
## Understand the relationship with SemVer
422
425
423
426
[ (--bump)] ( cli.md#bump ) <br >
427
+ [ (--versioning)] ( cli.md#versioning ) <br >
424
428
[ (--zerover)] ( cli.md#zerover )
425
429
430
+ * Although git-changelog supports several [ versioning schemes] ( #choose-a-versioning-scheme ) ,
431
+ SemVer plays a particular role when managing versions.*
432
+
426
433
[ SemVer] [ semver ] , or Semantic Versioning, helps users of tools and libraries
427
434
understand the impact of version changes. To quote SemVer itself:
428
435
@@ -461,6 +468,10 @@ git-changelog --bump minor # 1.2.3 -> 1.3.0
461
468
git-changelog --bump patch # 1.2.3 -> 1.2.4
462
469
```
463
470
471
+ As different schemes have different bumping strategies,
472
+ the selected scheme will affect the ` --bump ` option.
473
+ See [ PEP 440 strategies] ( #pep-440 ) and [ SemVer strategies] ( #semver ) .
474
+
464
475
### ZeroVer
465
476
466
477
Note that by default, "ZeroVer" mode is activated,
@@ -503,6 +514,153 @@ to bump to v1, set `zerover = false` and commit it as a breaking change.
503
514
Once v1 is released, the setting has no use anymore, and you can remove it
504
515
from your configuration file.
505
516
517
+ ## Choose a versioning scheme
518
+
519
+ [ (--bump)] ( cli.md#bump ) <br >
520
+ [ (--versioning)] ( cli.md#versioning ) <br >
521
+ [ (--zerover)] ( cli.md#zerover )
522
+
523
+ * git-changelog* currently supports the following versioning schemes:
524
+
525
+ - ` pep440 ` , see [ PEP 440] [ pep440 ]
526
+ - ` semver ` , see [ SemVer] [ semver ]
527
+
528
+ Versioning schemes are useful to * git-changelog* when grouping commits
529
+ from your Git history into versions, and when bumping versions.
530
+
531
+ To choose a specific scheme, use the ` -n ` , ` --versioning ` CLI option:
532
+
533
+ ``` bash
534
+ git-changelog -n pep440
535
+ ```
536
+
537
+ For backward compatibility reasons, it uses the SemVer scheme by default.
538
+
539
+ As different schemes have different bumping strategies,
540
+ the selected scheme will affect the ` --bump ` option.
541
+
542
+ ### PEP 440
543
+
544
+ The bumping strategies supported by the PEP 440 scheme
545
+ are described in the table below.
546
+ Bumping a specific part of the version will remove or reset the parts
547
+ on its right to 0.
548
+
549
+ Strategy | Example | Description
550
+ --------------------- | --------------------- | -----------
551
+ ` auto ` | - | Guess which of major, minor or micro to bump<br >thanks to the Git history and commit message conventions.
552
+ ` epoch ` | ` 1!1 ` → ` 2!1 ` | Bump [ epoch] [ pep440-epoch ] , keeping [ final release] [ pep440-release ] only.
553
+ ` release ` | ` 1rc2 ` → ` 1 ` | Bump version to a [ final release] [ pep440-release ] .
554
+ ` major ` | ` 1.1 ` → ` 2.0 ` | Bump major version.
555
+ ` minor ` | ` 1.1.1 ` → ` 1.2.0 ` | Bump minor version.
556
+ ` micro ` (or ` patch ` ) | ` 1.1.1.1 ` → ` 1.1.2.0 ` | Bump micro version.
557
+ ` pre ` | ` 1a0 ` → ` 1a1 ` | Bump current [ pre-release] [ pep440-pre ] (alpha ` a ` , beta ` b ` or release candidate ` rc ` ).
558
+ ` alpha ` | ` 1a0 ` → ` 1a1 ` | Bump current alpha pre-release.
559
+ ` beta ` | ` 1b0 ` → ` 1b1 ` | Bump current beta pre-release.
560
+ ` candidate ` | ` 1rc0 ` → ` 1rc1 ` | Bump current candidate pre-release.
561
+ ` post ` | ` 1 ` → ` 1.post0 ` | Bump to a [ post-release] [ pep440-post ] .
562
+ ` dev ` | ` 1.dev0 ` → ` 1.dev1 ` | Bump current [ dev-release] [ pep440-dev ] .
563
+ ` auto+alpha ` | - | Guess major/minor/micro bump, and set it to alpha pre-release.
564
+ ` auto+beta ` | - | Guess major/minor/micro bump, and set it to beta pre-release.
565
+ ` auto+candidate ` | - | Guess major/minor/micro bump, and set it to candidate pre-release.
566
+ ` auto+dev ` | - | Guess major/minor/micro bump, and set it to dev-release.
567
+ ` auto+alpha+dev ` | - | Guess major/minor/micro bump, and set it to alpha pre-release and dev-release.
568
+ ` auto+beta+dev ` | - | Guess major/minor/micro bump, and set it to beta pre-release and dev-release.
569
+ ` auto+candidate+dev ` | - | Guess major/minor/micro bump, and set it to candidate pre-release and dev-release.
570
+ ` major+alpha ` | ` 1 ` → ` 2a0 ` | Bump major version and set it to alpha pre-release.
571
+ ` major+beta ` | ` 1 ` → ` 2b0 ` | Bump major version and set it to beta pre-release.
572
+ ` major+candidate ` | ` 1 ` → ` 2rc0 ` | Bump major version and set it to candidate pre-release.
573
+ ` major+dev ` | ` 1 ` → ` 2.dev0 ` | Bump major version and set it to dev-release.
574
+ ` major+alpha+dev ` | ` 1 ` → ` 2a0.dev0 ` | Bump major version and set it to alpha pre-release and dev-release.
575
+ ` major+beta+dev ` | ` 1 ` → ` 2b0.dev0 ` | Bump major version and set it to beta pre-release and dev-release.
576
+ ` major+candidate+dev ` | ` 1 ` → ` 2rc0.dev0 ` | Bump major version and set it to candidate pre-release and dev-release.
577
+ ` minor+alpha ` | ` 1 ` → ` 1.1a0 ` | Bump minor version and set it to alpha pre-release.
578
+ ` minor+beta ` | ` 1 ` → ` 1.1b0 ` | Bump minor version and set it to beta pre-release.
579
+ ` minor+candidate ` | ` 1 ` → ` 1.1rc0 ` | Bump minor version and set it to candidate pre-release.
580
+ ` minor+dev ` | ` 1 ` → ` 1.1.dev0 ` | Bump minor version and set it to dev-release.
581
+ ` minor+alpha+dev ` | ` 1 ` → ` 1.1a0.dev0 ` | Bump minor version and set it to alpha pre-release and dev-release.
582
+ ` minor+beta+dev ` | ` 1 ` → ` 1.1b0.dev0 ` | Bump minor version and set it to beta pre-release and dev-release.
583
+ ` minor+candidate+dev ` | ` 1 ` → ` 1.1rc0.dev0 ` | Bump minor version and set it to candidate pre-release and dev-release.
584
+ ` micro+alpha ` | ` 1 ` → ` 1.0.1a0 ` | Bump micro version and set it to alpha pre-release.
585
+ ` micro+beta ` | ` 1 ` → ` 1.0.1b0 ` | Bump micro version and set it to beta pre-release.
586
+ ` micro+candidate ` | ` 1 ` → ` 1.0.1rc0 ` | Bump micro version and set it to candidate pre-release.
587
+ ` micro+dev ` | ` 1 ` → ` 1.0.1.dev0 ` | Bump micro version and set it to dev-release.
588
+ ` micro+alpha+dev ` | ` 1 ` → ` 1.0.1a0.dev0 ` | Bump micro version and set it to alpha pre-release and dev-release.
589
+ ` micro+beta+dev ` | ` 1 ` → ` 1.0.1b0.dev0 ` | Bump micro version and set it to beta pre-release and dev-release.
590
+ ` micro+candidate+dev ` | ` 1 ` → ` 1.0.1rc0.dev0 ` | Bump micro version and set it to candidate pre-release and dev-release.
591
+ ` alpha+dev ` | ` 1a0 ` → ` 1a1.dev0 ` | Bump current alpha pre-release and set it to a dev-release.
592
+ ` beta+dev ` | ` 1b0 ` → ` 1b1.dev0 ` | Bump current beta pre-release and set it to a dev-release.
593
+ ` candidate+dev ` | ` 1rc0 ` → ` 1rc1.dev0 ` | Bump current candidate pre-release and set it to a dev-release.
594
+
595
+ Try it out:
596
+
597
+ ``` pyodide install="git-changelog"
598
+ from git_changelog.versioning import bump_pep440
599
+
600
+ # "auto" strategies are not directly supported by this function
601
+ print(bump_pep440("1.2.3", "minor+alpha"))
602
+ ```
603
+
604
+ The ` v ` prefix will be preserved when bumping a version: ` v1 ` -> ` v2 ` .
605
+
606
+ The bumping strategies for PEP 440 try to make the most sense,
607
+ allowing you to bump in a semantic way and preventing version downgrade mistakes.
608
+ Specifically, it is not possible:
609
+
610
+ - to bump from a final release version to a pre-release or a dev-release version
611
+ - to bump from a pre-release version to a lower pre-release version or a dev-version
612
+ - more generally, to bump from any version to any lower version
613
+
614
+ If you need to "bump" to a version that is lower than the latest released one,
615
+ you must explicitely pass the version to the ` --bump ` option:
616
+
617
+ ``` bash
618
+ # latest release is 1.1
619
+ git-changelog --bump 1.0
620
+ ```
621
+
622
+ ### SemVer
623
+
624
+ The bumping strategies supported by the SemVer scheme
625
+ are described in the table below.
626
+ Bumping a specific part of the version will remove or reset the parts
627
+ on its right to 0.
628
+
629
+ Strategy | Example | Description
630
+ --------------------- | --------------------- | -----------
631
+ ` auto ` | - | Guess which of major, minor or patch to bump<br >thanks to the Git history and commit message conventions.
632
+ ` major ` | ` 1.1.1 ` → ` 2.0.0 ` | Bump major version.
633
+ ` minor ` | ` 1.1.1 ` → ` 1.2.0 ` | Bump minor version.
634
+ ` patch ` | ` 1.1.1 ` → ` 1.1.2 ` | Bump micro version.
635
+ ` release ` | ` 1.1.1-a2 ` → ` 1.1.1 ` | Bump version to a final release (remove pre-release and build metadata).
636
+
637
+ Try it out:
638
+
639
+ ``` pyodide install="git-changelog"
640
+ from git_changelog.versioning import bump_semver
641
+
642
+ # the "auto" strategy is not directly supported by this function
643
+ print(bump_semver("1.2.3", "minor"))
644
+ ```
645
+
646
+ The ` v ` prefix will be preserved when bumping a version: ` v1.0.0 ` -> ` v2.0.0 ` .
647
+
648
+ The bumping strategies for SemVer will prevent you from bumping from any version to a lower one.
649
+ It does not support bump pre-release metadata or build metadata
650
+ because these are not standardized.
651
+
652
+ If you need to "bump" to a version that is lower than the latest released one,
653
+ or to add pre-release or build metadata,
654
+ you must explicitely pass the version to the ` --bump ` option:
655
+
656
+ ``` bash
657
+ # downgrade
658
+ git-changelog --bump 1.1.0
659
+
660
+ # add pre-release metadata
661
+ git-changelog --bump 2.0.0-alpha1
662
+ ```
663
+
506
664
## Parse additional information in commit messages
507
665
508
666
* git-changelog* is able to parse the body of commit messages
@@ -707,3 +865,9 @@ and `--marker-line`.
707
865
[keepachangelog- template]: https:// github.com/ pawamoy/ git- changelog/ tree/ main/ src/ git_changelog/ templates/ keepachangelog.md
708
866
[builtin- templates]: https:// github.com/ pawamoy/ git- changelog/ tree/ main/ src/ git_changelog/ templates
709
867
[control- whitespace]: https:// jinja.palletsprojects.com/ en/ 3.1 .x/ templates/ # whitespace-control
868
+ [pep440]: https:// peps.python.org/ pep- 0440 /
869
+ [pep440- epoch]: https:// peps.python.org/ pep- 0440 / # version-epochs
870
+ [pep440- pre]: https:// peps.python.org/ pep- 0440 / # pre-releases
871
+ [pep440- post]: https:// peps.python.org/ pep- 0440 / # post-releases
872
+ [pep440- dev]: https:// peps.python.org/ pep- 0440 / # developmental-releases
873
+ [pep440- release]: https:// peps.python.org/ pep- 0440 / # final-releases
0 commit comments