fix: prefer valid position for comment line fallback
This commit is contained in:
+16
-1
@@ -197,12 +197,27 @@ fn to_commit_item(commit: CommitDto) -> CommitItem {
|
||||
}
|
||||
|
||||
fn to_comment_item(comment: ReviewCommentDto) -> CommentItem {
|
||||
let line = if let Some(value) = comment.line.filter(|value| *value > 0) {
|
||||
Some(value)
|
||||
} else if let Some(value) = comment
|
||||
.position
|
||||
.filter(|value| *value > 0)
|
||||
.and_then(|value| i64::try_from(value).ok())
|
||||
{
|
||||
Some(value)
|
||||
} else {
|
||||
comment
|
||||
.original_position
|
||||
.filter(|value| *value > 0)
|
||||
.and_then(|value| i64::try_from(value).ok())
|
||||
};
|
||||
|
||||
CommentItem {
|
||||
id: comment.id,
|
||||
user: comment.user.login,
|
||||
created_at: comment.created_at,
|
||||
path: comment.path,
|
||||
line: comment.line,
|
||||
line,
|
||||
body: comment.body,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user