Skip to content

Commit c4bf958

Browse files
committed
Merge branch 'main' into remote-ls-refs
2 parents de61c4d + e0c0b8c commit c4bf958

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1484
-898
lines changed

Diff for: Cargo.lock

+17-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,10 @@ is usable to some extend.
132132
* [git-repository](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-repository)
133133
* [git-attributes](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-attributes)
134134
* [git-pathspec](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-pathspec)
135-
* [git-refspec](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-refspec)
135+
* [git-index](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-index)
136136
* [git-revision](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-revision)
137137
* `gitoxide-core`
138138
* **very early** _(possibly without any documentation and many rough edges)_
139-
* [git-index](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-index)
140139
* [git-worktree](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-worktree)
141140
* [git-bitmap](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-bitmap)
142141
* [git-date](https://github.com/Byron/gitoxide/blob/main/crate-status.md#git-date)

Diff for: etc/check-package-size.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ echo "in root: gitoxide CLI"
2222
(enter git-path && indent cargo diet -n --package-size-limit 15KB)
2323
(enter git-attributes && indent cargo diet -n --package-size-limit 15KB)
2424
(enter git-discover && indent cargo diet -n --package-size-limit 20KB)
25-
(enter git-index && indent cargo diet -n --package-size-limit 30KB)
25+
(enter git-index && indent cargo diet -n --package-size-limit 40KB)
2626
(enter git-worktree && indent cargo diet -n --package-size-limit 30KB)
2727
(enter git-quote && indent cargo diet -n --package-size-limit 5KB)
2828
(enter git-revision && indent cargo diet -n --package-size-limit 25KB)
@@ -40,7 +40,7 @@ echo "in root: gitoxide CLI"
4040
(enter git-traverse && indent cargo diet -n --package-size-limit 10KB)
4141
(enter git-url && indent cargo diet -n --package-size-limit 15KB)
4242
(enter git-validate && indent cargo diet -n --package-size-limit 5KB)
43-
(enter git-date && indent cargo diet -n --package-size-limit 5KB)
43+
(enter git-date && indent cargo diet -n --package-size-limit 10KB)
4444
(enter git-filter && indent cargo diet -n --package-size-limit 5KB)
4545
(enter git-lfs && indent cargo diet -n --package-size-limit 5KB)
4646
(enter git-note && indent cargo diet -n --package-size-limit 5KB)

Diff for: git-date/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ serde1 = ["serde", "bstr/serde1"]
2020
bstr = { version = "0.2.13", default-features = false, features = ["std"]}
2121
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
2222
itoa = "1.0.1"
23-
time = { version = "0.3.2", default-features = false, features = ["local-offset"] }
23+
time = { version = "0.3.2", default-features = false, features = ["local-offset", "formatting", "macros"] }
2424

2525
document-features = { version = "0.2.0", optional = true }
2626

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

+2-11
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,11 @@
99
#![forbid(unsafe_code)]
1010
#![deny(missing_docs, rust_2018_idioms)]
1111

12-
use bstr::BStr;
13-
1412
///
1513
pub mod time;
1614

17-
#[allow(missing_docs)]
18-
pub fn parse(input: &BStr) -> Option<Time> {
19-
// TODO: actual implementation, this is just to not constantly fail
20-
if input == "1979-02-26 18:30:00" {
21-
Some(Time::new(42, 1800))
22-
} else {
23-
None
24-
}
25-
}
15+
mod parse;
16+
pub use parse::parse;
2617

2718
/// A timestamp with timezone.
2819
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]

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

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use crate::Time;
2+
3+
#[allow(missing_docs)]
4+
pub fn parse(input: &str) -> Option<Time> {
5+
// TODO: actual implementation, this is just to not constantly fail
6+
if input == "1979-02-26 18:30:00" {
7+
Some(Time::new(42, 1800))
8+
} else {
9+
None
10+
}
11+
}

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

-174
This file was deleted.

Diff for: git-date/src/time/format.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use crate::Time;
2+
use time::format_description::FormatItem;
3+
use time::formatting::Formattable;
4+
use time::macros::format_description;
5+
6+
/// E.g. `2018-12-24`
7+
pub const SHORT: &[FormatItem<'_>] = format_description!("[year]-[month]-[day]");
8+
9+
/// Formatting
10+
impl Time {
11+
/// Format this instance according to the given `format`.
12+
///
13+
/// Use the [`format_description`] macro to create and validate formats at compile time, courtesy of the [`time`] crate.
14+
pub fn format(&self, format: &(impl Formattable + ?Sized)) -> String {
15+
self.to_time()
16+
.format(&format)
17+
.expect("well-known format into memory never fails")
18+
}
19+
}
20+
21+
impl Time {
22+
fn to_time(self) -> time::OffsetDateTime {
23+
time::OffsetDateTime::from_unix_timestamp(self.seconds_since_unix_epoch as i64)
24+
.expect("always valid unix time")
25+
.replace_offset(time::UtcOffset::from_whole_seconds(self.offset_in_seconds).expect("valid offset"))
26+
}
27+
}

0 commit comments

Comments
 (0)