summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2022-01-07 14:07:57 -0500
committerDan Davison <dandavison7@gmail.com>2022-01-07 14:21:21 -0500
commitd10ef79aa01b03540affe7e67caffbded25189a6 (patch)
tree3764595b85dd1f3831e7ae7df9d942c2115764a8
parent7d987b1b4a4eb0e1e9b0731ed94bd9973cb7ef61 (diff)
Eliminate chrono dependency to avoid security bugsyntect-185-test-2
See https://github.com/dandavison/delta/pull/746
-rw-r--r--Cargo.lock25
-rw-r--r--Cargo.toml2
-rw-r--r--src/handlers/blame.rs16
3 files changed, 4 insertions, 39 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 63df7763..485e0d80 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -154,20 +154,8 @@ version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
- "libc",
"num-integer",
"num-traits",
- "time",
- "winapi",
-]
-
-[[package]]
-name = "chrono-humanize"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2eddc119501d583fd930cb92144e605f44e0252c38dd89d9247fffa1993375cb"
-dependencies = [
- "chrono",
]
[[package]]
@@ -356,8 +344,6 @@ dependencies = [
"bitflags",
"box_drawing",
"bytelines",
- "chrono",
- "chrono-humanize",
"console",
"ctrlc",
"dirs-next",
@@ -1094,17 +1080,6 @@ dependencies = [
]
[[package]]
-name = "time"
-version = "0.1.44"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
-dependencies = [
- "libc",
- "wasi 0.10.0+wasi-snapshot-preview1",
- "winapi",
-]
-
-[[package]]
name = "tinyvec"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 6f46bcf1..5a27e074 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,8 +15,6 @@ name = "delta"
path = "src/main.rs"
[dependencies]
-chrono = "0.4.19"
-chrono-humanize = "0.2.1"
ansi_colours = "1.0.4"
ansi_term = "0.12.1"
atty = "0.2.14"
diff --git a/src/handlers/blame.rs b/src/handlers/blame.rs
index b3d628a6..5aa6bb5b 100644
--- a/src/handlers/blame.rs
+++ b/src/handlers/blame.rs
@@ -1,4 +1,3 @@
-use chrono::{DateTime, FixedOffset};
use lazy_static::lazy_static;
use regex::Regex;
use std::borrow::Cow;
@@ -29,7 +28,7 @@ impl<'a> StateMachine<'a> {
};
if try_parse {
let line = self.line.to_owned();
- if let Some(blame) = parse_git_blame_line(&line, &self.config.blame_timestamp_format) {
+ if let Some(blame) = parse_git_blame_line(&line) {
// Format blame metadata
let format_data = format::parse_line_number_format(
&self.config.blame_format,
@@ -170,7 +169,6 @@ impl<'a> StateMachine<'a> {
pub struct BlameLine<'a> {
pub commit: &'a str,
pub author: &'a str,
- pub time: DateTime<FixedOffset>,
pub line_number: usize,
pub code: &'a str,
}
@@ -209,14 +207,11 @@ $
.unwrap();
}
-pub fn parse_git_blame_line<'a>(line: &'a str, timestamp_format: &str) -> Option<BlameLine<'a>> {
+pub fn parse_git_blame_line(line: &str) -> Option<BlameLine> {
let caps = BLAME_LINE_REGEX.captures(line)?;
let commit = caps.get(1).unwrap().as_str();
let author = caps.get(2).unwrap().as_str();
- let timestamp = caps.get(3).unwrap().as_str();
-
- let time = DateTime::parse_from_str(timestamp, timestamp_format).ok()?;
let line_number = caps.get(4).unwrap().as_str().parse::<usize>().ok()?;
@@ -225,7 +220,6 @@ pub fn parse_git_blame_line<'a>(line: &'a str, timestamp_format: &str) -> Option
Some(BlameLine {
commit,
author,
- time,
line_number,
code,
})
@@ -253,9 +247,7 @@ pub fn format_blame_metadata(
let width = placeholder.width.unwrap_or(15);
let field = match placeholder.placeholder {
- Some(Placeholder::Str("timestamp")) => Some(Cow::from(
- chrono_humanize::HumanTime::from(blame.time).to_string(),
- )),
+ Some(Placeholder::Str("timestamp")) => Some(Cow::from("dummy".to_string())),
Some(Placeholder::Str("author")) => Some(Cow::from(blame.author)),
Some(Placeholder::Str("commit")) => Some(delta::format_raw_line(blame.commit, config)),
None => None,
@@ -293,7 +285,7 @@ mod tests {
] {
let caps = BLAME_LINE_REGEX.captures(line);
assert!(caps.is_some());
- assert!(parse_git_blame_line(line, "%Y-%m-%d %H:%M:%S %z").is_some());
+ assert!(parse_git_blame_line(line).is_some());
}
}