Update `radicle-surf` to v0.17
This commit introduces the `FileStats` struct, that adds the insertions and deletions for each file to `DiffContent`. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
parent
9a1a216f70
commit
504a198cec
|
|
@ -2031,9 +2031,9 @@ checksum = "db20136bbc9ae63f3fec8e5a6c369f4902fac2244501b5dfc6d668e43475aaa4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "radicle-surf"
|
name = "radicle-surf"
|
||||||
version = "0.16.0"
|
version = "0.17.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bfc319f555a7cbf938ba4eecb06bd6edcdccce339b20a6b8d8a3af3e92e9f7b7"
|
checksum = "c8af2d4285e9f326da30ba25e2642b0644ec4b8e36c7243380b01dfb1a15e239"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.13.1",
|
"base64 0.13.1",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ nonempty = { version = "0.8" }
|
||||||
# N.b. this is required to use macros, even though it's re-exported
|
# N.b. this is required to use macros, even though it's re-exported
|
||||||
# through radicle
|
# through radicle
|
||||||
radicle-git-ext = { version = "0.6.0", features = ["serde"] }
|
radicle-git-ext = { version = "0.6.0", features = ["serde"] }
|
||||||
radicle-surf = { version = "0.16.0" }
|
radicle-surf = { version = "0.17.0" }
|
||||||
serde = { version = "1.0" }
|
serde = { version = "1.0" }
|
||||||
serde_json = { version = "1" }
|
serde_json = { version = "1" }
|
||||||
serde_yaml = { version = "0.8" }
|
serde_yaml = { version = "0.8" }
|
||||||
|
|
|
||||||
|
|
@ -165,26 +165,13 @@ impl ToPretty for DiffContent {
|
||||||
Some((f.old.oid, f.new_path.clone())),
|
Some((f.old.oid, f.new_path.clone())),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut header = header.pretty(hi, &(), repo);
|
let mut header = header.pretty(hi, &(), repo);
|
||||||
let mut additions = 0;
|
|
||||||
let mut deletions = 0;
|
|
||||||
|
|
||||||
match self {
|
let (additions, deletions) = if let Some(stats) = self.stats() {
|
||||||
DiffContent::Plain { hunks, .. } => {
|
(stats.additions, stats.deletions)
|
||||||
for h in hunks.iter() {
|
} else {
|
||||||
for l in &h.lines {
|
(0, 0)
|
||||||
match l {
|
};
|
||||||
Modification::Addition(_) => additions += 1,
|
|
||||||
Modification::Deletion(_) => deletions += 1,
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DiffContent::Empty => {}
|
|
||||||
DiffContent::Binary => {}
|
|
||||||
}
|
|
||||||
if deletions > 0 {
|
if deletions > 0 {
|
||||||
header.push(term::label(format!(" -{deletions}")).fg(theme.color("negative.light")));
|
header.push(term::label(format!(" -{deletions}")).fg(theme.color("negative.light")));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use std::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use radicle_surf::diff::FileStats;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use radicle::git;
|
use radicle::git;
|
||||||
|
|
@ -203,8 +204,17 @@ impl Encode for Diff {
|
||||||
impl Decode for DiffContent {
|
impl Decode for DiffContent {
|
||||||
fn decode(r: &mut impl io::BufRead) -> Result<Self, Error> {
|
fn decode(r: &mut impl io::BufRead) -> Result<Self, Error> {
|
||||||
let mut hunks = Vec::default();
|
let mut hunks = Vec::default();
|
||||||
|
let mut additions = 0;
|
||||||
|
let mut deletions = 0;
|
||||||
|
|
||||||
while let Some(h) = Hunk::<_>::try_decode(r)? {
|
while let Some(h) = Hunk::try_decode(r)? {
|
||||||
|
for l in &h.lines {
|
||||||
|
match l {
|
||||||
|
Modification::Addition(_) => additions += 1,
|
||||||
|
Modification::Deletion(_) => deletions += 1,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
hunks.push(h);
|
hunks.push(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,6 +224,10 @@ impl Decode for DiffContent {
|
||||||
// TODO: Handle case for binary.
|
// TODO: Handle case for binary.
|
||||||
Ok(DiffContent::Plain {
|
Ok(DiffContent::Plain {
|
||||||
hunks: Hunks::from(hunks),
|
hunks: Hunks::from(hunks),
|
||||||
|
stats: FileStats {
|
||||||
|
additions,
|
||||||
|
deletions,
|
||||||
|
},
|
||||||
// TODO: Properly handle EndOfLine field
|
// TODO: Properly handle EndOfLine field
|
||||||
eof: diff::EofNewLine::NoneMissing,
|
eof: diff::EofNewLine::NoneMissing,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ hyper = { version = "0.14.17", default-features = false }
|
||||||
lexopt = { version = "0.2.1" }
|
lexopt = { version = "0.2.1" }
|
||||||
lru = { version = "0.11.0" }
|
lru = { version = "0.11.0" }
|
||||||
nonempty = { version = "0.8.1", features = ["serialize"] }
|
nonempty = { version = "0.8.1", features = ["serialize"] }
|
||||||
radicle-surf = { version = "0.16.0", default-features = false, features = ["serde"] }
|
radicle-surf = { version = "0.17.0", default-features = false, features = ["serde"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = { version = "1", features = ["preserve_order"] }
|
serde_json = { version = "1", features = ["preserve_order"] }
|
||||||
thiserror = { version = "1" }
|
thiserror = { version = "1" }
|
||||||
|
|
|
||||||
|
|
@ -1187,6 +1187,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 1,
|
||||||
|
"deletions": 0,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"new": {
|
"new": {
|
||||||
|
|
@ -1218,6 +1222,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 1,
|
||||||
|
"deletions": 0,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"new": {
|
"new": {
|
||||||
|
|
@ -1251,6 +1259,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 0,
|
||||||
|
"deletions": 1,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"old": {
|
"old": {
|
||||||
|
|
@ -1316,6 +1328,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 1,
|
||||||
|
"deletions": 0,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"new": {
|
"new": {
|
||||||
|
|
@ -1349,6 +1365,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 0,
|
||||||
|
"deletions": 1,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"old": {
|
"old": {
|
||||||
|
|
@ -1412,6 +1432,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 1,
|
||||||
|
"deletions": 0,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"new": {
|
"new": {
|
||||||
|
|
@ -1497,6 +1521,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 1,
|
||||||
|
"deletions": 0,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"new": {
|
"new": {
|
||||||
|
|
@ -1528,6 +1556,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 1,
|
||||||
|
"deletions": 0,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"new": {
|
"new": {
|
||||||
|
|
@ -1561,6 +1593,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 0,
|
||||||
|
"deletions": 1,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"old": {
|
"old": {
|
||||||
|
|
@ -1892,6 +1928,10 @@ mod routes {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"stats": {
|
||||||
|
"additions": 1,
|
||||||
|
"deletions": 0,
|
||||||
|
},
|
||||||
"eof": "noneMissing",
|
"eof": "noneMissing",
|
||||||
},
|
},
|
||||||
"new": {
|
"new": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue