Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions src/git/diff_tree_to_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::git::status::MAX_PATHSPEC_ARGS;
use std::collections::HashSet;
use std::path::{Path, PathBuf};

#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DiffStatus {
Added,
Expand Down Expand Up @@ -32,7 +31,6 @@ impl DiffStatus {
}
}

#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct DiffFile {
path: Option<PathBuf>,
Expand All @@ -45,18 +43,15 @@ impl DiffFile {
self.path.as_deref()
}

#[allow(dead_code)]
pub fn mode(&self) -> &str {
&self.mode
}

#[allow(dead_code)]
pub fn id(&self) -> &str {
&self.oid
}
}

#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct DiffDelta {
status: DiffStatus,
Expand All @@ -75,15 +70,9 @@ impl DiffDelta {
&self.new_file
}

#[allow(dead_code)]
pub fn status(&self) -> DiffStatus {
self.status
}

#[allow(dead_code)]
pub fn similarity(&self) -> u32 {
self.similarity
}
}

pub struct Diff {
Expand All @@ -95,12 +84,10 @@ impl Diff {
self.deltas.iter()
}

#[allow(dead_code)]
pub fn len(&self) -> usize {
self.deltas.len()
}

#[allow(dead_code)]
pub fn is_empty(&self) -> bool {
self.deltas.is_empty()
}
Expand Down Expand Up @@ -273,15 +260,7 @@ fn parse_diff_raw(data: &[u8]) -> Result<Vec<DiffDelta>, GitAiError> {
// Construct the old_file and new_file
let old_file = DiffFile {
path: old_path
.or_else(|| {
// For deletions, the old file path is the path
#[allow(clippy::if_same_then_else)]
if matches!(status, DiffStatus::Deleted) {
Some(new_path.clone())
} else {
Some(new_path.clone())
}
})
.or_else(|| Some(new_path.clone()))
.map(PathBuf::from),
mode: old_mode.to_string(),
oid: old_hash.to_string(),
Expand Down
Loading