Skip to content

Commit 3b1bef7

Browse files
authored
Merge pull request #1935 from pierrechevalier83/fix_1923
Make author and committer date roundtrip
2 parents 46227e6 + c3c6504 commit 3b1bef7

File tree

331 files changed

+2013
-1529
lines changed

Some content is hidden

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

331 files changed

+2013
-1529
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,7 @@ no_effect_underscore_binding = "allow" # x1
377377
empty_docs = "allow"
378378
too_long_first_doc_paragraph = "allow"
379379
large_stack_arrays = "allow"
380+
381+
# Fix one day
382+
result_large_err = "allow"
383+
large_enum_variant = "allow"

examples/log.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn run(args: Args) -> anyhow::Result<()> {
150150
commit_ref.author.actor().write_to(&mut buf)?;
151151
buf.into()
152152
},
153-
time: commit_ref.author.time.format(format::DEFAULT),
153+
time: commit_ref.author.time()?.format(format::DEFAULT),
154154
message: commit_ref.message.to_owned(),
155155
})
156156
}),

gitoxide-core/src/corpus/engine.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ impl Engine {
5757
let repos = self.refresh_repos(&corpus_path, corpus_id)?;
5858
self.state.progress.set_name("refresh repos".into());
5959
self.state.progress.info(format!(
60-
"Added or updated {} repositories under {corpus_path:?}",
61-
repos.len()
60+
"Added or updated {} repositories under '{corpus_path}'",
61+
repos.len(),
62+
corpus_path = corpus_path.display(),
6263
));
6364
Ok(())
6465
}
@@ -316,7 +317,7 @@ impl Engine {
316317
out.push(repo);
317318
progress.inc();
318319
}
319-
Err(err) => progress.fail(format!("{repo_path:?}: {err:#?}")),
320+
Err(err) => progress.fail(format!("{repo_path}: {err:#?}", repo_path = repo_path.display())),
320321
}
321322
}
322323
statement.finalize()?;

gitoxide-core/src/hours/core.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const MINUTES_PER_HOUR: f32 = 60.0;
1717
pub const HOURS_PER_WORKDAY: f32 = 8.0;
1818

