From 528b2ae39c41581118f2cc27e49e1f7c1e29cb44 Mon Sep 17 00:00:00 2001 From: altsem Date: Sat, 10 Feb 2024 12:43:38 +0100 Subject: [PATCH] refactor: remove unused commit field on Diff --- src/git/diff.rs | 1 - src/git/parse/diff/diff.pest | 2 +- src/git/parse/diff/mod.rs | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/git/diff.rs b/src/git/diff.rs index c1889472d8..28d4430e4c 100644 --- a/src/git/diff.rs +++ b/src/git/diff.rs @@ -4,7 +4,6 @@ use itertools::Itertools; #[derive(Debug, Clone)] pub(crate) struct Diff { - pub commit: Option, pub deltas: Vec, } diff --git a/src/git/parse/diff/diff.pest b/src/git/parse/diff/diff.pest index d7c35518ad..393724055b 100644 --- a/src/git/parse/diff/diff.pest +++ b/src/git/parse/diff/diff.pest @@ -19,6 +19,6 @@ hunk = { hunk_header ~ hunk_body } diff = { diff_header ~ hunk* } -commit = { "commit " ~ to_header } +commit = _{ "commit " ~ to_header } diffs = _{ commit? ~ diff* } diff --git a/src/git/parse/diff/mod.rs b/src/git/parse/diff/mod.rs index caa908f90e..0044b16cd4 100644 --- a/src/git/parse/diff/mod.rs +++ b/src/git/parse/diff/mod.rs @@ -12,18 +12,16 @@ impl FromStr for Diff { type Err = pest::error::Error; fn from_str(s: &str) -> Result { - 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 }) } }