Skip to content

Commit 589d63e

Browse files
authored
Merge pull request #2097 from GitoxideLabs/fix-gix-date
fix: don't parse any number as timestamp in `parse_header()` (#2095)
2 parents 8f51845 + 007e3f6 commit 589d63e

File tree

23 files changed

+78
-42
lines changed

23 files changed

+78
-42
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-actor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ doctest = false
1919
serde = ["dep:serde", "bstr/serde", "gix-date/serde"]
2020

2121
[dependencies]
22-
gix-date = { version = "^0.10.3", path = "../gix-date" }
22+
gix-date = { version = "^0.10.4", path = "../gix-date" }
2323
gix-utils = { version = "^0.3.0", path = "../gix-utils" }
2424

2525
thiserror = "2.0.0"

gix-archive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ zip = ["dep:zip"]
3030
gix-worktree-stream = { version = "^0.22.0", path = "../gix-worktree-stream" }
3131
gix-object = { version = "^0.50.0", path = "../gix-object" }
3232
gix-path = { version = "^0.10.19", path = "../gix-path", optional = true }
33-
gix-date = { version = "^0.10.3", path = "../gix-date" }
33+
gix-date = { version = "^0.10.4", path = "../gix-date" }
3434

3535
flate2 = { version = "1.1.1", optional = true, default-features = false, features = ["zlib-rs"] }
3636
zip = { version = "4.3.0", optional = true, default-features = false, features = ["deflate-flate2"] }

gix-blame/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ rust-version = "1.70"
1414
gix-commitgraph = { version = "^0.29.0", path = "../gix-commitgraph" }
1515
gix-revwalk = { version = "^0.21.0", path = "../gix-revwalk" }
1616
gix-trace = { version = "^0.1.13", path = "../gix-trace" }
17-
gix-date = { version = "^0.10.3", path = "../gix-date" }
17+
gix-date = { version = "^0.10.4", path = "../gix-date" }
1818
gix-diff = { version = "^0.53.0", path = "../gix-diff", default-features = false, features = ["blob"] }
1919
gix-object = { version = "^0.50.0", path = "../gix-object" }
2020
gix-hash = { version = "^0.19.0", path = "../gix-hash" }

gix-credentials/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ gix-path = { version = "^0.10.19", path = "../gix-path" }
2525
gix-command = { version = "^0.6.2", path = "../gix-command" }
2626
gix-config-value = { version = "^0.15.1", path = "../gix-config-value" }
2727
gix-prompt = { version = "^0.11.1", path = "../gix-prompt" }
28-
gix-date = { version = "^0.10.3", path = "../gix-date" }
28+
gix-date = { version = "^0.10.4", path = "../gix-date" }
2929
gix-trace = { version = "^0.1.13", path = "../gix-trace" }
3030

3131
thiserror = "2.0.0"

