Issue: add tags field

This commit is contained in:
Sebastian Kuzminsky 2025-07-12 10:18:46 -06:00
parent 665f02cbe8
commit b02807eaca
3 changed files with 31 additions and 0 deletions

View file

@ -22,6 +22,7 @@ pub type IssueHandle = String;
pub struct Issue {
pub author: String,
pub timestamp: chrono::DateTime<chrono::Local>,
pub tags: Vec<String>,
pub state: State,
pub dependencies: Option<Vec<IssueHandle>>,
pub assignee: Option<String>,
@ -97,6 +98,7 @@ impl Issue {
let mut dependencies: Option<Vec<String>> = None;
let mut comments = Vec::<crate::comment::Comment>::new();
let mut assignee: Option<String> = None;
let mut tags = Vec::<String>::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::<String>::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::<String>::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::<String>::new(),
state: State::InProgress,
dependencies: None,
assignee: Some(String::from("beep boop")),

View file

@ -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::<String>::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::<String>::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::<String>::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::<String>::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::<String>::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::<String>::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::<String>::new(),
state: crate::issue::State::WontDo,
dependencies: Some(vec![
crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"),

View file

@ -0,0 +1,3 @@
tag1
TAG2
i-am-also-a-tag