Skip to content

Commit 4435e31

Browse files
committed
feat: support --commit for nox bump
1 parent eae241a commit 4435e31

File tree

4 files changed

+56
-18
lines changed

4 files changed

+56
-18
lines changed

docs/update_cmake_version.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If using nox, run::
1717
nox -s bump -- <version>
1818

1919

20-
And follow the instructions it gives you. Leave off the version to bump to the latest version.
20+
And follow the instructions it gives you. Leave off the version to bump to the latest version. Add `--commit` to run the commit procedure.
2121

2222
Classic procedure:
2323
------------------
@@ -48,7 +48,7 @@ Classic procedure:
4848

4949
release=3.20.4
5050
git switch -c update-to-cmake-$release
51-
git add CMakeUrls.cmake docs/index.rst README.rst tests/test_distribution.py docs/update_cmake_version.rst
51+
git add -u CMakeUrls.cmake docs/index.rst README.rst tests/test_distribution.py docs/update_cmake_version.rst
5252
git commit -m "Update to CMake $release"
5353

5454
4. Push the topic and create a `Pull Request`.

noxfile.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
import argparse
23
from pathlib import Path
34

45
import nox
@@ -79,12 +80,45 @@ def bump(session: nox.Session) -> None:
7980
"""
8081
Set to a new version, use -- <version>, otherwise will use the latest version.
8182
"""
82-
if session.posargs:
83-
(version,) = session.posargs
84-
else:
83+
parser = argparse.ArgumentParser(description="Process some integers.")
84+
parser.add_argument(
85+
"--commit", action="store_true", help="Make a branch and commit."
86+
)
87+
parser.add_argument(
88+
"version", nargs="?", help="The version to process - leave off for latest."
89+
)
90+
args = parser.parse_args(session.posargs)
91+
92+
if args.version is None:
8593
session.install("lastversion")
8694
version = session.run(
8795
"lastversion", "kitware/cmake", log=False, silent=True
8896
).strip()
97+
else:
98+
version = args.version
99+
89100
session.install("requests")
90-
session.run("python", "scripts/update_cmake_version.py", version)
101+
102+
extra = [] if args.commit else ["--quiet"]
103+
session.run("python", "scripts/update_cmake_version.py", version, *extra)
104+
105+
if args.commit:
106+
session.run("git", "switch", "-c", f"update-to-cmake-{version}", external=True)
107+
files = (
108+
"CMakeUrls.cmake",
109+
"docs/index.rst",
110+
"README.rst",
111+
"tests/test_distribution.py",
112+
"docs/update_cmake_version.rst",
113+
)
114+
session.run(
115+
"git",
116+
"add",
117+
"-u",
118+
*files,
119+
external=True,
120+
)
121+
session.run("git", "commit", "-m", f"Update to CMake {version}", external=True)
122+
session.log(
123+
'Complete! Now run: gh pr create --fill --body "Created by update_cmake_version.py"'
124+
)

scripts/update_cmake_version.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ def main():
207207
action="store_true",
208208
help="If specified, only display the archive URLs and associated hashsums",
209209
)
210+
parser.add_argument(
211+
"--quiet",
212+
action="store_true",
213+
help="Hide the output",
214+
)
210215
args = parser.parse_args()
211216
if args.collect_only:
212217
get_cmake_archive_urls_and_sha256s(args.cmake_version, verbose=True)
@@ -216,17 +221,16 @@ def main():
216221
update_tests(args.cmake_version)
217222
update_raw_versions(args.cmake_version)
218223

219-
print(
220-
"""Complete! Now run:
224+
if not args.quiet:
225+
msg = """\
226+
Complete! Now run:
221227
222-
git switch -c update-to-cmake-{release}
223-
git add CMakeUrls.cmake docs/index.rst README.rst tests/test_distribution.py docs/update_cmake_version.rst
224-
git commit -m "Update to CMake {release}"
225-
gh pr create --fill --body "Created by update_cmake_version.py"
226-
""".format(
227-
release=args.cmake_version
228-
)
229-
)
228+
git switch -c update-to-cmake-{release}
229+
git add -u CMakeUrls.cmake docs/index.rst README.rst tests/test_distribution.py docs/update_cmake_version.rst
230+
git commit -m "Update to CMake {release}"
231+
gh pr create --fill --body "Created by update_cmake_version.py"
232+
"""
233+
print(textwrap.dedent(msg.format(release=args.cmake_version)))
230234

231235

232236
if __name__ == "__main__":

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[flake8]
2-
max-line-length: 120
2+
max-line-length: 130
33
# Whether to display the pep8 instructions on failure (can be quite verbose)
44
show-pep8: False
55
# Whether to show source code for each failure
66
show-source: True
77
# Maximum cyclomatic complexity allowed
88
max-complexity: 14
99
format: pylint
10-
exclude: .git,.idea,.eggs,__pycache__,.tox,docs/conf.py,_skbuild,CMake-src,versioneer.py,_version.py,.venv,.nox,noxfile.py
10+
exclude: .git,.idea,.eggs,__pycache__,.tox,docs/conf.py,_skbuild,CMake-src,versioneer.py,_version.py,.venv,.nox
1111

1212
[tool:pytest]
1313
testpaths = tests

0 commit comments

Comments
 (0)