From 559e70077e36b1bedac9c7ee881298da02ebb456 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Sat, 5 Jul 2025 22:40:28 -0600 Subject: [PATCH] "title" is just the first line of "description" now --- src/bin/ent/main.rs | 2 +- src/issue.rs | 33 ++++++++++--------- src/issues.rs | 33 +++++++------------ .../description | 2 ++ .../title | 1 - .../description | 1 + .../title | 1 - .../description | 1 + .../description | 2 ++ .../title | 1 - .../description} | 0 .../title | 1 - .../description | 2 ++ .../title | 1 - .../description | 2 ++ .../title | 1 - 16 files changed, 40 insertions(+), 44 deletions(-) delete mode 100644 test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/title create mode 100644 test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/description delete mode 100644 test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/title create mode 100644 test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/description delete mode 100644 test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title rename test/{0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/title => 0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/description} (100%) delete mode 100644 test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/title delete mode 100644 test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/title delete mode 100644 test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title diff --git a/src/bin/ent/main.rs b/src/bin/ent/main.rs index 86dfa95..65e36dc 100644 --- a/src/bin/ent/main.rs +++ b/src/bin/ent/main.rs @@ -34,7 +34,7 @@ fn handle_command(args: &Args, issues_dir: &std::path::Path) -> anyhow::Result<( let issues = entomologist::issues::Issues::new_from_dir(std::path::Path::new(issues_dir))?; for (uuid, issue) in issues.issues.iter() { - println!("{} {} ({:?})", uuid, issue.title, issue.state); + println!("{} {} ({:?})", uuid, issue.title(), issue.state); } } Commands::New { title, description } => { diff --git a/src/issue.rs b/src/issue.rs index 7171380..939af47 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -15,8 +15,7 @@ pub type IssueHandle = String; #[derive(Debug, PartialEq)] pub struct Issue { - pub title: String, - pub description: Option, + pub description: String, pub state: State, pub dependencies: Option>, } @@ -53,7 +52,6 @@ impl FromStr for State { impl Issue { pub fn new_from_dir(dir: &std::path::Path) -> Result { - let mut title: Option = None; let mut description: Option = None; let mut state = State::New; // default state, if not specified in the issue let mut dependencies: Option> = None; @@ -61,16 +59,17 @@ impl Issue { for direntry in dir.read_dir()? { if let Ok(direntry) = direntry { let file_name = direntry.file_name(); - if file_name == "title" { - title = Some(std::fs::read_to_string(direntry.path())?.trim().into()); - } else if file_name == "description" { + if file_name == "description" { description = Some(std::fs::read_to_string(direntry.path())?); } else if file_name == "state" { let state_string = std::fs::read_to_string(direntry.path())?; - state = State::from_str(state_string.trim())?; + state = State::from_str(state_string.trim())?; } else if file_name == "dependencies" { let dep_strings = std::fs::read_to_string(direntry.path())?; - let deps: Vec = dep_strings.lines().map(|dep|{IssueHandle::from(dep)}).collect(); + let deps: Vec = dep_strings + .lines() + .map(|dep| IssueHandle::from(dep)) + .collect(); if deps.len() > 0 { dependencies = Some(deps); } @@ -80,17 +79,23 @@ impl Issue { } } - if title == None { + if description == None { return Err(ReadIssueError::IssueParseError); } Ok(Self { - title: title.unwrap(), - description: description, + description: description.unwrap(), state: state, dependencies, }) } + + pub fn title<'a>(&'a self) -> &'a str { + match self.description.find("\n") { + Some(index) => &self.description.as_str()[..index], + None => self.description.as_str(), + } + } } #[cfg(test)] @@ -102,8 +107,7 @@ mod tests { let issue_dir = std::path::Path::new("test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/"); let issue = Issue::new_from_dir(issue_dir).unwrap(); let expected = Issue { - title: String::from("this is the title of my issue"), - description: Some(String::from("This is the description of my issue.\nIt is multiple lines.\n* Arbitrary contents\n* But let's use markdown by convention\n")), + 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: State::New, dependencies: None, }; @@ -115,8 +119,7 @@ mod tests { let issue_dir = std::path::Path::new("test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/"); let issue = Issue::new_from_dir(issue_dir).unwrap(); let expected = Issue { - title: String::from("minimal"), - description: None, + description: String::from("minimal"), state: State::InProgress, dependencies: None, }; diff --git a/src/issues.rs b/src/issues.rs index 35116e7..9422ded 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -80,8 +80,7 @@ mod tests { expected.add_issue( String::from("7792b063eef6d33e7da5dc1856750c149ba678c6"), crate::issue::Issue { - title: String::from("minimal"), - description: None, + description: String::from("minimal"), state: crate::issue::State::InProgress, dependencies: None, }, @@ -89,8 +88,7 @@ mod tests { expected.add_issue( String::from("3943fc5c173fdf41c0a22251593cd476d96e6c9f"), crate::issue::Issue { - title: String::from("this is the title of my issue"), - description: Some(String::from("This is the description of my issue.\nIt is multiple lines.\n* Arbitrary contents\n* But let's use markdown by convention\n")), + 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, } @@ -107,8 +105,7 @@ mod tests { expected.add_issue( String::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"), crate::issue::Issue { - title: String::from("oh yeah we got titles"), - description: None, + description: String::from("oh yeah we got titles"), state: crate::issue::State::Done, dependencies: None, }, @@ -116,10 +113,7 @@ mod tests { expected.add_issue( String::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561"), crate::issue::Issue { - title: String::from("issues out the wazoo"), - description: Some(String::from( - "Lots of words\nthat don't say much\nbecause this is just\na test\n", - )), + 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, }, @@ -136,8 +130,7 @@ mod tests { expected.add_issue( String::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"), crate::issue::Issue { - title: String::from("oh yeah we got titles"), - description: None, + description: String::from("oh yeah we got titles\n"), state: crate::issue::State::Done, dependencies: None, }, @@ -145,10 +138,7 @@ mod tests { expected.add_issue( String::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561"), crate::issue::Issue { - title: String::from("issues out the wazoo"), - description: Some(String::from( - "Lots of words\nthat don't say much\nbecause this is just\na test\n", - )), + 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, }, @@ -156,15 +146,14 @@ mod tests { expected.add_issue( String::from("a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7"), crate::issue::Issue { - title: String::from("issue with dependencies"), - description: Some(String::from( - "a test has begun\nfor dependencies we seek\nintertwining life", - )), + description: String::from("issue with dependencies\n\na test has begun\nfor dependencies we seek\nintertwining life"), state: crate::issue::State::WontDo, - dependencies: Some(vec![crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"), crate::issue::IssueHandle::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561")]), + dependencies: Some(vec![ + crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"), + crate::issue::IssueHandle::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561"), + ]), }, ); assert_eq!(issues, expected); } } - diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/description b/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/description index 3db0fcf..e380829 100644 --- a/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/description +++ b/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/description @@ -1,3 +1,5 @@ +this is the title of my issue + This is the description of my issue. It is multiple lines. * Arbitrary contents diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/title b/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/title deleted file mode 100644 index c9c2379..0000000 --- a/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/title +++ /dev/null @@ -1 +0,0 @@ -this is the title of my issue diff --git a/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/description b/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/description new file mode 100644 index 0000000..982085a --- /dev/null +++ b/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/description @@ -0,0 +1 @@ +minimal \ No newline at end of file diff --git a/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/title b/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/title deleted file mode 100644 index dd1a932..0000000 --- a/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/title +++ /dev/null @@ -1 +0,0 @@ -minimal diff --git a/test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/description b/test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/description new file mode 100644 index 0000000..c73d593 --- /dev/null +++ b/test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/description @@ -0,0 +1 @@ +oh yeah we got titles \ No newline at end of file diff --git a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description b/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description index 010156b..a65ceb6 100644 --- a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description +++ b/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description @@ -1,3 +1,5 @@ +issues out the wazoo + Lots of words that don't say much because this is just diff --git a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title b/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title deleted file mode 100644 index ab5b4a9..0000000 --- a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title +++ /dev/null @@ -1 +0,0 @@ -issues out the wazoo diff --git a/test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/title b/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/description similarity index 100% rename from test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/title rename to test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/description diff --git a/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/title b/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/title deleted file mode 100644 index 18a1926..0000000 --- a/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/title +++ /dev/null @@ -1 +0,0 @@ -oh yeah we got titles diff --git a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description index 049c15f..42e2ce3 100644 --- a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description +++ b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description @@ -1,3 +1,5 @@ +issue with dependencies + a test has begun for dependencies we seek intertwining life \ No newline at end of file diff --git a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/title b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/title deleted file mode 100644 index 7c150e7..0000000 --- a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/title +++ /dev/null @@ -1 +0,0 @@ -issue with dependencies diff --git a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description b/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description index 010156b..a65ceb6 100644 --- a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description +++ b/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description @@ -1,3 +1,5 @@ +issues out the wazoo + Lots of words that don't say much because this is just diff --git a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title b/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title deleted file mode 100644 index ab5b4a9..0000000 --- a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title +++ /dev/null @@ -1 +0,0 @@ -issues out the wazoo