fast-dev-cli 0.25.2__tar.gz → 0.25.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.25.2
3
+ Version: 0.25.3
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -0,0 +1 @@
1
+ __version__ = "0.25.3"
@@ -593,6 +593,29 @@ class BumpUp(DryRun):
593
593
  echo(f"Invalid part: {s!r}")
594
594
  raise Exit(1) from e
595
595
 
596
+ @staticmethod
597
+ def parse_new_version(part: str, version: str) -> str:
598
+ version_parts = version.split(".")
599
+ if not version_parts[-1].isdigit():
600
+ try:
601
+ p1, p2, p3 = version_parts[:3]
602
+ p2i = int(p2)
603
+ p1i = int(p1)
604
+ except ValueError:
605
+ ...
606
+ else:
607
+ match part:
608
+ case "patch":
609
+ p3i = int(m.group()) if (m := re.match(r"\d+", p3)) else 0
610
+ if len(version_parts) == 3:
611
+ p3i += 1
612
+ return f"{p1}.{p2}.{p3i}"
613
+ case "minor":
614
+ return f"{p1}.{p2i + 1}.0"
615
+ case "major":
616
+ return f"{p1i + 1}.0.0"
617
+ return ""
618
+
596
619
  def gen(self) -> str:
597
620
  should_sync, _version = get_current_version(check_version=True)
598
621
  filename = self.filename
@@ -606,9 +629,10 @@ class BumpUp(DryRun):
606
629
  self.part = part
607
630
  parse = r'--parse "(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)"'
608
631
  filename_arg = _quote_shell_arg(filename)
609
- cmd = (
610
- f'bumpversion {parse} --current-version="{_version}" {part} {filename_arg}'
611
- )
632
+ cmd = f'bumpversion {parse} --current-version="{_version}" '
633
+ if new_version := self.parse_new_version(part, _version):
634
+ cmd += f'--new-version="{new_version}" '
635
+ cmd += f"{part} {filename_arg}"
612
636
  if self.commit:
613
637
  if part != "patch":
614
638
  cmd += " --tag"
@@ -674,15 +698,13 @@ def version() -> None:
674
698
  @cli.command(name="bump")
675
699
  def bump_version(
676
700
  part: BumpUp.PartChoices,
701
+ sync: bool = False,
677
702
  commit: bool = Option(
678
703
  False, "--commit", "-c", help="Whether run `git commit` after version changed"
679
704
  ),
680
705
  emoji: bool | None = Option(
681
706
  None, "--emoji", help="Whether add emoji prefix to commit message"
682
707
  ),
683
- no_sync: bool = Option(
684
- False, "--no-sync", help="Do not run sync command to update version"
685
- ),
686
708
  dry: bool = DryOption,
687
709
  ) -> None:
688
710
  """Bump up version string in pyproject.toml"""
@@ -691,7 +713,7 @@ def bump_version(
691
713
  return BumpUp(
692
714
  _ensure_bool(commit),
693
715
  getattr(part, "value", part),
694
- no_sync=_ensure_bool(no_sync),
716
+ no_sync=not _ensure_bool(sync),
695
717
  emoji=emoji,
696
718
  dry=dry,
697
719
  ).run()
@@ -29,7 +29,7 @@ dependencies = [
29
29
  "typer>=0.24.0,<1",
30
30
  "tomli >=2.0.1,<3; python_version < '3.11'",
31
31
  ]
32
- version = "0.25.2"
32
+ version = "0.25.3"
33
33
 
34
34
  [project.urls]
35
35
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -1 +0,0 @@
1
- __version__ = "0.25.2"
File without changes
File without changes