Skip to content

Commit

Permalink
refactor: remove unused commit field on Diff
Browse files Browse the repository at this point in the history
  • Loading branch information
altsem committed Feb 10, 2024
1 parent 9c1b63c commit 528b2ae
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/git/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use itertools::Itertools;

#[derive(Debug, Clone)]
pub(crate) struct Diff {
pub commit: Option<String>,
pub deltas: Vec<Delta>,
}

Expand Down
2 changes: 1 addition & 1 deletion src/git/parse/diff/diff.pest
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ hunk = { hunk_header ~ hunk_body }

diff = { diff_header ~ hunk* }

commit = { "commit " ~ to_header }
commit = _{ "commit " ~ to_header }

diffs = _{ commit? ~ diff* }
4 changes: 1 addition & 3 deletions src/git/parse/diff/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@ impl FromStr for Diff {
type Err = pest::error::Error<Rule>;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut commit = None;
let mut deltas = vec![];

for diff in DiffParser::parse(Rule::diffs, s)? {
match diff.as_rule() {
Rule::commit => commit = Some(diff.as_str().to_string()),
Rule::diff => deltas.push(parse_diff(diff)),
rule => panic!("No rule {:?}", rule),
}
}

Ok(Self { commit, deltas })
Ok(Self { deltas })
}
}

Expand Down

0 comments on commit 528b2ae

Please sign in to comment.