mirror of
https://github.com/TECHNOFAB11/bumpver.git
synced 2025-12-12 14:30:09 +01:00
add config parameter: commit_message
This commit is contained in:
parent
7febf195ae
commit
a8e658d1c4
4 changed files with 102 additions and 53 deletions
97
README.md
97
README.md
|
|
@ -19,7 +19,7 @@ Project/Repo:
|
||||||
|
|
||||||
[![MIT License][license_img]][license_ref]
|
[![MIT License][license_img]][license_ref]
|
||||||
[![Supported Python Versions][pyversions_img]][pyversions_ref]
|
[![Supported Python Versions][pyversions_img]][pyversions_ref]
|
||||||
[![PyCalVer v202007.0036][version_img]][version_ref]
|
[![PyCalVer v202007.1036][version_img]][version_ref]
|
||||||
[![PyPI Releases][pypi_img]][pypi_ref]
|
[![PyPI Releases][pypi_img]][pypi_ref]
|
||||||
[![PyPI Downloads][downloads_img]][downloads_ref]
|
[![PyPI Downloads][downloads_img]][downloads_ref]
|
||||||
|
|
||||||
|
|
@ -89,8 +89,9 @@ WARNING - File not found: pycalver.toml
|
||||||
Exiting because of '--dry'. Would have written to pycalver.toml:
|
Exiting because of '--dry'. Would have written to pycalver.toml:
|
||||||
|
|
||||||
[pycalver]
|
[pycalver]
|
||||||
current_version = "v201902.0001-alpha"
|
current_version = "v202010.1001-alpha"
|
||||||
version_pattern = "{pycalver}"
|
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||||
|
commit_message = "bump version to {new_version}"
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
push = true
|
push = true
|
||||||
|
|
@ -123,8 +124,9 @@ This will add the something like the following to your `setup.cfg`
|
||||||
```ini
|
```ini
|
||||||
# setup.cfg
|
# setup.cfg
|
||||||
[pycalver]
|
[pycalver]
|
||||||
current_version = "v201902.0001-alpha"
|
current_version = "v201902.1001-alpha"
|
||||||
version_pattern = "{pycalver}"
|
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||||
|
commit_message = "bump version to {new_version}"
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
push = True
|
push = True
|
||||||
|
|
@ -164,35 +166,35 @@ it would have made.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ pycalver bump --dry --no-fetch
|
$ pycalver bump --dry --no-fetch
|
||||||
INFO - Old Version: v201901.0001-beta
|
INFO - Old Version: v201901.1001-beta
|
||||||
INFO - New Version: v201902.0002-beta
|
INFO - New Version: v201902.1002-beta
|
||||||
--- README.md
|
--- README.md
|
||||||
+++ README.md
|
+++ README.md
|
||||||
@@ -11,7 +11,7 @@
|
@@ -11,7 +11,7 @@
|
||||||
|
|
||||||
[![Supported Python Versions][pyversions_img]][pyversions_ref]
|
[![Supported Python Versions][pyversions_img]][pyversions_ref]
|
||||||
-[![Version v201901.0001][version_img]][version_ref]
|
-[![Version v201901.1001-beta][version_img]][version_ref]
|
||||||
+[![Version v201902.0002][version_img]][version_ref]
|
+[![Version v201902.1002-beta][version_img]][version_ref]
|
||||||
[![PyPI Releases][pypi_img]][pypi_ref]
|
[![PyPI Releases][pypi_img]][pypi_ref]
|
||||||
|
|
||||||
--- src/mymodule_v1/__init__.py
|
--- src/mymodule_v1/__init__.py
|
||||||
+++ src/mymodule_v1/__init__.py
|
+++ src/mymodule_v1/__init__.py
|
||||||
@@ -1,1 +1,1 @@
|
@@ -1,1 +1,1 @@
|
||||||
-__version__ = "v201901.0001-beta"
|
-__version__ = "v201901.1001-beta"
|
||||||
+__version__ = "v201902.0002-beta"
|
+__version__ = "v201902.1002-beta"
|
||||||
|
|
||||||
--- src/mymodule_v2/__init__.py
|
--- src/mymodule_v2/__init__.py
|
||||||
+++ src/mymodule_v2/__init__.py
|
+++ src/mymodule_v2/__init__.py
|
||||||
@@ -1,1 +1,1 @@
|
@@ -1,1 +1,1 @@
|
||||||
-__version__ = "v201901.0001-beta"
|
-__version__ = "v201901.1001-beta"
|
||||||
+__version__ = "v201902.0002-beta"
|
+__version__ = "v201902.1002-beta"
|
||||||
|
|
||||||
--- setup.py
|
--- setup.py
|
||||||
+++ setup.py
|
+++ setup.py
|
||||||
@@ -44,7 +44,7 @@
|
@@ -44,7 +44,7 @@
|
||||||
name="myproject",
|
name="myproject",
|
||||||
- version="201901.1b0",
|
- version="201901.1001b0",
|
||||||
+ version="201902.2b0",
|
+ version="201902.1002b0",
|
||||||
license="MIT",
|
license="MIT",
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -485,10 +487,10 @@ maintainer and no build system) this is a non-issue and you can always use
|
||||||
```shell
|
```shell
|
||||||
$ time pycalver show --verbose
|
$ time pycalver show --verbose
|
||||||
INFO - fetching tags from remote (to turn off use: -n / --no-fetch)
|
INFO - fetching tags from remote (to turn off use: -n / --no-fetch)
|
||||||
INFO - Working dir version : v201812.0018
|
INFO - Working dir version : v202010.1018
|
||||||
INFO - Latest version from git tag: v201901.0019-beta
|
INFO - Latest version from git tag: v202010.1019-beta
|
||||||
Current Version: v201901.0019-beta
|
Current Version: v202010.1019-beta
|
||||||
PEP440 : 201901.19b0
|
PEP440 : 202010.1019b0
|
||||||
|
|
||||||
real 0m4,254s
|
real 0m4,254s
|
||||||
|
|
||||||
|
|
@ -506,8 +508,9 @@ section:
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
[pycalver]
|
[pycalver]
|
||||||
current_version = "202008.1006-beta"
|
current_version = "v202010.1006-beta"
|
||||||
version_pattern = "YYYY0M.BUILD[-TAG]"
|
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||||
|
commit_message = "bump version to {new_version}"
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
push = True
|
push = True
|
||||||
|
|
@ -544,11 +547,11 @@ $ pycalver bump --dry
|
||||||
@@ -65,7 +65,7 @@
|
@@ -65,7 +65,7 @@
|
||||||
|
|
||||||
[pycalver]
|
[pycalver]
|
||||||
-current_version = v202008.1005-beta
|
-current_version = v202010.1005-beta
|
||||||
+current_version = v202008.1006-beta
|
+current_version = v202010.1006-beta
|
||||||
|
version_pattern = "vYYYY0M.BUILD[-TAG]"
|
||||||
|
commit_message = "bump version to {new_version}"
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
|
||||||
push = True
|
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -557,13 +560,47 @@ If everything looks OK, you can do `pycalver bump`.
|
||||||
```
|
```
|
||||||
$ pycalver bump --verbose
|
$ pycalver bump --verbose
|
||||||
INFO - fetching tags from remote (to turn off use: -n / --no-fetch)
|
INFO - fetching tags from remote (to turn off use: -n / --no-fetch)
|
||||||
INFO - Old Version: v202008.0005-beta
|
INFO - Old Version: v202010.1005-beta
|
||||||
INFO - New Version: v202008.0006-beta
|
INFO - New Version: v202010.1006-beta
|
||||||
INFO - git commit --file /tmp/tmpph_npey9
|
INFO - git commit --message 'bump version to v202010.1006-beta'
|
||||||
INFO - git tag --annotate v202008.0006-beta --message v202008.0006-beta
|
INFO - git tag --annotate v202010.1006-beta --message v202010.1006-beta
|
||||||
INFO - git push origin v202008.0006-beta
|
INFO - git push origin v202010.1006-beta
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Config Parameters
|
||||||
|
|
||||||
|
TODO: Descriptions
|
||||||
|
|
||||||
|
| Config Parameter | Type | Description |
|
||||||
|
|-------------------|---------|------------------------------|
|
||||||
|
| `current_version` | string | |
|
||||||
|
| `version_pattern` | string | |
|
||||||
|
| `commit_message` | string | ¹Template fro commit message |
|
||||||
|
| `commit` | boolean | |
|
||||||
|
| `tag` | boolean | |
|
||||||
|
| `push` | boolean | |
|
||||||
|
|
||||||
|
- ¹ Available placeholders:
|
||||||
|
- `{new_version}`
|
||||||
|
- `{old_version}`
|
||||||
|
- `{new_version_pep440}`
|
||||||
|
- `{old_version_pep440}`
|
||||||
|
|
||||||
|
|
||||||
|
### CLI Arguments
|
||||||
|
|
||||||
|
TODO: Descriptions
|
||||||
|
|
||||||
|
| CLI Argument | Description |
|
||||||
|
|---------------|-------------|
|
||||||
|
| --major | |
|
||||||
|
| --minor | |
|
||||||
|
| --patch | |
|
||||||
|
| --pin-date | |
|
||||||
|
| --no-fetch | |
|
||||||
|
| --dry | |
|
||||||
|
| --allow-dirty | |
|
||||||
|
|
||||||
|
|
||||||
## The PyCalVer Format
|
## The PyCalVer Format
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -392,15 +392,13 @@ def bump(
|
||||||
if dry:
|
if dry:
|
||||||
return
|
return
|
||||||
|
|
||||||
# # TODO (mb 2020-09-05): format from config
|
commit_message_kwargs = {
|
||||||
# commit_message_kwargs = {
|
'new_version' : new_version,
|
||||||
# new_version
|
'old_version' : old_version,
|
||||||
# old_version
|
'new_version_pep440': v1version.to_pep440(new_version),
|
||||||
# pep440_new_version
|
'old_version_pep440': v1version.to_pep440(old_version),
|
||||||
# pep440_old_version
|
}
|
||||||
# }
|
commit_message = cfg.commit_message.format(**commit_message_kwargs)
|
||||||
# cfg.commit_message =
|
|
||||||
commit_message = f"bump version to {new_version}"
|
|
||||||
|
|
||||||
_try_bump(cfg, new_version, commit_message, allow_dirty)
|
_try_bump(cfg, new_version, commit_message, allow_dirty)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ PatternsByGlob = typ.Dict[str, Patterns]
|
||||||
|
|
||||||
SUPPORTED_CONFIGS = ["setup.cfg", "pyproject.toml", "pycalver.toml"]
|
SUPPORTED_CONFIGS = ["setup.cfg", "pyproject.toml", "pycalver.toml"]
|
||||||
|
|
||||||
|
DEFAULT_COMMIT_MESSAGE = "bump version to {new_version}"
|
||||||
|
|
||||||
|
|
||||||
class ProjectContext(typ.NamedTuple):
|
class ProjectContext(typ.NamedTuple):
|
||||||
"""Container class for project info."""
|
"""Container class for project info."""
|
||||||
|
|
@ -78,6 +80,7 @@ class Config(typ.NamedTuple):
|
||||||
current_version: str
|
current_version: str
|
||||||
version_pattern: str
|
version_pattern: str
|
||||||
pep440_version : str
|
pep440_version : str
|
||||||
|
commit_message : str
|
||||||
|
|
||||||
commit: bool
|
commit: bool
|
||||||
tag : bool
|
tag : bool
|
||||||
|
|
@ -92,6 +95,7 @@ def _debug_str(cfg: Config) -> str:
|
||||||
f"current_version='{cfg.current_version}'",
|
f"current_version='{cfg.current_version}'",
|
||||||
"version_pattern='{pycalver}'",
|
"version_pattern='{pycalver}'",
|
||||||
f"pep440_version='{cfg.pep440_version}'",
|
f"pep440_version='{cfg.pep440_version}'",
|
||||||
|
f"commit_message='{cfg.commit_message}'",
|
||||||
f"commit={cfg.commit}",
|
f"commit={cfg.commit}",
|
||||||
f"tag={cfg.tag}",
|
f"tag={cfg.tag}",
|
||||||
f"push={cfg.push}",
|
f"push={cfg.push}",
|
||||||
|
|
@ -238,6 +242,8 @@ def _parse_config(raw_cfg: RawConfig) -> Config:
|
||||||
version_pattern: str = raw_cfg.get('version_pattern', "{pycalver}")
|
version_pattern: str = raw_cfg.get('version_pattern', "{pycalver}")
|
||||||
version_pattern = raw_cfg['version_pattern'] = version_pattern.strip("'\" ")
|
version_pattern = raw_cfg['version_pattern'] = version_pattern.strip("'\" ")
|
||||||
|
|
||||||
|
commit_message: str = raw_cfg.get('commit_message', DEFAULT_COMMIT_MESSAGE)
|
||||||
|
commit_message = raw_cfg['commit_message'] = commit_message.strip("'\" ")
|
||||||
# NOTE (mb 2019-01-05): Provoke ValueError if version_pattern
|
# NOTE (mb 2019-01-05): Provoke ValueError if version_pattern
|
||||||
# and current_version are not compatible.
|
# and current_version are not compatible.
|
||||||
version.parse_version_info(version_str, version_pattern)
|
version.parse_version_info(version_str, version_pattern)
|
||||||
|
|
@ -265,6 +271,7 @@ def _parse_config(raw_cfg: RawConfig) -> Config:
|
||||||
current_version=version_str,
|
current_version=version_str,
|
||||||
version_pattern=version_pattern,
|
version_pattern=version_pattern,
|
||||||
pep440_version=pep440_version,
|
pep440_version=pep440_version,
|
||||||
|
commit_message=commit_message,
|
||||||
commit=commit,
|
commit=commit,
|
||||||
tag=tag,
|
tag=tag,
|
||||||
push=push,
|
push=push,
|
||||||
|
|
@ -333,6 +340,7 @@ DEFAULT_CONFIGPARSER_BASE_TMPL = """
|
||||||
[pycalver]
|
[pycalver]
|
||||||
current_version = "{initial_version}"
|
current_version = "{initial_version}"
|
||||||
version_pattern = "{{pycalver}}"
|
version_pattern = "{{pycalver}}"
|
||||||
|
commit_message = "bump version to {{new_version}}"
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
push = True
|
push = True
|
||||||
|
|
@ -372,6 +380,7 @@ DEFAULT_TOML_BASE_TMPL = """
|
||||||
[pycalver]
|
[pycalver]
|
||||||
current_version = "{initial_version}"
|
current_version = "{initial_version}"
|
||||||
version_pattern = "{{pycalver}}"
|
version_pattern = "{{pycalver}}"
|
||||||
|
commit_message = "bump version to {{new_version}}"
|
||||||
commit = true
|
commit = true
|
||||||
tag = true
|
tag = true
|
||||||
push = true
|
push = true
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ VCS_SUBCOMMANDS_BY_NAME = {
|
||||||
'ls_tags' : "git tag --list",
|
'ls_tags' : "git tag --list",
|
||||||
'status' : "git status --porcelain",
|
'status' : "git status --porcelain",
|
||||||
'add_path' : "git add --update {path}",
|
'add_path' : "git add --update {path}",
|
||||||
'commit' : "git commit --file {path}",
|
'commit' : "git commit --message '{message}'",
|
||||||
'tag' : "git tag --annotate {tag} --message {tag}",
|
'tag' : "git tag --annotate {tag} --message {tag}",
|
||||||
'push_tag' : "git push origin --follow-tags {tag}",
|
'push_tag' : "git push origin --follow-tags {tag}",
|
||||||
'show_remotes': "git config --get remote.origin.url",
|
'show_remotes': "git config --get remote.origin.url",
|
||||||
|
|
@ -144,20 +144,25 @@ class VCSAPI:
|
||||||
|
|
||||||
def commit(self, message: str) -> None:
|
def commit(self, message: str) -> None:
|
||||||
"""Commit added files."""
|
"""Commit added files."""
|
||||||
message_data = message.encode("utf-8")
|
|
||||||
|
|
||||||
tmp_file = tempfile.NamedTemporaryFile("wb", delete=False)
|
|
||||||
assert " " not in tmp_file.name
|
|
||||||
|
|
||||||
fobj: typ.IO[bytes]
|
|
||||||
|
|
||||||
with tmp_file as fobj:
|
|
||||||
fobj.write(message_data)
|
|
||||||
|
|
||||||
env: Env = os.environ.copy()
|
env: Env = os.environ.copy()
|
||||||
env['HGENCODING'] = "utf-8"
|
|
||||||
self('commit', env=env, path=tmp_file.name)
|
if self.name == 'git':
|
||||||
os.unlink(tmp_file.name)
|
self('commit', env=env, message=message)
|
||||||
|
else:
|
||||||
|
message_data = message.encode("utf-8")
|
||||||
|
tmp_file = tempfile.NamedTemporaryFile("wb", delete=False)
|
||||||
|
try:
|
||||||
|
assert " " not in tmp_file.name
|
||||||
|
|
||||||
|
fobj: typ.IO[bytes]
|
||||||
|
|
||||||
|
with tmp_file as fobj:
|
||||||
|
fobj.write(message_data)
|
||||||
|
|
||||||
|
env['HGENCODING'] = "utf-8"
|
||||||
|
self('commit', env=env, path=tmp_file.name)
|
||||||
|
finally:
|
||||||
|
os.unlink(tmp_file.name)
|
||||||
|
|
||||||
def tag(self, tag_name: str) -> None:
|
def tag(self, tag_name: str) -> None:
|
||||||
"""Create an annotated tag."""
|
"""Create an annotated tag."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue