From b02807eaca831bdf9e43e27699d28c108147460b Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Sat, 12 Jul 2025 10:18:46 -0600 Subject: [PATCH] Issue: add tags field --- src/issue.rs | 17 +++++++++++++++++ src/issues.rs | 11 +++++++++++ .../tags | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/tags diff --git a/src/issue.rs b/src/issue.rs index b309cae..52c2f0b 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -22,6 +22,7 @@ pub type IssueHandle = String; pub struct Issue { pub author: String, pub timestamp: chrono::DateTime, + pub tags: Vec, pub state: State, pub dependencies: Option>, pub assignee: Option, @@ -97,6 +98,7 @@ impl Issue { let mut dependencies: Option> = None; let mut comments = Vec::::new(); let mut assignee: Option = None; + let mut tags = Vec::::new(); for direntry in dir.read_dir()? { if let Ok(direntry) = direntry { @@ -119,6 +121,13 @@ impl Issue { if deps.len() > 0 { dependencies = Some(deps); } + } else if file_name == "tags" { + let contents = std::fs::read_to_string(direntry.path())?; + tags = contents + .lines() + .filter(|s| s.len() > 0) + .map(|tag| String::from(tag.trim())) + .collect(); } else if file_name == "comments" && direntry.metadata()?.is_dir() { Self::read_comments(&mut comments, &direntry.path())?; } else { @@ -138,6 +147,7 @@ impl Issue { Ok(Self { author, timestamp, + tags, state: state, dependencies, assignee, @@ -192,6 +202,7 @@ impl Issue { let mut issue = Self { author: String::from(""), timestamp: chrono::Local::now(), + tags: Vec::::new(), state: State::New, dependencies: None, assignee: None, @@ -372,6 +383,11 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::from([ + String::from("tag1"), + String::from("TAG2"), + String::from("i-am-also-a-tag") + ]), state: State::New, dependencies: None, assignee: None, @@ -391,6 +407,7 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::new(), state: State::InProgress, dependencies: None, assignee: Some(String::from("beep boop")), diff --git a/src/issues.rs b/src/issues.rs index 16dab55..5c314ac 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -100,6 +100,7 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::new(), state: crate::issue::State::InProgress, dependencies: None, assignee: Some(String::from("beep boop")), @@ -119,6 +120,11 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::from([ + String::from("tag1"), + String::from("TAG2"), + String::from("i-am-also-a-tag") + ]), state: crate::issue::State::New, dependencies: None, assignee: None, @@ -147,6 +153,7 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::new(), state: crate::issue::State::Done, dependencies: None, assignee: None, @@ -180,6 +187,7 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::new(), state: crate::issue::State::WontDo, dependencies: None, assignee: None, @@ -208,6 +216,7 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::new(), state: crate::issue::State::Done, dependencies: None, assignee: None, @@ -227,6 +236,7 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::new(), state: crate::issue::State::WontDo, dependencies: None, assignee: None, @@ -246,6 +256,7 @@ mod tests { timestamp: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00") .unwrap() .with_timezone(&chrono::Local), + tags: Vec::::new(), state: crate::issue::State::WontDo, dependencies: Some(vec![ crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"), diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/tags b/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/tags new file mode 100644 index 0000000..04e82a6 --- /dev/null +++ b/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/tags @@ -0,0 +1,3 @@ +tag1 +TAG2 +i-am-also-a-tag