-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/default/prepare-0.1.0' into 'branch/default'
Topic/default/prepare 0.1.0 See merge request fluiddyn/hg-setup!4
- Loading branch information
Showing
6 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Release notes | ||
|
||
0.1.0 is being prepared! | ||
## 0.1.0 (2024/12/17) | ||
|
||
- commands `hg-setup init` and `hg-setup init-shell-completion`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ test: | |
|
||
cov_html: test | ||
pdm run coverage html | ||
|
||
format-md: | ||
mdformat *.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"""Nox file for hg-setup | ||
```sh | ||
nox -l | ||
nox -s add-tag-for-release | ||
``` | ||
""" | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
import nox | ||
|
||
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"}) | ||
nox.options.reuse_existing_virtualenvs = 1 | ||
|
||
def _get_version_from_pyproject(path=Path.cwd()): | ||
if isinstance(path, str): | ||
path = Path(path) | ||
|
||
if not path.name == "pyproject.toml": | ||
path /= "pyproject.toml" | ||
|
||
in_project = False | ||
version = None | ||
with open(path, encoding="utf-8") as file: | ||
for line in file: | ||
if line.startswith("[project]"): | ||
in_project = True | ||
if line.startswith("version =") and in_project: | ||
version = line.split("=")[1].strip() | ||
version = version[1:-1] | ||
break | ||
|
||
assert version is not None | ||
return version | ||
|
||
|
||
@nox.session(name="add-tag-for-release", venv_backend="none") | ||
def add_tag_for_release(session): | ||
session.run("hg", "pull", external=True) | ||
|
||
result = session.run( | ||
*"hg log -r default -G".split(), external=True, silent=True | ||
) | ||
if result[0] != "@": | ||
session.run("hg", "update", "default", external=True) | ||
|
||
version = _get_version_from_pyproject() | ||
print(f"{version = }") | ||
|
||
result = session.run("hg", "tags", "-T", "{tag},", external=True, silent=True) | ||
last_tag = result.split(",", 2)[1] | ||
print(f"{last_tag = }") | ||
|
||
if last_tag == version: | ||
session.error("last_tag == version") | ||
|
||
answer = input( | ||
f'Do you really want to add and push the new tag "{version}"? (yes/[no]) ' | ||
) | ||
|
||
if answer != "yes": | ||
print("Maybe next time then. Bye!") | ||
return | ||
|
||
print("Let's go!") | ||
session.run("hg", "tag", version, external=True) | ||
session.run("hg", "push", external=True) |