mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 06:20:08 +01:00
Optional GITHASH directive for version_pattern
Optionally add GIT hash to your version number.
This commit is contained in:
parent
e96904438b
commit
da44922261
5 changed files with 34 additions and 0 deletions
|
|
@ -1,5 +1,9 @@
|
|||
# Changelog for https://github.com/mbarkhau/bumpver
|
||||
|
||||
## **unreleased**
|
||||
|
||||
- Add ``GITHASH`` to ``version_pattern`` (@mpasternak)
|
||||
|
||||
## BumpVer 2022.1116
|
||||
|
||||
- Fix: [incorrect version comparison when updating from vcs tag][gh_i174].
|
||||
|
|
|
|||
24
README.md
24
README.md
|
|
@ -412,6 +412,30 @@ INFO - New Version: v2020.1060
|
|||
+__version__ = "v2020.1060"
|
||||
```
|
||||
|
||||
#### Add git hash to version string
|
||||
|
||||
In case you want to build a package straight from your git repository, without making a release first,
|
||||
you can explictly add git hash to the version number using ``GITHASH`` version part in ``setup.cfg``.
|
||||
|
||||
Let's say your ``setup.cfg`` looks like this:
|
||||
|
||||
```ini
|
||||
[bumpver]
|
||||
...
|
||||
version_pattern = "YYYY.BUILD[-TAG][GITHASH]"
|
||||
...
|
||||
```
|
||||
|
||||
Then, to update all configured files, you need to execute this command:
|
||||
|
||||
```shell
|
||||
$ bumpver update --no-commit --no-tag --set-version="v202202.1085.8+ged2c3aaf"
|
||||
```
|
||||
|
||||
This will modify your source tree, but won't commit or tag aything, so you can build your
|
||||
packages with that version number. Then, remember to reset local changes after (by
|
||||
typing ``git reset --hard``) as standard bumpver behaviour with such version number
|
||||
makes not much sense.
|
||||
|
||||
|
||||
### Searching for Patterns with `grep`
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ PART_PATTERNS = {
|
|||
'BLD' : r"[1-9][0-9]*",
|
||||
'TAG' : r"preview|final|alpha|beta|post|rc",
|
||||
'PYTAG': r"post|rc|a|b",
|
||||
'GITHASH' : r"\.[0-9]+\+.*",
|
||||
'NUM' : r"[0-9]+",
|
||||
'INC0' : r"[0-9]+",
|
||||
'INC1' : r"[1-9][0-9]*",
|
||||
|
|
@ -109,6 +110,7 @@ PATTERN_PART_FIELDS = {
|
|||
'BLD' : 'bid',
|
||||
'TAG' : 'tag',
|
||||
'PYTAG': 'pytag',
|
||||
'GITHASH' : 'githash',
|
||||
'NUM' : 'num',
|
||||
'INC0' : 'inc0',
|
||||
'INC1' : 'inc1',
|
||||
|
|
@ -208,6 +210,7 @@ PART_FORMATS: typ.Dict[str, FormatterFunc] = {
|
|||
'BLD' : _fmt_bld,
|
||||
'TAG' : _fmt_num,
|
||||
'PYTAG': _fmt_num,
|
||||
'GITHASH' : _fmt_num,
|
||||
'NUM' : _fmt_num,
|
||||
'INC0' : _fmt_num,
|
||||
'INC1' : _fmt_num,
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ def parse_field_values_to_vinfo(field_values: FieldValues) -> version.V2VersionI
|
|||
|
||||
tag = fvals.get('tag' ) or ""
|
||||
pytag = fvals.get('pytag') or ""
|
||||
githash = fvals.get('githash') or ""
|
||||
|
||||
if tag and not pytag:
|
||||
pytag = version.PEP440_TAG_BY_TAG[tag]
|
||||
|
|
@ -257,6 +258,7 @@ def parse_field_values_to_vinfo(field_values: FieldValues) -> version.V2VersionI
|
|||
bid=bid,
|
||||
tag=tag,
|
||||
pytag=pytag,
|
||||
githash=githash,
|
||||
num=num,
|
||||
inc0=inc0,
|
||||
inc1=inc1,
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ class V2VersionInfo(typ.NamedTuple):
|
|||
bid : str
|
||||
tag : str
|
||||
pytag : str
|
||||
githash : str
|
||||
num : int
|
||||
inc0 : int
|
||||
inc1 : int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue