Add Dependency Tracking to Issue Type #1
12 changed files with 78 additions and 1 deletions
16
src/issue.rs
16
src/issue.rs
|
|
@ -5,16 +5,20 @@ 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<String>,
|
||||
pub state: State,
|
||||
pub dependencies: Option<Vec<IssueHandle>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
|
@ -33,6 +37,8 @@ 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" {
|
||||
|
|
@ -50,6 +56,7 @@ impl Issue {
|
|||
let mut title: Option<String> = None;
|
||||
let mut description: Option<String> = None;
|
||||
let mut state = State::New; // default state, if not specified in the issue
|
||||
let mut dependencies: Option<Vec<String>> = None;
|
||||
|
||||
for direntry in dir.read_dir()? {
|
||||
if let Ok(direntry) = direntry {
|
||||
|
|
@ -61,6 +68,12 @@ impl Issue {
|
|||
} 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<IssueHandle> = dep_strings.lines().map(|dep|{IssueHandle::from(dep)}).collect();
|
||||
if deps.len() > 0 {
|
||||
dependencies = Some(deps);
|
||||
}
|
||||
} else {
|
||||
println!("ignoring unknown file in issue directory: {:?}", file_name);
|
||||
}
|
||||
|
|
@ -75,6 +88,7 @@ impl Issue {
|
|||
title: title.unwrap(),
|
||||
description: description,
|
||||
state: state,
|
||||
dependencies,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -91,6 +105,7 @@ 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);
|
||||
}
|
||||
|
|
@ -103,6 +118,7 @@ mod tests {
|
|||
title: String::from("minimal"),
|
||||
description: None,
|
||||
state: State::InProgress,
|
||||
dependencies: None,
|
||||
};
|
||||
assert_eq!(issue, expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ mod tests {
|
|||
title: String::from("minimal"),
|
||||
description: None,
|
||||
state: crate::issue::State::InProgress,
|
||||
dependencies: None,
|
||||
},
|
||||
);
|
||||
expected.add_issue(
|
||||
|
|
@ -91,6 +92,7 @@ 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);
|
||||
|
|
@ -108,6 +110,7 @@ mod tests {
|
|||
title: String::from("oh yeah we got titles"),
|
||||
description: None,
|
||||
state: crate::issue::State::Done,
|
||||
dependencies: None,
|
||||
},
|
||||
);
|
||||
expected.add_issue(
|
||||
|
|
@ -118,8 +121,50 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
1
test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/state
Normal file
1
test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
done
|
||||
1
test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/title
Normal file
1
test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/title
Normal file
|
|
@ -0,0 +1 @@
|
|||
oh yeah we got titles
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
3fa5bfd93317ad25772680071d5ac3259cd2384f
|
||||
dd79c8cfb8beeacd0460429944b4ecbe95a31561
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
a test has begun
|
||||
for dependencies we seek
|
||||
intertwining life
|
||||
|
|
||||
1
test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/state
Normal file
1
test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
wontdo
|
||||
1
test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/title
Normal file
1
test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/title
Normal file
|
|
@ -0,0 +1 @@
|
|||
issue with dependencies
|
||||
1
test/0002/config.toml
Normal file
1
test/0002/config.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
states = [ "open", "closed" ]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Lots of words
|
||||
that don't say much
|
||||
because this is just
|
||||
a test
|
||||
1
test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state
Normal file
1
test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
wontdo
|
||||
1
test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title
Normal file
1
test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/title
Normal file
|
|
@ -0,0 +1 @@
|
|||
issues out the wazoo
|
||||
Loading…
Add table
Add a link
Reference in a new issue
❤️