gix-date/CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.10.4 (2025-08-03)
9+
10+
### Bug Fixes
11+
12+
- <csr-id-ad67ab5bdea74f3c90c9670c8043f8b642a274d4/> don't parse any number as timestamp in `parse_header()`
13+
14+
### Commit Statistics
15+
16+
<csr-read-only-do-not-edit/>
17+
18+
- 3 commits contributed to the release over the course of 19 calendar days.
19+
- 19 days passed between releases.
20+
- 1 commit was understood as [conventional](https://www.conventionalcommits.org).
21+
- 1 unique issue was worked on: [#2095](https://github.com/GitoxideLabs/gitoxide/issues/2095)
22+
23+
### Commit Details
24+
25+
<csr-read-only-do-not-edit/>
26+
27+
<details><summary>view details</summary>
28+
29+
* **[#2095](https://github.com/GitoxideLabs/gitoxide/issues/2095)**
30+
- Don't parse any number as timestamp in `parse_header()` ([`ad67ab5`](https://github.com/GitoxideLabs/gitoxide/commit/ad67ab5bdea74f3c90c9670c8043f8b642a274d4))
31+
* **Uncategorized**
32+
- Remove a hack which makes '1979-02-26 18:30:00' special. ([`91b3220`](https://github.com/GitoxideLabs/gitoxide/commit/91b32208dda387916b87fc1d02809a73415a58c0))
33+
- Merge pull request #2075 from GitoxideLabs/improvements ([`784c046`](https://github.com/GitoxideLabs/gitoxide/commit/784c0465bf87011fe7dbf71a590d3f9e6c8696a8))
34+
</details>
35+
836
## 0.10.3 (2025-07-15)
937

1038
A maintenance release without user-facing changes.
@@ -13,7 +41,7 @@ A maintenance release without user-facing changes.
1341

1442
<csr-read-only-do-not-edit/>
1543

16-
- 6 commits contributed to the release over the course of 65 calendar days.
44+
- 7 commits contributed to the release over the course of 65 calendar days.
1745
- 65 days passed between releases.
1846
- 0 commits were understood as [conventional](https://www.conventionalcommits.org).
1947
- 0 issues like '(#ID)' were seen in commit messages
@@ -25,6 +53,7 @@ A maintenance release without user-facing changes.
2553
<details><summary>view details</summary>
2654

2755
* **Uncategorized**
56+
- Release gix-date v0.10.3, gix-actor v0.35.2, gix-trace v0.1.13, gix-path v0.10.19, gix-features v0.43.0, gix-hash v0.19.0, gix-hashtable v0.9.0, gix-object v0.50.0, gix-glob v0.21.0, gix-attributes v0.27.0, gix-command v0.6.2, gix-packetline-blocking v0.19.1, gix-filter v0.20.0, gix-fs v0.16.0, gix-commitgraph v0.29.0, gix-revwalk v0.21.0, gix-traverse v0.47.0, gix-worktree-stream v0.22.0, gix-archive v0.22.0, gix-tempfile v18.0.0, gix-lock v18.0.0, gix-index v0.41.0, gix-config-value v0.15.1, gix-pathspec v0.12.0, gix-ignore v0.16.0, gix-worktree v0.42.0, gix-diff v0.53.0, gix-blame v0.3.0, gix-ref v0.53.0, gix-sec v0.12.0, gix-config v0.46.0, gix-prompt v0.11.1, gix-url v0.32.0, gix-credentials v0.30.0, gix-discover v0.41.0, gix-dir v0.15.0, gix-mailmap v0.27.2, gix-revision v0.35.0, gix-merge v0.6.0, gix-negotiate v0.21.0, gix-pack v0.60.0, gix-odb v0.70.0, gix-refspec v0.31.0, gix-shallow v0.5.0, gix-packetline v0.19.1, gix-transport v0.48.0, gix-protocol v0.51.0, gix-status v0.20.0, gix-submodule v0.20.0, gix-worktree-state v0.20.0, gix v0.73.0, gix-fsck v0.12.0, gitoxide-core v0.48.0, gitoxide v0.45.0, safety bump 43 crates ([`5a919c4`](https://github.com/GitoxideLabs/gitoxide/commit/5a919c48393020d47c7034946108577dd213b80a))
2857
- Update changelogs prior to release ([`65037b5`](https://github.com/GitoxideLabs/gitoxide/commit/65037b56918b90ac07454a815b0ed136df2fca3b))
2958
- Merge pull request #2070 from GitoxideLabs/dependabot/cargo/cargo-827bceb7eb ([`dab97f7`](https://github.com/GitoxideLabs/gitoxide/commit/dab97f7618f160421b6e31de8f3e2f3d11dc2ef2))
3059
- Bump the cargo group across 1 directory with 68 updates ([`a9a8ea1`](https://github.com/GitoxideLabs/gitoxide/commit/a9a8ea1472532dde03bce4e0afdfa82924af1f96))

gix-date/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ lints.workspace = true
22

33
[package]
44
name = "gix-date"
5-
version = "0.10.3"
5+
version = "0.10.4"
66
repository = "https://github.com/GitoxideLabs/gitoxide"
77
license = "MIT OR Apache-2.0"
88
description = "A crate of the gitoxide project parsing dates the way git does"

gix-date/src/parse.rs

Lines changed: 3 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)
@@ -214,6 +209,9 @@ pub(crate) mod function {
214209
Some(offset_in_seconds)
215210
}
216211

212+
if input.contains(':') {
213+
return None;
214+
}
217215
let mut split = input.split_whitespace();
218216
let seconds = split.next()?;
219217
let seconds = match seconds.parse::<SecondsSinceUnixEpoch>() {

gix-date/tests/time/parse.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,28 @@ 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

13+
#[test]
14+
fn parse_header_is_not_too_lenient() {
15+
let now = SystemTime::now();
16+
for not_a_header_str in ["2005-04-07T22:13:09", "2005-04-07 22:13:09"] {
17+
assert!(
18+
gix_date::parse_header(not_a_header_str).is_none(),
19+
"It's not timestamp-like, despite some leniency"
20+
);
21+
assert!(
22+
gix_date::parse(not_a_header_str, Some(now)).is_err(),
23+
"it misses the timezone offset, so can't be parsed"
24+
);
25+
}
26+
}
27+
1628
#[test]
1729
fn short() {
1830
assert_eq!(

gix-mailmap/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ serde = ["dep:serde", "bstr/serde", "gix-actor/serde"]
2020

2121
[dependencies]
2222
gix-actor = { version = "^0.35.2", path = "../gix-actor" }
23-
gix-date = { version = "^0.10.3", path = "../gix-date" }
23+
gix-date = { version = "^0.10.4", path = "../gix-date" }
2424
bstr = { version = "1.12.0", default-features = false, features = ["std", "unicode"] }
2525
thiserror = "2.0.0"
2626
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] }

0 commit comments

Comments
 (0)