diff --git a/Cargo.toml b/Cargo.toml index af271d7..fccb9c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ log = ["dep:log", "dep:simple_logger"] [dependencies] anyhow = "1.0.95" -chrono = "0.4.41" clap = { version = "4.5.26", features = ["derive"] } log = { version = "0.4.27", optional = true } rand = "0.9.1" diff --git a/src/bin/ent/main.rs b/src/bin/ent/main.rs index 9f8b6da..1c9ddaa 100644 --- a/src/bin/ent/main.rs +++ b/src/bin/ent/main.rs @@ -99,7 +99,6 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( for (uuid, comment) in issue.comments.iter() { println!(""); println!("comment: {}", uuid); - println!("timestamp: {}", comment.timestamp); println!("{}", comment.description); } } diff --git a/src/comment.rs b/src/comment.rs index 99d4524..ab2ced9 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -3,7 +3,6 @@ use std::io::Write; #[derive(Debug, PartialEq)] pub struct Comment { pub description: String, - pub timestamp: chrono::DateTime, /// This is the directory that the comment lives in. Only used /// internally by the entomologist library. @@ -40,15 +39,13 @@ impl Comment { } } } + if description == None { return Err(CommentError::CommentParseError); } - let timestamp = crate::git::git_log_oldest_timestamp(comment_dir)?; - Ok(Self { description: description.unwrap(), - timestamp, dir: std::path::PathBuf::from(comment_dir), }) } @@ -99,7 +96,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-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 e2afb34..caa5e4b 100644 --- a/src/git.rs +++ b/src/git.rs @@ -4,8 +4,6 @@ use std::io::Write; pub enum GitError { #[error(transparent)] StdIoError(#[from] std::io::Error), - #[error(transparent)] - ParseIntError(#[from] std::num::ParseIntError), #[error("Oops, something went wrong")] Oops, } @@ -126,33 +124,6 @@ pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> { Ok(()) } -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.file_name().unwrap().to_string_lossy(), - ]) - .current_dir(&git_dir) - .output()?; - 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(); - let timestamp_i64 = timestamp_str.parse::()?; - let timestamp: chrono::DateTime = - chrono::DateTime::from_timestamp(timestamp_i64, 0) - .unwrap() - .with_timezone(&chrono::Local); - Ok(timestamp) -} - pub fn create_orphan_branch(branch: &str) -> Result<(), GitError> { { let tmp_worktree = tempfile::tempdir().unwrap(); diff --git a/src/issue.rs b/src/issue.rs index f8adcde..c762c82 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -75,6 +75,7 @@ impl fmt::Display for State { State::InProgress => "inprogress", State::Done => "done", State::WontDo => "wontdo", + }; write!(f, "{fmt_str}") } @@ -154,7 +155,6 @@ impl Issue { Ok(crate::comment::Comment { description: String::from(""), // FIXME - timestamp: chrono::Local::now(), dir, }) } diff --git a/src/issues.rs b/src/issues.rs index 2036f4d..28df2e9 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -154,7 +154,6 @@ 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-07T15:26:26-06:00").unwrap().with_timezone(&chrono::Local), dir: std::path::PathBuf::from(comment_dir), } );