Compare commits
No commits in common. "f44d009cce5831019d40d93c21c55f4abb1b0db3" and "ba47a4bcd67cd78b5909b012b08c12498aab3383" have entirely different histories.
f44d009cce
...
ba47a4bcd6
12 changed files with 1 additions and 78 deletions
16
src/issue.rs
16
src/issue.rs
|
|
@ -5,20 +5,16 @@ 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)]
|
||||||
|
|
@ -37,8 +33,6 @@ 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" {
|
||||||
|
|
@ -56,7 +50,6 @@ 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 {
|
||||||
|
|
@ -68,12 +61,6 @@ impl Issue {
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +75,6 @@ impl Issue {
|
||||||
title: title.unwrap(),
|
title: title.unwrap(),
|
||||||
description: description,
|
description: description,
|
||||||
state: state,
|
state: state,
|
||||||
dependencies,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +91,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +103,6 @@ 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,7 +83,6 @@ 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(
|
||||||
|
|
@ -92,7 +91,6 @@ 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);
|
||||||
|
|
@ -110,7 +108,6 @@ 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(
|
||||||
|
|
@ -121,50 +118,8 @@ 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 +0,0 @@
|
||||||
done
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
oh yeah we got titles
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
3fa5bfd93317ad25772680071d5ac3259cd2384f
|
|
||||||
dd79c8cfb8beeacd0460429944b4ecbe95a31561
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
a test has begun
|
|
||||||
for dependencies we seek
|
|
||||||
intertwining life
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
wontdo
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
issue with dependencies
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
states = [ "open", "closed" ]
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
Lots of words
|
|
||||||
that don't say much
|
|
||||||
because this is just
|
|
||||||
a test
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
wontdo
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
issues out the wazoo
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue