Skip to content

Commit

Permalink
adjust to breaking changes in gix
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jun 27, 2023
1 parent cca17f0 commit 782fc66
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/info/contributors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl InfoField for ContributorsInfo {
#[cfg(test)]
mod test {
use super::*;
use gix::actor::Time;
use gix::date::Time;

#[test]
fn test_display_contributors_info() {
Expand Down
4 changes: 2 additions & 2 deletions src/info/git/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pub struct GitMetrics {
pub total_number_of_authors: usize,
pub total_number_of_commits: usize,
pub churn_pool_size: usize,
pub time_of_most_recent_commit: gix::actor::Time,
pub time_of_first_commit: gix::actor::Time,
pub time_of_most_recent_commit: gix::date::Time,
pub time_of_first_commit: gix::date::Time,
}

impl GitMetrics {
Expand Down
5 changes: 2 additions & 3 deletions src/info/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ pub fn traverse_commit_graph(repo: &gix::Repository, options: &CliOptions) -> Re

churn_tx.send(commit.id)?;

let commit_time = gix::actor::Time::new(
let commit_time = gix::date::Time::new(
commit
.commit_time
.expect("sorting by time yields this field as part of traversal")
as u32, // TODO: remove this cast once `gix` supports 64 bit dates.
.expect("sorting by time yields this field as part of traversal"),
0,
);
time_of_most_recent_commit.get_or_insert(commit_time);
Expand Down
12 changes: 6 additions & 6 deletions src/info/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::time::{Duration, SystemTime};

use gix::actor::Time;
use gix::date::Time;
use time::{format_description::well_known::Rfc3339, OffsetDateTime};
use time_humanize::HumanTime;

pub mod info_field;

pub fn format_time(time: Time, iso_time: bool) -> String {
if iso_time {
to_rfc3339(HumanTime::from(time.seconds_since_unix_epoch as i64))
to_rfc3339(HumanTime::from(time.seconds as i64))
} else {
to_human_time(time)
}
Expand All @@ -26,7 +26,7 @@ fn to_human_time(time: Time) -> String {
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap();

let ts = Duration::from_secs(time.seconds_since_unix_epoch as u64);
let ts = Duration::from_secs(time.seconds);
let duration = since_epoch_duration.checked_sub(ts).expect(
"Achievement unlocked: time travel! \
Check your system clock and commit dates.",
Expand All @@ -46,7 +46,7 @@ mod tests {
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap();

let time = Time::new(current_time.as_secs() as u32, 0);
let time = Time::new(current_time.as_secs(), 0);
let result = format_time(time, false);
assert_eq!(result, "now");
}
Expand All @@ -59,7 +59,7 @@ mod tests {
.unwrap();
// NOTE 366 so that it's a year ago even with leap years.
let year_ago = current_time - (day * 366);
let time = Time::new(year_ago.as_secs() as u32, 0);
let time = Time::new(year_ago.as_secs(), 0);
let result = format_time(time, false);
assert_eq!(result, "a year ago");
}
Expand Down Expand Up @@ -91,7 +91,7 @@ mod tests {
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap();
let tomorrow = current_time + day;
let time = Time::new(tomorrow.as_secs() as u32, 0);
let time = Time::new(tomorrow.as_secs(), 0);
format_time(time, false);
}
}
2 changes: 1 addition & 1 deletion src/info/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn get_version(repo: &Repository, manifest: Option<&Manifest>) -> Result<String>

for tag in repo.references()?.tags()?.peeled().filter_map(Result::ok) {
if let Ok(commit) = tag.id().object()?.try_into_commit() {
let current_time = commit.time()?.seconds();
let current_time = commit.time()?.seconds;
if current_time > most_recent {
most_recent = current_time;
version = tag.name().shorten().to_string();
Expand Down

0 comments on commit 782fc66

Please sign in to comment.