1919
pub fn estimate_hours(
20-
commits: &[(u32, gix::actor::SignatureRef<'static>)],
20+
commits: &[(u32, super::SignatureRef<'static>)],
2121
stats: &[(u32, FileStats, LineStats)],
2222
) -> WorkByEmail {
2323
assert!(!commits.is_empty());
@@ -31,7 +31,7 @@ pub fn estimate_hours(
3131
let mut cur = commits.next().expect("at least one commit if we are here");
3232

3333
for next in commits {
34-
let change_in_minutes = (next.time.seconds.saturating_sub(cur.time.seconds)) as f32 / MINUTES_PER_HOUR;
34+
let change_in_minutes = (next.seconds().saturating_sub(cur.seconds())) as f32 / MINUTES_PER_HOUR;
3535
if change_in_minutes < MAX_COMMIT_DIFFERENCE_IN_MINUTES {
3636
hours += change_in_minutes / MINUTES_PER_HOUR;
3737
} else {
@@ -166,13 +166,11 @@ pub fn spawn_tree_delta_threads<'scope>(
166166
(true, true) => {
167167
files.modified += 1;
168168
if let Some(cache) = cache.as_mut() {
169-
let mut diff = change.diff(cache).map_err(|err| {
170-
std::io::Error::new(std::io::ErrorKind::Other, err)
171-
})?;
169+
let mut diff = change.diff(cache).map_err(std::io::Error::other)?;
172170
let mut nl = 0;
173-
if let Some(counts) = diff.line_counts().map_err(|err| {
174-
std::io::Error::new(std::io::ErrorKind::Other, err)
175-
})? {
171+
if let Some(counts) =
172+
diff.line_counts().map_err(std::io::Error::other)?
173+
{
176174
nl += counts.insertions as usize + counts.removals as usize;
177175
lines.added += counts.insertions as usize;
178176
lines.removed += counts.removals as usize;

gitoxide-core/src/hours/mod.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::{collections::BTreeSet, io, path::Path, time::Instant};
22

33
use anyhow::bail;
44
use gix::{
5-
actor,
65
bstr::{BStr, ByteSlice},
76
prelude::*,
87
progress, Count, NestedProgress, Progress,
@@ -27,6 +26,18 @@ pub struct Context<W> {
2726
pub out: W,
2827
}
2928

29+
pub struct SignatureRef<'a> {
30+
name: &'a BStr,
31+
email: &'a BStr,
32+
time: gix::date::Time,
33+
}
34+
35+
impl SignatureRef<'_> {
36+
fn seconds(&self) -> gix::date::SecondsSinceUnixEpoch {
37+
self.time.seconds
38+
}
39+
}
40+
3041
/// Estimate the hours it takes to produce the content of the repository in `_working_dir_`, with `_refname_` for
3142
/// the start of the commit graph traversal.
3243
///
@@ -85,7 +96,7 @@ where
8596

8697
out.push((
8798
commit_idx,
88-
actor::SignatureRef {
99+
SignatureRef {
89100
name,
90101
email,
91102
time: author.time,
@@ -97,7 +108,7 @@ where
97108
out.sort_by(|a, b| {
98109
a.1.email
99110
.cmp(b.1.email)
100-
.then(a.1.time.seconds.cmp(&b.1.time.seconds).reverse())
111+
.then(a.1.seconds().cmp(&b.1.seconds()).reverse())
101112
});
102113
Ok(out)
103114
});

gitoxide-core/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
#![deny(rust_2018_idioms)]
3131
#![forbid(unsafe_code)]
3232

33-
use anyhow::bail;
3433
use std::str::FromStr;
3534

35+
use anyhow::bail;
36+
3637
#[derive(Debug, Eq, PartialEq, Hash, Clone, Copy)]
3738
pub enum OutputFormat {
3839
Human,

gitoxide-core/src/organize.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::borrow::Cow;
21
use std::{
2+
borrow::Cow,
33
ffi::OsStr,
44
path::{Path, PathBuf},
55
};
@@ -138,9 +138,9 @@ fn handle(
138138

139139
if let Some(parent_repo_path) = find_parent_repo(git_workdir) {
140140
progress.fail(format!(
141-
"Skipping repository at {:?} as it is nested within repository {:?}",
141+
"Skipping repository at '{}' as it is nested within repository '{}'",
142142
git_workdir.display(),
143-
parent_repo_path
143+
parent_repo_path.display()
144144
));
145145
return Ok(());
146146
}
@@ -157,7 +157,7 @@ fn handle(
157157
};
158158
if url.path.is_empty() {
159159
progress.info(format!(
160-
"Skipping repository at {:?} whose remote does not have a path: {:?}",
160+
"Skipping repository at '{}' whose remote does not have a path: {}",
161161
git_workdir.display(),
162162
url.to_bstring()
163163
));

gitoxide-core/src/pack/receive.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use crate::net;
2-
use crate::pack::receive::protocol::fetch::negotiate;
3-
use crate::OutputFormat;
4-
use gix::config::tree::Key;
5-
use gix::protocol::maybe_async;
6-
use gix::remote::fetch::Error;
7-
use gix::DynNestedProgress;
1+
use std::{
2+
io,
3+
path::PathBuf,
4+
sync::{atomic::AtomicBool, Arc},
5+
};
6+
7+
use gix::{config::tree::Key, protocol::maybe_async, remote::fetch::Error, DynNestedProgress};
88
pub use gix::{
99
hash::ObjectId,
1010
objs::bstr::{BString, ByteSlice},
@@ -18,11 +18,8 @@ pub use gix::{
1818
},
1919
NestedProgress, Progress,
2020
};
21-
use std::{
22-
io,
23-
path::PathBuf,
24-
sync::{atomic::AtomicBool, Arc},
25-
};
21+
22+
use crate::{net, pack::receive::protocol::fetch::negotiate, OutputFormat};
2623

2724
pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=3;
2825
pub struct Context<W> {
@@ -294,7 +291,7 @@ fn receive_pack_blocking(
294291
None::<gix::objs::find::Never>,
295292
options,
296293
)
297-
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
294+
.map_err(io::Error::other)?;
298295

299296
if let Some(directory) = refs_directory.take() {
300297
write_raw_refs(refs, directory)?;

gitoxide-core/src/query/db.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ pub fn create(path: impl AsRef<std::path::Path>) -> anyhow::Result<rusqlite::Con
1919
}
2020
Some(version) if version != VERSION => match con.close() {
2121
Ok(()) => {
22-
std::fs::remove_file(path)
23-
.with_context(|| format!("Failed to remove incompatible database file at {path:?}"))?;
22+
std::fs::remove_file(path).with_context(|| {
23+
format!(
24+
"Failed to remove incompatible database file at {path}",
25+
path = path.display()
26+
)
27+
})?;
2428
con = rusqlite::Connection::open(path)?;
2529
con.execute_batch(meta_table)?;
2630
con.execute("INSERT into meta(version) values(?)", params![VERSION])?;

0 commit comments

Comments
 (0)