give Comment a timestamp, display in chronological order

This commit makes a couple of changes:

- `ent show ISSUE` now displays the Issue's Comments in chronological
  order

- the Comment struct now includes a timestamp, which is the Author Time
  of the oldest commit that touches the comment's directory

- the Issue struct now stores its Comments in a sorted Vec, not in
  a HashMap

- The Comment's uuid moved into the Comment struct itself, instead of
  being the key in the Issue's HashMap of Comments
This commit is contained in:
Sebastian Kuzminsky 2025-07-07 23:45:03 -06:00
parent 431c67d43d
commit be362517fb
6 changed files with 65 additions and 23 deletions

View file

@ -99,7 +99,7 @@ mod tests {
description: String::from("minimal"),
state: crate::issue::State::InProgress,
dependencies: None,
comments: std::collections::HashMap::<String, crate::comment::Comment>::new(),
comments: Vec::<crate::comment::Comment>::new(),
dir,
},
);
@ -113,7 +113,7 @@ mod tests {
description: String::from("this is the title of my issue\n\nThis is the description of my issue.\nIt is multiple lines.\n* Arbitrary contents\n* But let's use markdown by convention\n"),
state: crate::issue::State::New,
dependencies: None,
comments: std::collections::HashMap::<String, crate::comment::Comment>::new(),
comments: Vec::<crate::comment::Comment>::new(),
dir,
}
);
@ -136,7 +136,7 @@ mod tests {
description: String::from("oh yeah we got titles"),
state: crate::issue::State::Done,
dependencies: None,
comments: std::collections::HashMap::<String, crate::comment::Comment>::new(),
comments: Vec::<crate::comment::Comment>::new(),
dir,
},
);
@ -148,12 +148,12 @@ mod tests {
let comment_uuid = String::from("9055dac36045fe36545bed7ae7b49347");
comment_dir.push("comments");
comment_dir.push(&comment_uuid);
let mut expected_comments =
std::collections::HashMap::<String, crate::comment::Comment>::new();
expected_comments.insert(
String::from(&comment_uuid),
let mut expected_comments = Vec::<crate::comment::Comment>::new();
expected_comments.push(
crate::comment::Comment {
uuid: comment_uuid,
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),
}
);
@ -186,7 +186,7 @@ mod tests {
description: String::from("oh yeah we got titles\n"),
state: crate::issue::State::Done,
dependencies: None,
comments: std::collections::HashMap::<String, crate::comment::Comment>::new(),
comments: Vec::<crate::comment::Comment>::new(),
dir,
},
);
@ -200,7 +200,7 @@ mod tests {
description: String::from("issues out the wazoo\n\nLots of words\nthat don't say much\nbecause this is just\na test\n"),
state: crate::issue::State::WontDo,
dependencies: None,
comments: std::collections::HashMap::<String, crate::comment::Comment>::new(),
comments: Vec::<crate::comment::Comment>::new(),
dir,
},
);
@ -217,7 +217,7 @@ mod tests {
crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"),
crate::issue::IssueHandle::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561"),
]),
comments: std::collections::HashMap::<String, crate::comment::Comment>::new(),
comments: Vec::<crate::comment::Comment>::new(),
dir,
},
);