Skip to content

Commit 0f8680a

Browse files
committed
adjust git_date::parsea(str) to use a str
It will never not be UTF-8, so no bstr is required.
1 parent 11a5fa2 commit 0f8680a

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

Diff for: git-date/src/parse.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use crate::Time;
2-
use bstr::BStr;
32

43
#[allow(missing_docs)]
5-
pub fn parse(input: &BStr) -> Option<Time> {
4+
pub fn parse(input: &str) -> Option<Time> {
65
// TODO: actual implementation, this is just to not constantly fail
76
if input == "1979-02-26 18:30:00" {
87
Some(Time::new(42, 1800))

Diff for: git-date/tests/time/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ mod parse {
8080
#[test]
8181
fn special_time_is_ok_for_now() {
8282
assert_eq!(
83-
git_date::parse("1979-02-26 18:30:00".into()).unwrap(),
83+
git_date::parse("1979-02-26 18:30:00").unwrap(),
8484
Time {
8585
seconds_since_unix_epoch: 42,
8686
offset_in_seconds: 1800,

Diff for: git-repository/src/repository/identity.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,15 @@ impl Personas {
126126
if git_env.eq(&git_sec::Permission::Allow) {
127127
committer_name = committer_name.or_else(|| env_var("GIT_COMMITTER_NAME"));
128128
committer_email = committer_email.or_else(|| env_var("GIT_COMMITTER_EMAIL"));
129-
committer_date = env_var("GIT_COMMITTER_DATE").and_then(|date| git_date::parse(date.as_ref()));
129+
committer_date = std::env::var("GIT_COMMITTER_DATE")
130+
.ok()
131+
.and_then(|date| git_date::parse(&date));
130132

131133
author_name = author_name.or_else(|| env_var("GIT_AUTHOR_NAME"));
132134
author_email = author_email.or_else(|| env_var("GIT_AUTHOR_EMAIL"));
133-
author_date = env_var("GIT_AUTHOR_DATE").and_then(|date| git_date::parse(date.as_ref()));
135+
author_date = std::env::var("GIT_AUTHOR_DATE")
136+
.ok()
137+
.and_then(|date| git_date::parse(&date));
134138

135139
user_email = user_email.or_else(|| env_var("EMAIL")); // NOTE: we don't have permission for this specific one…
136140
}

Diff for: git-revision/src/spec/parse/function.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,11 @@ where
432432
Err(Error::SiblingBranchNeedsBranchName { name: (*name).into() })
433433
}?
434434
} else if has_ref_or_implied_name {
435-
let time = git_date::parse(nav).ok_or_else(|| Error::Time { input: nav.into() })?;
435+
let time = nav
436+
.to_str()
437+
.ok()
438+
.and_then(git_date::parse)
439+
.ok_or_else(|| Error::Time { input: nav.into() })?;
436440
delegate
437441
.reflog(delegate::ReflogLookup::Date(time))
438442
.ok_or(Error::Delegate)?;

0 commit comments

Comments
 (0)