tags is now a directory with a file per tag
This is more conflict resistant than the old encoding where tags was a file with a line per tag.
This commit is contained in:
parent
3b64acbf3f
commit
a57482f662
1 changed files with 18 additions and 7 deletions
25
src/issue.rs
25
src/issue.rs
|
|
@ -137,13 +137,7 @@ impl Issue {
|
||||||
} else if file_name == "dependencies" && direntry.metadata()?.is_dir() {
|
} else if file_name == "dependencies" && direntry.metadata()?.is_dir() {
|
||||||
dependencies = Self::read_dependencies(&direntry.path())?;
|
dependencies = Self::read_dependencies(&direntry.path())?;
|
||||||
} else if file_name == "tags" {
|
} else if file_name == "tags" {
|
||||||
let contents = std::fs::read_to_string(direntry.path())?;
|
tags = Self::read_tags(&direntry)?;
|
||||||
tags = contents
|
|
||||||
.lines()
|
|
||||||
.filter(|s| s.len() > 0)
|
|
||||||
.map(|tag| String::from(tag.trim()))
|
|
||||||
.collect();
|
|
||||||
tags.sort();
|
|
||||||
} else if file_name == "comments" && direntry.metadata()?.is_dir() {
|
} else if file_name == "comments" && direntry.metadata()?.is_dir() {
|
||||||
Self::read_comments(&mut comments, &direntry.path())?;
|
Self::read_comments(&mut comments, &direntry.path())?;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -218,6 +212,23 @@ impl Issue {
|
||||||
Ok(dependencies)
|
Ok(dependencies)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_tags(tags_direntry: &std::fs::DirEntry) -> Result<Vec<String>, IssueError> {
|
||||||
|
if !tags_direntry.metadata()?.is_dir() {
|
||||||
|
eprintln!("issue has old-style tags file");
|
||||||
|
return Err(IssueError::StdIoError(std::io::Error::from(
|
||||||
|
std::io::ErrorKind::NotADirectory,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
let mut tags = Vec::<String>::new();
|
||||||
|
for direntry in tags_direntry.path().read_dir()? {
|
||||||
|
if let Ok(direntry) = direntry {
|
||||||
|
tags.push(String::from(direntry.file_name().to_string_lossy()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tags.sort();
|
||||||
|
Ok(tags)
|
||||||
|
}
|
||||||
|
|
||||||
/// Add a new Comment to the Issue. Commits.
|
/// Add a new Comment to the Issue. Commits.
|
||||||
pub fn add_comment(
|
pub fn add_comment(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue