From d35678f0c7180c040fb47d6dfdac364a611ab8e9 Mon Sep 17 00:00:00 2001 From: Michael Everingham Date: Fri, 6 Jan 2023 21:17:01 -0500 Subject: [PATCH] Raise exception with error output if CalledProcessError when tagging. --- bumpversion/exceptions.py | 5 +++++ bumpversion/vcs.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) 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()}")