Skip to content

Commit

Permalink
surf: Add FileDiff::path method
Browse files Browse the repository at this point in the history
This allows to get the latest path of a `FileDiff`, directly from
`radicle_surf`

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
  • Loading branch information
sebastinez committed Jul 24, 2023
1 parent f9360d8 commit 7a408cc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions radicle-surf/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ pub enum FileDiff {
Copied(Copied),
}

impl FileDiff {
pub fn path(&self) -> &PathBuf {
match self {
FileDiff::Added(x) => &x.path,
FileDiff::Deleted(x) => &x.path,
FileDiff::Modified(x) => &x.path,
FileDiff::Moved(x) => &x.new_path,
FileDiff::Copied(x) => &x.new_path,
}
}
}

#[cfg(feature = "serde")]
impl Serialize for FileDiff {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand Down

0 comments on commit 7a408cc

Please sign in to comment.