Skip to content

Commit b70ed1d

Browse files
committed
release: Add support for calver
1 parent 1f120fd commit b70ed1d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

repo_helper/cli/commands/release.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#
2525

2626
# stdlib
27+
from datetime import date
2728
from functools import partial
2829
from types import MethodType
2930
from typing import Callable, Dict, List, Optional, Tuple, cast
@@ -209,6 +210,20 @@ def patch(self, commit: Optional[bool], message: str):
209210
)
210211
self.bump(new_version, commit, message)
211212

213+
def today(self, commit: Optional[bool], message: str):
214+
"""
215+
Bump to the calver version for today's date.
216+
217+
E.g. 2020.12.25 for 25th December 2020
218+
219+
:param commit: Whether to commit automatically (:py:obj:`True`) or ask first (:py:obj:`None`).
220+
:param message: The commit message.
221+
"""
222+
223+
today = date.today()
224+
new_version = Version(today.year, today.month, today.day)
225+
self.bump(new_version, commit, message)
226+
212227
def bump(self, new_version: Version, commit: Optional[bool], message: str):
213228
r"""
214229
Bump to the given version.
@@ -332,3 +347,15 @@ def patch(commit: Optional[bool], message: str, force: bool) -> int:
332347
bumper = Bumper(PathPlus.cwd(), force)
333348
bumper.patch(commit, message)
334349
return 0
350+
351+
352+
@release_options
353+
@release_command()
354+
def today(commit: Optional[bool], message: str, force: bool) -> int:
355+
"""
356+
Bump to the calver version for today's date (e.g. 2020.12.25).
357+
"""
358+
359+
bumper = Bumper(PathPlus.cwd(), force)
360+
bumper.today(commit, message)
361+
return 0

0 commit comments

Comments
 (0)