mirror of
https://github.com/openSUSE/osc.git
synced 2025-11-24 05:48:53 +01:00
Introduce GitObsRuntimeError exception and use it where appropriate
This commit is contained in:
@@ -146,7 +146,7 @@ class PullRequestCreateCommand(osc.commandline_git.GitObsCommand):
|
||||
message = message.strip()
|
||||
|
||||
if not message:
|
||||
raise RuntimeError("Aborting operation due to empty title and description.")
|
||||
raise gitea_api.GitObsRuntimeError("Aborting operation due to empty title and description.")
|
||||
|
||||
parts = re.split(r"\n\n", message, 1)
|
||||
if len(parts) == 1:
|
||||
|
||||
@@ -5,6 +5,7 @@ from .exceptions import BranchDoesNotExist
|
||||
from .exceptions import BranchExists
|
||||
from .exceptions import ForkExists
|
||||
from .exceptions import GiteaException
|
||||
from .exceptions import GitObsRuntimeError
|
||||
from .exceptions import RepoExists
|
||||
from .exceptions import UserDoesNotExist
|
||||
from .exceptions import response_to_exception
|
||||
|
||||
@@ -60,6 +60,7 @@ class GiteaModel:
|
||||
def get_editor() -> List[str]:
|
||||
import shutil
|
||||
import shlex
|
||||
from .exceptions import GitObsRuntimeError
|
||||
|
||||
editor = os.getenv("EDITOR", None)
|
||||
if editor:
|
||||
@@ -80,7 +81,7 @@ def get_editor() -> List[str]:
|
||||
break
|
||||
|
||||
if not editor_path:
|
||||
raise RuntimeError(f"Unable to start editor '{candidates[0]}'")
|
||||
raise GitObsRuntimeError(f"Unable to start editor '{candidates[0]}'")
|
||||
|
||||
res = [editor_path]
|
||||
if args:
|
||||
|
||||
@@ -61,6 +61,10 @@ class GiteaException(oscerr.OscBaseError):
|
||||
return result
|
||||
|
||||
|
||||
class GitObsRuntimeError(oscerr.OscBaseError):
|
||||
pass
|
||||
|
||||
|
||||
class MovedPermanently(GiteaException):
|
||||
RESPONSE_STATUS = 301
|
||||
RESPONSE_MESSAGE_RE = [
|
||||
|
||||
@@ -552,10 +552,12 @@ class PullRequest(GiteaModel):
|
||||
"""
|
||||
Approve review in a pull request.
|
||||
"""
|
||||
from .exceptions import GitObsRuntimeError
|
||||
|
||||
if commit:
|
||||
pr_obj = cls.get(conn, owner, repo, number)
|
||||
if pr_obj.head_commit != commit:
|
||||
raise RuntimeError("The pull request '{owner}/{repo}#{number}' has changed during the review")
|
||||
raise GitObsRuntimeError("The pull request '{owner}/{repo}#{number}' has changed during the review")
|
||||
|
||||
if reviewer:
|
||||
# group review bot is controlled via messages in comments
|
||||
|
||||
Reference in New Issue
Block a user