Skip to content

Commit

Permalink
GitSCM.apply_patch: raise specific exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
shtrom committed Jan 10, 2025
1 parent 7aa0327 commit 8411436
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lando/main/scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
from simple_github import AppAuth, AppInstallationAuth

from lando.main.scm.consts import SCM_TYPE_GIT
from lando.main.scm.exceptions import SCMException
from lando.main.scm.exceptions import (
PatchConflict,
SCMException,
)
from lando.settings import LANDO_USER_EMAIL, LANDO_USER_NAME

from .abstract_scm import AbstractSCM
Expand Down Expand Up @@ -177,7 +180,11 @@ def apply_patch(
]

for c in cmds:
self._git_run(*c, cwd=self.path)
try:
self._git_run(*c, cwd=self.path)
except SCMException as exc:
if "patch does not apply" in exc.err:
raise PatchConflict(exc.err) from exc

@contextmanager
def for_pull(self) -> ContextManager:
Expand Down

0 comments on commit 8411436

Please sign in to comment.