fixup timestamp
This commit is contained in:
parent
19a99c6b0e
commit
2d759ca4ab
3 changed files with 10 additions and 9 deletions
|
|
@ -99,7 +99,7 @@ mod tests {
|
|||
let comment = Comment::new_from_dir(comment_dir).unwrap();
|
||||
let expected = Comment {
|
||||
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"),
|
||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-01T15:26:26").unwrap().with_timezone(&chrono::Local),
|
||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00").unwrap().with_timezone(&chrono::Local),
|
||||
dir: std::path::PathBuf::from(comment_dir),
|
||||
};
|
||||
assert_eq!(comment, expected);
|
||||
|
|
|
|||
15
src/git.rs
15
src/git.rs
|
|
@ -129,21 +129,22 @@ pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> {
|
|||
pub fn git_log_oldest_timestamp(
|
||||
path: &std::path::Path,
|
||||
) -> Result<chrono::DateTime<chrono::Local>, GitError> {
|
||||
let mut git_dir = std::path::PathBuf::from(path);
|
||||
git_dir.pop();
|
||||
let result = std::process::Command::new("git")
|
||||
.args(["log", "--pretty=format:%at", &path.to_string_lossy()])
|
||||
.args([
|
||||
"log",
|
||||
"--pretty=format:%at",
|
||||
&path.file_name().unwrap().to_string_lossy(),
|
||||
])
|
||||
.current_dir(&git_dir)
|
||||
.output()?;
|
||||
println!("git logging path is {:?}", path);
|
||||
if !result.status.success() {
|
||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||
return Err(GitError::Oops);
|
||||
}
|
||||
let timestamp_str = std::str::from_utf8(&result.stdout).unwrap();
|
||||
println!(
|
||||
"timestamp of '{}': {}",
|
||||
path.file_name().unwrap().to_string_lossy(),
|
||||
timestamp_str
|
||||
);
|
||||
let timestamp_i64 = timestamp_str.parse::<i64>()?;
|
||||
let timestamp: chrono::DateTime<chrono::Local> =
|
||||
chrono::DateTime::from_timestamp(timestamp_i64, 0)
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ mod tests {
|
|||
String::from(&comment_uuid),
|
||||
crate::comment::Comment {
|
||||
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"),
|
||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-01T15:26:26").unwrap().with_timezone(&chrono::Local),
|
||||
timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00").unwrap().with_timezone(&chrono::Local),
|
||||
dir: std::path::PathBuf::from(comment_dir),
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue