Compare commits

..

No commits in common. "2d759ca4ab06ea2d1957d0cb5a90c5fc81ae94a4" and "4d6e18a9f425d90f89b069c90d11fa89c3afd2d6" have entirely different histories.

6 changed files with 3 additions and 38 deletions

View file

@ -9,7 +9,6 @@ log = ["dep:log", "dep:simple_logger"]
[dependencies] [dependencies]
anyhow = "1.0.95" anyhow = "1.0.95"
chrono = "0.4.41"
clap = { version = "4.5.26", features = ["derive"] } clap = { version = "4.5.26", features = ["derive"] }
log = { version = "0.4.27", optional = true } log = { version = "0.4.27", optional = true }
rand = "0.9.1" rand = "0.9.1"

View file

@ -99,7 +99,6 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
for (uuid, comment) in issue.comments.iter() { for (uuid, comment) in issue.comments.iter() {
println!(""); println!("");
println!("comment: {}", uuid); println!("comment: {}", uuid);
println!("timestamp: {}", comment.timestamp);
println!("{}", comment.description); println!("{}", comment.description);
} }
} }

View file

@ -3,7 +3,6 @@ use std::io::Write;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct Comment { pub struct Comment {
pub description: String, pub description: String,
pub timestamp: chrono::DateTime<chrono::Local>,
/// This is the directory that the comment lives in. Only used /// This is the directory that the comment lives in. Only used
/// internally by the entomologist library. /// internally by the entomologist library.
@ -40,15 +39,13 @@ impl Comment {
} }
} }
} }
if description == None { if description == None {
return Err(CommentError::CommentParseError); return Err(CommentError::CommentParseError);
} }
let timestamp = crate::git::git_log_oldest_timestamp(comment_dir)?;
Ok(Self { Ok(Self {
description: description.unwrap(), description: description.unwrap(),
timestamp,
dir: std::path::PathBuf::from(comment_dir), dir: std::path::PathBuf::from(comment_dir),
}) })
} }
@ -99,7 +96,7 @@ mod tests {
let comment = Comment::new_from_dir(comment_dir).unwrap(); let comment = Comment::new_from_dir(comment_dir).unwrap();
let expected = Comment { let expected = Comment {
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"), 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), dir: std::path::PathBuf::from(comment_dir),
}; };
assert_eq!(comment, expected); assert_eq!(comment, expected);

View file

@ -4,8 +4,6 @@ use std::io::Write;
pub enum GitError { pub enum GitError {
#[error(transparent)] #[error(transparent)]
StdIoError(#[from] std::io::Error), StdIoError(#[from] std::io::Error),
#[error(transparent)]
ParseIntError(#[from] std::num::ParseIntError),
#[error("Oops, something went wrong")] #[error("Oops, something went wrong")]
Oops, Oops,
} }
@ -126,33 +124,6 @@ pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> {
Ok(()) Ok(())
} }
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.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::<i64>()?;
let timestamp: chrono::DateTime<chrono::Local> =
chrono::DateTime::from_timestamp(timestamp_i64, 0)
.unwrap()
.with_timezone(&chrono::Local);
Ok(timestamp)
}
pub fn create_orphan_branch(branch: &str) -> Result<(), GitError> { pub fn create_orphan_branch(branch: &str) -> Result<(), GitError> {
{ {
let tmp_worktree = tempfile::tempdir().unwrap(); let tmp_worktree = tempfile::tempdir().unwrap();

View file

@ -75,6 +75,7 @@ impl fmt::Display for State {
State::InProgress => "inprogress", State::InProgress => "inprogress",
State::Done => "done", State::Done => "done",
State::WontDo => "wontdo", State::WontDo => "wontdo",
}; };
write!(f, "{fmt_str}") write!(f, "{fmt_str}")
} }
@ -154,7 +155,6 @@ impl Issue {
Ok(crate::comment::Comment { Ok(crate::comment::Comment {
description: String::from(""), // FIXME description: String::from(""), // FIXME
timestamp: chrono::Local::now(),
dir, dir,
}) })
} }

View file

@ -154,7 +154,6 @@ mod tests {
String::from(&comment_uuid), String::from(&comment_uuid),
crate::comment::Comment { crate::comment::Comment {
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"), 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), dir: std::path::PathBuf::from(comment_dir),
} }
); );