Skip to content
Merged
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
10 changes: 6 additions & 4 deletions src/hermes/commands/harvest/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import shutil

from hermes.model.context import HermesHarvestContext
from hermes.model.errors import HermesValidationError


_log = logging.getLogger('harvest.git')
Expand Down Expand Up @@ -274,15 +275,16 @@ def harvest_git(click_ctx: click.Context, ctx: HermesHarvestContext):

p = subprocess.run([git_exe, "rev-parse", "--abbrev-ref", "HEAD"], capture_output=True)
if p.returncode:
raise RuntimeError(f"`git branch` command failed with code {p.returncode}: "
f"'{p.stderr.decode(SHELL_ENCODING)}'!")
raise HermesValidationError(f"`git branch` command failed with code {p.returncode}: "
f"'{p.stderr.decode(SHELL_ENCODING).rstrip()}'!")

git_branch = p.stdout.decode(SHELL_ENCODING).strip()
# TODO: should we warn or error if the HEAD is detached?

p = subprocess.run([git_exe, "log", f"--pretty={_GIT_SEP.join(_GIT_FORMAT)}"] + _GIT_ARGS, capture_output=True)
if p.returncode:
raise RuntimeError(f"`git log` command failed with code {p.returncode}: "
f"'{p.stderr.decode(SHELL_ENCODING)}'!")
raise HermesValidationError(f"`git log` command failed with code {p.returncode}: "
f"'{p.stderr.decode(SHELL_ENCODING).rstrip()}'!")

log = p.stdout.decode(SHELL_ENCODING).split('\n')
for line in log:
Expand Down
3 changes: 3 additions & 0 deletions src/hermes/model/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is not None and issubclass(exc_type, HermesValidationError):
exc = traceback.TracebackException(exc_type, exc_val, exc_tb)
self._base.error(self._ep, exc)
self._log.warning("%s: %s",
exc_type,
' '.join(map(str, exc_val.args)))
return True

def update(self, _key: str, _value: t.Any, **kwargs: t.Any):
Expand Down