Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version bump and tag #82

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/ctl/plugins/semver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ def tag(self, version, repo, prerelease=None, **kwargs):
raise UsageError("Currently checked out branch is not clean")

version = semver.VersionInfo.parse(version)

if prerelease:
version = version.bump_prerelease(prerelease)

Expand All @@ -125,7 +124,9 @@ def tag(self, version, repo, prerelease=None, **kwargs):
repo_plugin.commit(files=files, message=f"Version {version_tag}", push=True)
nogit = kwargs.pop("nogit", False)
if not nogit:
repo_plugin.tag(version_tag, message=version_tag, push=True)
prefix = kwargs.pop("prefix", None)
version_tag = f"{prefix}{version_tag}" if prefix else version_tag
repo_plugin.tag(version_tag, message=version_tag, push=True, prefix=prefix)

@expose("ctl.{plugin_name}.bump")
def bump(self, version, repo, **kwargs):
Expand Down Expand Up @@ -166,7 +167,9 @@ def bump(self, version, repo, **kwargs):

self.log.info(f"Bumping semantic version: {current} to {new_version}")

self.tag(version=str(new_version), repo=repo, **kwargs)
do_tag = kwargs.pop("do_tag", True)
if do_tag:
self.tag(version=str(new_version), repo=repo, **kwargs)

@expose("ctl.{plugin_name}.release")
def release(self, repo, **kwargs):
Expand Down
10 changes: 9 additions & 1 deletion tests/test_plugin_semver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def test_tag(tmpdir, ctlr):
assert dummy_repo.version == "1.0.3"
assert not dummy_repo.has_tag("1.0.3")

plugin.tag(version="1.0.4", repo="dummy_repo", prefix="v")
assert dummy_repo.version == "1.0.4"
assert dummy_repo.has_tag("v1.0.4")


def test_tag_prerelease(tmpdir, ctlr):
plugin, dummy_repo = instantiate(tmpdir, ctlr)
Expand All @@ -60,7 +64,7 @@ def test_tag_pyproject(tmpdir, ctlr):

plugin.tag(version="2.0.0", repo="dummy_repo", prerelease="rc")

with open(pyproject_path, "r") as f:
with open(pyproject_path) as f:
pyproject = tomlkit.load(f)
assert pyproject["tool"]["poetry"]["version"] == "2.0.0-rc.1"

Expand All @@ -86,6 +90,10 @@ def test_bump(tmpdir, ctlr):
assert dummy_repo.version == "2.0.1"
assert not dummy_repo.has_tag("2.0.1")

plugin.bump(version="patch", repo="dummy_repo", do_tag=False)
assert dummy_repo.version == "2.0.1"
assert not dummy_repo.has_tag("2.0.2")


def test_bump_w_prerelease_flag(tmpdir, ctlr):
plugin, dummy_repo = instantiate(tmpdir, ctlr)
Expand Down