diff --git a/src/issue.rs b/src/issue.rs index 7171380..6dde005 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -5,20 +5,16 @@ use std::str::FromStr; pub enum State { New, Backlog, - Blocked, InProgress, Done, WontDo, } -pub type IssueHandle = String; - #[derive(Debug, PartialEq)] pub struct Issue { pub title: String, pub description: Option, pub state: State, - pub dependencies: Option>, } #[derive(Debug, thiserror::Error)] @@ -37,8 +33,6 @@ impl FromStr for State { Ok(State::New) } else if s == "backlog" { Ok(State::Backlog) - } else if s == "blocked" { - Ok(State::Blocked) } else if s == "inprogress" { Ok(State::InProgress) } else if s == "done" { @@ -56,7 +50,6 @@ impl Issue { 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; for direntry in dir.read_dir()? { if let Ok(direntry) = direntry { @@ -67,13 +60,7 @@ impl Issue { 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())?; - } 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(); - if deps.len() > 0 { - dependencies = Some(deps); - } + state = State::from_str(state_string.trim())?; } else { println!("ignoring unknown file in issue directory: {:?}", file_name); } @@ -88,7 +75,6 @@ impl Issue { title: title.unwrap(), description: description, state: state, - dependencies, }) } } @@ -105,7 +91,6 @@ mod tests { 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")), state: State::New, - dependencies: None, }; assert_eq!(issue, expected); } @@ -118,7 +103,6 @@ mod tests { title: String::from("minimal"), description: None, state: State::InProgress, - dependencies: None, }; assert_eq!(issue, expected); } diff --git a/src/issues.rs b/src/issues.rs index 35116e7..b5c1c87 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -83,7 +83,6 @@ mod tests { title: String::from("minimal"), description: None, state: crate::issue::State::InProgress, - dependencies: None, }, ); expected.add_issue( @@ -92,7 +91,6 @@ mod tests { 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")), state: crate::issue::State::New, - dependencies: None, } ); assert_eq!(issues, expected); @@ -110,7 +108,6 @@ mod tests { title: String::from("oh yeah we got titles"), description: None, state: crate::issue::State::Done, - dependencies: None, }, ); expected.add_issue( @@ -121,50 +118,8 @@ mod tests { "Lots of words\nthat don't say much\nbecause this is just\na test\n", )), state: crate::issue::State::WontDo, - dependencies: None, - }, - ); - assert_eq!(issues, expected); - } - - #[test] - fn read_issues_0002() { - let issues_dir = std::path::Path::new("test/0002/"); - let issues = Issues::new_from_dir(issues_dir).unwrap(); - - let mut expected = Issues::new(); - expected.add_issue( - String::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"), - crate::issue::Issue { - title: String::from("oh yeah we got titles"), - description: None, - state: crate::issue::State::Done, - dependencies: None, - }, - ); - 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", - )), - state: crate::issue::State::WontDo, - dependencies: None, - }, - ); - 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", - )), - state: crate::issue::State::WontDo, - dependencies: Some(vec![crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"), crate::issue::IssueHandle::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561")]), }, ); assert_eq!(issues, expected); } } - diff --git a/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/state b/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/state deleted file mode 100644 index 19f86f4..0000000 --- a/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/state +++ /dev/null @@ -1 +0,0 @@ -done 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/dependencies b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/dependencies deleted file mode 100644 index 71e4ee3..0000000 --- a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/dependencies +++ /dev/null @@ -1,2 +0,0 @@ -3fa5bfd93317ad25772680071d5ac3259cd2384f -dd79c8cfb8beeacd0460429944b4ecbe95a31561 \ No newline at end of file diff --git a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description deleted file mode 100644 index 049c15f..0000000 --- a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description +++ /dev/null @@ -1,3 +0,0 @@ -a test has begun -for dependencies we seek -intertwining life \ No newline at end of file diff --git a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/state b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/state deleted file mode 100644 index 7f19192..0000000 --- a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/state +++ /dev/null @@ -1 +0,0 @@ -wontdo 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/config.toml b/test/0002/config.toml deleted file mode 100644 index dfc15f2..0000000 --- a/test/0002/config.toml +++ /dev/null @@ -1 +0,0 @@ -states = [ "open", "closed" ] diff --git a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description b/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description deleted file mode 100644 index 010156b..0000000 --- a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description +++ /dev/null @@ -1,4 +0,0 @@ -Lots of words -that don't say much -because this is just -a test diff --git a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state b/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state deleted file mode 100644 index 7f19192..0000000 --- a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state +++ /dev/null @@ -1 +0,0 @@ -wontdo 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