Skip to content

Commit 91b3220

Browse files
committed
Remove a hack which makes '1979-02-26 18:30:00' special.
1 parent ad67ab5 commit 91b3220

File tree

7 files changed

+15
-26
lines changed

7 files changed

+15
-26
lines changed

gix-date/src/parse.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ pub(crate) mod function {
145145
/// * `2 minutes ago` (October 27, 2023 at 09:58:00 UTC)
146146
/// * `3 hours ago` (October 27, 2023 at 07:00:00 UTC)
147147
pub fn parse(input: &str, now: Option<SystemTime>) -> Result<Time, Error> {
148-
// TODO: actual implementation, this is just to not constantly fail
149-
if input == "1979-02-26 18:30:00" {
150-
return Ok(Time::new(42, 1800));
151-
}
152-
153148
Ok(if let Ok(val) = Date::strptime(SHORT.0, input) {
154149
let val = val
155150
.to_zoned(TimeZone::UTC)

gix-date/tests/time/parse.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ use std::time::SystemTime;
33
use gix_date::Time;
44

55
#[test]
6-
fn special_time_is_ok_for_now() {
7-
assert_eq!(
8-
gix_date::parse("1979-02-26 18:30:00", Some(SystemTime::now())).unwrap(),
9-
Time {
10-
seconds: 42,
11-
offset: 1800,
12-
}
6+
fn time_without_offset_is_not_parsed_yet() {
7+
assert!(
8+
gix_date::parse("1979-02-26 18:30:00", Some(SystemTime::now())).is_err(),
9+
"This was a special time with special handling, but it is not anymore"
1310
);
1411
}
1512

gix-revision/tests/revision/spec/parse/anchor/at_symbol.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn reflog_by_entry_for_current_branch() {
3535

3636
#[test]
3737
fn reflog_by_date_for_current_branch() {
38-
let rec = parse("@{1979-02-26 18:30:00}");
38+
let rec = parse("@{42 +0030}");
3939

4040
assert!(rec.kind.is_none());
4141
assert_eq!(rec.find_ref[0], None);
@@ -81,9 +81,9 @@ fn reflog_by_date_with_date_parse_failure() {
8181
#[test]
8282
fn reflog_by_date_for_hash_is_invalid() {
8383
for (spec, full_name) in [
84-
("1234@{1979-02-26 18:30:00}", "1234"),
85-
("abcd-dirty@{1979-02-26 18:30:00}", "abcd-dirty"),
86-
("v1.2.3-0-g1234@{1979-02-26 18:30:00}", "v1.2.3-0-g1234"),
84+
("1234@{42 +0030}", "1234"),
85+
("abcd-dirty@{42 +0030}", "abcd-dirty"),
86+
("v1.2.3-0-g1234@{42 +0030}", "v1.2.3-0-g1234"),
8787
] {
8888
let err = try_parse(spec).unwrap_err();
8989
assert!(matches!(err, spec::parse::Error::ReflogLookupNeedsRefName {name} if name == full_name));
@@ -93,12 +93,9 @@ fn reflog_by_date_for_hash_is_invalid() {
9393
#[test]
9494
fn reflog_by_date_for_given_ref_name() {
9595
for (spec, expected_ref) in [
96-
("main@{1979-02-26 18:30:00}", "main"),
97-
("refs/heads/other@{1979-02-26 18:30:00}", "refs/heads/other"),
98-
(
99-
"refs/worktree/feature/a@{1979-02-26 18:30:00}",
100-
"refs/worktree/feature/a",
101-
),
96+
("main@{42 +0030}", "main"),
97+
("refs/heads/other@{42 +0030}", "refs/heads/other"),
98+
("refs/worktree/feature/a@{42 +0030}", "refs/worktree/feature/a"),
10299
] {
103100
let rec = parse(spec);
104101

gix/tests/gix-init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod with_overrides {
2626
#[test]
2727
#[serial]
2828
fn order_from_api_and_cli_and_environment() -> gix_testtools::Result {
29-
let default_date = "1979-02-26 18:30:00";
29+
let default_date = "42 +0030";
3030
let _env = Env::new()
3131
.set("GIT_HTTP_USER_AGENT", "agent-from-env")
3232
.set("GIT_HTTP_LOW_SPEED_LIMIT", "1")

gix/tests/gix/repository/config/identity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn author_from_different_config_sections() -> crate::Result {
141141
let _env = Env::new()
142142
.set("GIT_CONFIG_GLOBAL", work_dir.join("global.config").to_str().unwrap())
143143
.set("GIT_CONFIG_SYSTEM", work_dir.join("system.config").to_str().unwrap())
144-
.set("GIT_AUTHOR_DATE", "1979-02-26 18:30:00")
144+
.set("GIT_AUTHOR_DATE", "42 +0030")
145145
.unset("GIT_AUTHOR_NAME")
146146
.set("GIT_COMMITTER_DATE", "1980-02-26 18:30:00 +0000")
147147
.unset("GIT_COMMITTER_NAME")

gix/tests/gix/revision/spec/from_bytes/reflog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn by_index() {
7878
fn by_date() {
7979
let repo = repo("complex_graph").unwrap();
8080

81-
let spec = parse_spec_no_baseline("main@{1979-02-26 18:30:00}", &repo).unwrap();
81+
let spec = parse_spec_no_baseline("main@{42 +0030}", &repo).unwrap();
8282

8383
assert_eq!(
8484
spec,

gix/tests/gix/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn hex_to_id(hex: &str) -> gix_hash::ObjectId {
99
}
1010

1111
pub fn freeze_time() -> gix_testtools::Env<'static> {
12-
let frozen_time = "1979-02-26 18:30:00";
12+
let frozen_time = "42 +0030";
1313
gix_testtools::Env::new()
1414
.unset("GIT_AUTHOR_NAME")
1515
.unset("GIT_AUTHOR_EMAIL")

0 commit comments

Comments
 (0)