From 564886b165a72d06668672d9e3da99023d687c5b Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Wed, 22 Mar 2023 17:40:35 +0100 Subject: [PATCH] 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 --- radicle-httpd/src/api/v1/projects.rs | 6 ++++-- radicle/src/cob/patch.rs | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/radicle-httpd/src/api/v1/projects.rs b/radicle-httpd/src/api/v1/projects.rs index ff6a7e31..2fcc7ad3 100644 --- a/radicle-httpd/src/api/v1/projects.rs +++ b/radicle-httpd/src/api/v1/projects.rs @@ -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, diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index 522f20bc..a12f36e8 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -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, + )) } }