From 2d759ca4ab06ea2d1957d0cb5a90c5fc81ae94a4 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Mon, 7 Jul 2025 23:57:33 -0600 Subject: [PATCH] fixup timestamp --- src/comment.rs | 2 +- src/git.rs | 15 ++++++++------- src/issues.rs | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/comment.rs b/src/comment.rs index fd83b5c..99d4524 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -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); diff --git a/src/git.rs b/src/git.rs index 9fa9ffe..e2afb34 100644 --- a/src/git.rs +++ b/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, 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::()?; let timestamp: chrono::DateTime = chrono::DateTime::from_timestamp(timestamp_i64, 0) diff --git a/src/issues.rs b/src/issues.rs index 29162c6..2036f4d 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -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), } );