mirror of
https://github.com/karma-riuk/crab.git
synced 2025-07-04 21:28:12 +02:00
added another point of failure
This commit is contained in:
@ -17,6 +17,12 @@ class NoLinesForCommentError(SetupException):
|
|||||||
reason_for_failure = "There are no line reference for the comment"
|
reason_for_failure = "There are no line reference for the comment"
|
||||||
|
|
||||||
|
|
||||||
|
class CommentedFileNotInOriginalChanges(SetupException):
|
||||||
|
reason_for_failure = (
|
||||||
|
"Commented file is not part of the original PR (most like due to a merge of another branch)"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CantCloneRepoError(SetupException):
|
class CantCloneRepoError(SetupException):
|
||||||
reason_for_failure = "Couldn't clone the repository"
|
reason_for_failure = "Couldn't clone the repository"
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ from errors import (
|
|||||||
CantCheckoutCommitError,
|
CantCheckoutCommitError,
|
||||||
CantEnsureFullHistoryError,
|
CantEnsureFullHistoryError,
|
||||||
CantFetchPRError,
|
CantFetchPRError,
|
||||||
|
CommentedFileNotInOriginalChanges,
|
||||||
MultipleFilesError,
|
MultipleFilesError,
|
||||||
NoDiffsAfterError,
|
NoDiffsAfterError,
|
||||||
NoDiffsBeforeError,
|
NoDiffsBeforeError,
|
||||||
@ -185,7 +186,10 @@ def get_files(pr: PullRequest, repo: Repository, repo_path: str) -> dict[str, Fi
|
|||||||
|
|
||||||
def get_comments(pr: PullRequest) -> list[Comment]:
|
def get_comments(pr: PullRequest) -> list[Comment]:
|
||||||
ret = []
|
ret = []
|
||||||
|
filenames = {file.filename for file in pr.get_files()}
|
||||||
for comment in pr.get_review_comments():
|
for comment in pr.get_review_comments():
|
||||||
|
if comment.path not in filenames:
|
||||||
|
raise CommentedFileNotInOriginalChanges(f"File {comment.path} not in {filenames}")
|
||||||
if (
|
if (
|
||||||
comment.start_line is None
|
comment.start_line is None
|
||||||
and comment.original_start_line is None
|
and comment.original_start_line is None
|
||||||
|
Reference in New Issue
Block a user