Compare commits

..

9 commits

Author SHA1 Message Date
c0e0618ec0 ent list: show assignee, if any 2025-07-08 17:31:10 -06:00
b4268a5f29 add ent assign ISSUE PERSON 2025-07-08 17:16:17 -06:00
c1f18c8145 add optional 'assignee' to Issue 2025-07-08 16:29:18 -06:00
ce1e966d7d ent list: show comment count for each issue 2025-07-08 16:20:44 -06:00
9933b139d9 make ent list sort issues first by state, then by ctime 2025-07-08 16:09:45 -06:00
a08b514c34 add author and timestamp to Issue 2025-07-08 14:46:41 -06:00
fcadf840dc add author to Comment 2025-07-08 14:46:35 -06:00
92adb554a5 fix git::git_log_oldest_timestamp() when there are multiple log entries 2025-07-08 14:46:35 -06:00
1fa3aae2c0 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
2025-07-08 12:29:24 -06:00
3 changed files with 8 additions and 55 deletions

View file

@ -23,11 +23,7 @@ struct Args {
#[derive(clap::Subcommand, Debug)] #[derive(clap::Subcommand, Debug)]
enum Commands { enum Commands {
/// List issues. /// List issues.
List { List,
/// Filter string, describes issues to include in the list.
#[arg(default_value_t = String::from("state=New,Backlog,Blocked,InProgress"))]
filter: String,
},
/// Create a new issue. /// Create a new issue.
New { description: Option<String> }, New { description: Option<String> },
@ -68,22 +64,20 @@ enum Commands {
fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> { fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<()> {
match &args.command { match &args.command {
Commands::List { filter } => { Commands::List => {
let issues = let issues =
entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?; entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?;
let filter = entomologist::parse_filter(filter)?;
let mut uuids_by_state = std::collections::HashMap::< let mut uuids_by_state = std::collections::HashMap::<
entomologist::issue::State, entomologist::issue::State,
Vec<&entomologist::issue::IssueHandle>, Vec<&entomologist::issue::IssueHandle>,
>::new(); >::new();
for (uuid, issue) in issues.issues.iter() { for (uuid, issue) in issues.issues.iter() {
if filter.include_states.contains(&issue.state) {
uuids_by_state uuids_by_state
.entry(issue.state.clone()) .entry(issue.state.clone())
.or_default() .or_default()
.push(uuid); .push(uuid);
} }
}
use entomologist::issue::State; use entomologist::issue::State;
for state in [ for state in [
@ -95,9 +89,6 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<(
State::WontDo, State::WontDo,
] { ] {
let these_uuids = uuids_by_state.entry(state.clone()).or_default(); let these_uuids = uuids_by_state.entry(state.clone()).or_default();
if these_uuids.len() == 0 {
continue;
}
these_uuids.sort_by(|a_id, b_id| { these_uuids.sort_by(|a_id, b_id| {
let a = issues.issues.get(*a_id).unwrap(); let a = issues.issues.get(*a_id).unwrap();
let b = issues.issues.get(*b_id).unwrap(); let b = issues.issues.get(*b_id).unwrap();

View file

@ -41,8 +41,6 @@ pub enum IssueError {
CommentError(#[from] crate::comment::CommentError), CommentError(#[from] crate::comment::CommentError),
#[error("Failed to parse issue")] #[error("Failed to parse issue")]
IssueParseError, IssueParseError,
#[error("Failed to parse state")]
StateParseError,
#[error("Failed to run git")] #[error("Failed to run git")]
GitError(#[from] crate::git::GitError), GitError(#[from] crate::git::GitError),
#[error("Failed to run editor")] #[error("Failed to run editor")]
@ -66,7 +64,7 @@ impl FromStr for State {
} else if s == "wontdo" { } else if s == "wontdo" {
Ok(State::WontDo) Ok(State::WontDo)
} else { } else {
Err(IssueError::StateParseError) Err(IssueError::IssueParseError)
} }
} }
} }

View file

@ -1,40 +1,4 @@
use std::str::FromStr;
pub mod comment; pub mod comment;
pub mod git; pub mod git;
pub mod issue; pub mod issue;
pub mod issues; pub mod issues;
#[derive(Debug, thiserror::Error)]
pub enum ParseFilterError {
#[error("Failed to parse filter")]
ParseError,
#[error(transparent)]
IssueParseError(#[from] crate::issue::IssueError),
}
// FIXME: It's easy to imagine a full dsl for filtering issues, for now
// i'm starting with obvious easy things. Chumsky looks appealing but
// more research is needed.
#[derive(Debug)]
pub struct Filter {
pub include_states: std::collections::HashSet<crate::issue::State>,
}
// Parses a filter description matching "state=STATE[,STATE*]"
pub fn parse_filter(filter_str: &str) -> Result<Filter, ParseFilterError> {
let tokens: Vec<&str> = filter_str.split("=").collect();
if tokens.len() != 2 {
return Err(ParseFilterError::ParseError);
}
if tokens[0] != "state" {
return Err(ParseFilterError::ParseError);
}
let mut include_states = std::collections::HashSet::<crate::issue::State>::new();
for s in tokens[1].split(",") {
include_states.insert(crate::issue::State::from_str(s)?);
}
Ok(Filter { include_states })
}