diff --git a/bumpversion/exceptions.py b/bumpversion/exceptions.py index 73f51479..f95aacff 100644 --- a/bumpversion/exceptions.py +++ b/bumpversion/exceptions.py @@ -30,3 +30,8 @@ class VersionNotFoundException(BumpVersionException): class InvalidVersionPartException(BumpVersionException): """The specified part (e.g. 'bugfix') was not found""" + + +class TaggingFailureException(BumpVersionException): + def __init__(self, message): + self.message = message diff --git a/bumpversion/vcs.py b/bumpversion/vcs.py index 0a016a67..9b38e3ef 100644 --- a/bumpversion/vcs.py +++ b/bumpversion/vcs.py @@ -7,6 +7,7 @@ from bumpversion.exceptions import ( WorkingDirectoryIsDirtyException, MercurialDoesNotSupportSignedTagsException, + TaggingFailureException, ) @@ -135,7 +136,10 @@ def tag(cls, sign, name, message): command += ["--sign"] if message: command += ["--message", message] - subprocess.check_output(command) + try: + subprocess.check_output(command, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + raise TaggingFailureException(f"{e.returncode} {e.output.decode()}") class Mercurial(BaseVCS): @@ -175,4 +179,7 @@ def tag(cls, sign, name, message): ) if message: command += ["--message", message] - subprocess.check_output(command) + try: + subprocess.check_output(command, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + raise TaggingFailureException(f"{e.returncode} {e.output.decode()}")