httpd: Add `path` property to `CodeLocation`

For the web client to be able to show file we need to provide
the web client with the file path.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez 2023-03-22 17:40:35 +01:00
parent 00ea587c6d
commit 564886b165
No known key found for this signature in database
2 changed files with 21 additions and 8 deletions

View File

@ -2089,7 +2089,8 @@ mod routes {
"inline": [
{
"location": {
"blob": HEAD,
"blob": "82eb77880c693655bce074e3dbbd9fa711dc018b",
"path": "./README.md",
"commit": HEAD,
"lines": {
"start": 1,
@ -2148,7 +2149,8 @@ mod routes {
"inline": [
{
"location": {
"blob": HEAD,
"blob": "82eb77880c693655bce074e3dbbd9fa711dc018b",
"path": "./README.md",
"commit": HEAD,
"lines": {
"start": 1,

View File

@ -2,6 +2,7 @@
use std::fmt;
use std::ops::Deref;
use std::ops::Range;
use std::path::PathBuf;
use std::str::FromStr;
use once_cell::sync::Lazy;
@ -466,6 +467,8 @@ impl fmt::Display for Verdict {
pub struct CodeLocation {
/// File being commented on.
pub blob: git::Oid,
/// Path of file being commented on.
pub path: PathBuf,
/// Commit commented on.
pub commit: git::Oid,
/// Line range commented on.
@ -480,12 +483,20 @@ impl PartialOrd for CodeLocation {
impl Ord for CodeLocation {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
(&self.blob, &self.commit, &self.lines.start, &self.lines.end).cmp(&(
&other.blob,
&other.commit,
&other.lines.start,
&other.lines.end,
))
(
&self.blob,
&self.path,
&self.commit,
&self.lines.start,
&self.lines.end,
)
.cmp(&(
&other.blob,
&other.path,
&other.commit,
&other.lines.start,
&other.lines.end,
))
}
}