|
24 | 24 | # |
25 | 25 |
|
26 | 26 | # stdlib |
| 27 | +from datetime import date |
27 | 28 | from functools import partial |
28 | 29 | from types import MethodType |
29 | 30 | from typing import Callable, Dict, List, Optional, Tuple, cast |
@@ -209,6 +210,20 @@ def patch(self, commit: Optional[bool], message: str): |
209 | 210 | ) |
210 | 211 | self.bump(new_version, commit, message) |
211 | 212 |
|
| 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 | + |
212 | 227 | def bump(self, new_version: Version, commit: Optional[bool], message: str): |
213 | 228 | r""" |
214 | 229 | Bump to the given version. |
@@ -332,3 +347,15 @@ def patch(commit: Optional[bool], message: str, force: bool) -> int: |
332 | 347 | bumper = Bumper(PathPlus.cwd(), force) |
333 | 348 | bumper.patch(commit, message) |
334 | 349 | 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