Add Dependency Tracking to Issue Type #1
12 changed files with 78 additions and 1 deletions
18
src/issue.rs
18
src/issue.rs
|
|
@ -5,16 +5,20 @@ use std::str::FromStr;
|
||||||
pub enum State {
|
pub enum State {
|
||||||
New,
|
New,
|
||||||
Backlog,
|
Backlog,
|
||||||
|
Blocked,
|
||||||
InProgress,
|
InProgress,
|
||||||
Done,
|
Done,
|
||||||
WontDo,
|
WontDo,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type IssueHandle = String;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Issue {
|
pub struct Issue {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
pub state: State,
|
pub state: State,
|
||||||
|
pub dependencies: Option<Vec<IssueHandle>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
|
@ -33,6 +37,8 @@ impl FromStr for State {
|
||||||
Ok(State::New)
|
Ok(State::New)
|
||||||
} else if s == "backlog" {
|
} else if s == "backlog" {
|
||||||
Ok(State::Backlog)
|
Ok(State::Backlog)
|
||||||
|
} else if s == "blocked" {
|
||||||
|
Ok(State::Blocked)
|
||||||
} else if s == "inprogress" {
|
} else if s == "inprogress" {
|
||||||
Ok(State::InProgress)
|
Ok(State::InProgress)
|
||||||
} else if s == "done" {
|
} else if s == "done" {
|
||||||
|
|
@ -50,6 +56,7 @@ impl Issue {
|
||||||
let mut title: Option<String> = None;
|
let mut title: Option<String> = None;
|
||||||
let mut description: Option<String> = None;
|
let mut description: Option<String> = None;
|
||||||
let mut state = State::New; // default state, if not specified in the issue
|
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()? {
|
for direntry in dir.read_dir()? {
|
||||||
if let Ok(direntry) = direntry {
|
if let Ok(direntry) = direntry {
|
||||||
|
|
@ -60,7 +67,13 @@ impl Issue {
|
||||||
description = Some(std::fs::read_to_string(direntry.path())?);
|
description = Some(std::fs::read_to_string(direntry.path())?);
|
||||||
} else if file_name == "state" {
|
} else if file_name == "state" {
|
||||||
let state_string = std::fs::read_to_string(direntry.path())?;
|
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<IssueHandle> = dep_strings.lines().map(|dep|{IssueHandle::from(dep)}).collect();
|
||||||
|
if deps.len() > 0 {
|
||||||
|
dependencies = Some(deps);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("ignoring unknown file in issue directory: {:?}", file_name);
|
println!("ignoring unknown file in issue directory: {:?}", file_name);
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +88,7 @@ impl Issue {
|
||||||
title: title.unwrap(),
|
title: title.unwrap(),
|
||||||
description: description,
|
description: description,
|
||||||
state: state,
|
state: state,
|
||||||
|
dependencies,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -91,6 +105,7 @@ mod tests {
|
||||||
title: String::from("this is the title of my 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: 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,
|
state: State::New,
|
||||||
|
dependencies: None,
|
||||||
};
|
};
|
||||||
assert_eq!(issue, expected);
|
assert_eq!(issue, expected);
|
||||||
}
|
}
|
||||||
|
|
@ -103,6 +118,7 @@ mod tests {
|
||||||
title: String::from("minimal"),
|
title: String::from("minimal"),
|
||||||
description: None,
|
description: None,
|
||||||
state: State::InProgress,
|
state: State::InProgress,
|
||||||
|
dependencies: None,
|
||||||
};
|
};
|
||||||
assert_eq!(issue, expected);
|
assert_eq!(issue, expected);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ mod tests {
|
||||||
title: String::from("minimal"),
|
title: String::from("minimal"),
|
||||||
description: None,
|
description: None,
|
||||||
state: crate::issue::State::InProgress,
|
state: crate::issue::State::InProgress,
|
||||||
|
dependencies: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expected.add_issue(
|
expected.add_issue(
|
||||||
|
|
@ -91,6 +92,7 @@ mod tests {
|
||||||
title: String::from("this is the title of my 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: 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,
|
state: crate::issue::State::New,
|
||||||
|
dependencies: None,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert_eq!(issues, expected);
|
assert_eq!(issues, expected);
|
||||||
|
|
@ -108,6 +110,7 @@ mod tests {
|
||||||
title: String::from("oh yeah we got titles"),
|
title: String::from("oh yeah we got titles"),
|
||||||
description: None,
|
description: None,
|
||||||
state: crate::issue::State::Done,
|
state: crate::issue::State::Done,
|
||||||
|
dependencies: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
expected.add_issue(
|
expected.add_issue(
|
||||||
|
|
@ -118,8 +121,50 @@ mod tests {
|
||||||
"Lots of words\nthat don't say much\nbecause this is just\na test\n",
|
"Lots of words\nthat don't say much\nbecause this is just\na test\n",
|
||||||
)),
|
)),
|
||||||
state: crate::issue::State::WontDo,
|
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);
|
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
❤️