Compare commits
15 commits
b1c32fbf63
...
bedcc8a352
| Author | SHA1 | Date | |
|---|---|---|---|
| bedcc8a352 | |||
| 87f6b42595 | |||
| 9b941fdbda | |||
| bc72061d14 | |||
| 99d19e0fd9 | |||
| 485f88c686 | |||
| 50f2b2a1bf | |||
| fad23ba233 | |||
| b3903a9ed2 | |||
| b3f5aaeb76 | |||
| 598f4e5df8 | |||
| 05c7c6f441 | |||
| 694d127638 | |||
| 4683760942 | |||
| ef8a648cf8 |
32 changed files with 294 additions and 45 deletions
|
|
@ -212,16 +212,17 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read_comment_0() {
|
fn read_comment_0() {
|
||||||
let comment_dir =
|
let comment_dir = std::path::Path::new(
|
||||||
std::path::Path::new("test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/comments/9055dac36045fe36545bed7ae7b49347");
|
"test/0001/dd79c8cfb8beeacd0460429944b4ecbe/comments/9055dac36045fe36545bed7ae7b49347",
|
||||||
|
);
|
||||||
let comment = Comment::new_from_dir(comment_dir).unwrap();
|
let comment = Comment::new_from_dir(comment_dir).unwrap();
|
||||||
let expected = Comment {
|
let expected = Comment {
|
||||||
uuid: String::from("9055dac36045fe36545bed7ae7b49347"),
|
uuid: String::from("9055dac36045fe36545bed7ae7b49347"),
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T10:08:38-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"),
|
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe\n\nIt has multiple lines\n"),
|
||||||
dir: std::path::PathBuf::from(comment_dir),
|
dir: std::path::PathBuf::from(comment_dir),
|
||||||
};
|
};
|
||||||
assert_eq!(comment, expected);
|
assert_eq!(comment, expected);
|
||||||
|
|
|
||||||
201
src/issue.rs
201
src/issue.rs
|
|
@ -48,6 +48,10 @@ pub enum IssueError {
|
||||||
ChronoParseError(#[from] chrono::format::ParseError),
|
ChronoParseError(#[from] chrono::format::ParseError),
|
||||||
#[error("Failed to parse issue")]
|
#[error("Failed to parse issue")]
|
||||||
IssueParseError,
|
IssueParseError,
|
||||||
|
#[error("invalid escape character {escape:?} in tag file {filename:?}")]
|
||||||
|
TagInvalidEscape { escape: String, filename: String },
|
||||||
|
#[error("invalid trailing escape character ',' in tag file {filename:?}")]
|
||||||
|
TagTrailingEscape { filename: String },
|
||||||
#[error("Failed to parse state")]
|
#[error("Failed to parse state")]
|
||||||
StateParseError,
|
StateParseError,
|
||||||
#[error("Failed to run git")]
|
#[error("Failed to run git")]
|
||||||
|
|
@ -137,13 +141,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 {
|
||||||
|
|
@ -525,12 +523,82 @@ impl Issue {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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::IssueParseError);
|
||||||
|
}
|
||||||
|
let mut tags = Vec::<String>::new();
|
||||||
|
for direntry in tags_direntry.path().read_dir()? {
|
||||||
|
if let Ok(direntry) = direntry {
|
||||||
|
let tag = Issue::tag_from_filename(&direntry.file_name().to_string_lossy())?;
|
||||||
|
tags.push(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tags.sort();
|
||||||
|
Ok(tags)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Perform un-escape on a filename to make it into a tag:
|
||||||
|
/// ",0" => ","
|
||||||
|
/// ",1" => "/"
|
||||||
|
fn tag_from_filename(filename: &str) -> Result<String, IssueError> {
|
||||||
|
let mut tag = String::new();
|
||||||
|
let mut token_iter = filename.split(',');
|
||||||
|
let Some(start) = token_iter.next() else {
|
||||||
|
return Err(IssueError::StdIoError(std::io::Error::from(
|
||||||
|
std::io::ErrorKind::NotFound,
|
||||||
|
)));
|
||||||
|
};
|
||||||
|
tag.push_str(start);
|
||||||
|
for token in token_iter {
|
||||||
|
match token.chars().nth(0) {
|
||||||
|
Some('0') => {
|
||||||
|
tag.push(',');
|
||||||
|
tag.push_str(&token[1..]);
|
||||||
|
}
|
||||||
|
Some('1') => {
|
||||||
|
tag.push('/');
|
||||||
|
tag.push_str(&token[1..]);
|
||||||
|
}
|
||||||
|
Some(bogus) => {
|
||||||
|
return Err(IssueError::TagInvalidEscape {
|
||||||
|
escape: String::from(bogus),
|
||||||
|
filename: String::from(filename),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
return Err(IssueError::TagTrailingEscape {
|
||||||
|
filename: String::from(filename),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform escape on a tag to make it into a filename:
|
||||||
|
// "," => ",0"
|
||||||
|
// "/" => ",1"
|
||||||
|
fn tag_to_filename(tag: &str) -> String {
|
||||||
|
let mut filename = tag.replace(",", ",0");
|
||||||
|
filename = filename.replace("/", ",1");
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
fn commit_tags(&self, commit_message: &str) -> Result<(), IssueError> {
|
fn commit_tags(&self, commit_message: &str) -> Result<(), IssueError> {
|
||||||
let mut tags_filename = self.dir.clone();
|
let mut tags_dir_name = self.dir.clone();
|
||||||
tags_filename.push("tags");
|
tags_dir_name.push("tags");
|
||||||
let mut tags_file = std::fs::File::create(&tags_filename)?;
|
match std::fs::remove_dir_all(&tags_dir_name) {
|
||||||
|
Err(e) if e.kind() == std::io::ErrorKind::NotFound => (),
|
||||||
|
Err(e) => return Err(e.into()),
|
||||||
|
Ok(_) => (),
|
||||||
|
}
|
||||||
|
std::fs::create_dir(&tags_dir_name)?;
|
||||||
for tag in &self.tags {
|
for tag in &self.tags {
|
||||||
writeln!(tags_file, "{}", tag)?;
|
let mut tag_filename = tags_dir_name.clone();
|
||||||
|
tag_filename.push(Issue::tag_to_filename(tag));
|
||||||
|
std::fs::File::create(&tag_filename)?;
|
||||||
}
|
}
|
||||||
self.commit(commit_message)?;
|
self.commit(commit_message)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -551,19 +619,118 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_tag_0() {
|
||||||
|
assert_eq!(
|
||||||
|
Issue::tag_from_filename("hello").unwrap(),
|
||||||
|
String::from("hello")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_tag_1() {
|
||||||
|
assert_eq!(
|
||||||
|
Issue::tag_from_filename("hello,0world").unwrap(),
|
||||||
|
String::from("hello,world")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_tag_2() {
|
||||||
|
assert_eq!(
|
||||||
|
Issue::tag_from_filename("hello,1world").unwrap(),
|
||||||
|
String::from("hello/world")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_tag_3() {
|
||||||
|
assert_eq!(
|
||||||
|
Issue::tag_from_filename(",0hello,1world,0").unwrap(),
|
||||||
|
String::from(",hello/world,")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_tag_4() {
|
||||||
|
// std::io::Error does not impl PartialEq :-(
|
||||||
|
let filename = "hello,";
|
||||||
|
match Issue::tag_from_filename(filename) {
|
||||||
|
Ok(tag) => panic!(
|
||||||
|
"tag_from_filename() accepted invalid input {:?} and returned {:?}",
|
||||||
|
filename, tag
|
||||||
|
),
|
||||||
|
Err(_e) => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn parse_tag_5() {
|
||||||
|
// std::io::Error does not impl PartialEq :-(
|
||||||
|
let filename = "hello,world";
|
||||||
|
match Issue::tag_from_filename(filename) {
|
||||||
|
Ok(tag) => panic!(
|
||||||
|
"tag_from_filename() accepted invalid input {:?} and returned {:?}",
|
||||||
|
filename, tag
|
||||||
|
),
|
||||||
|
Err(_e) => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tag_to_filename_0() {
|
||||||
|
let tag = "hello";
|
||||||
|
assert_eq!(Issue::tag_to_filename(tag), "hello");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tag_to_filename_1() {
|
||||||
|
let tag = "hello,";
|
||||||
|
assert_eq!(Issue::tag_to_filename(tag), "hello,0");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tag_to_filename_2() {
|
||||||
|
let tag = "/hello";
|
||||||
|
assert_eq!(Issue::tag_to_filename(tag), ",1hello");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tag_to_filename_3() {
|
||||||
|
let tag = "hello/bye,boo";
|
||||||
|
assert_eq!(Issue::tag_to_filename(tag), "hello,1bye,0boo");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tag_to_filename_4() {
|
||||||
|
let tag = ",,,///,,,";
|
||||||
|
assert_eq!(Issue::tag_to_filename(tag), ",0,0,0,1,1,1,0,0,0");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn tag_to_filename_5() {
|
||||||
|
let tag = ",0,0,1,1";
|
||||||
|
assert_eq!(Issue::tag_to_filename(tag), ",00,00,01,01");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read_issue_0() {
|
fn read_issue_0() {
|
||||||
let issue_dir = std::path::Path::new("test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/");
|
let issue_dir = std::path::Path::new("test/0000/3943fc5c173fdf41c0a22251593cd476/");
|
||||||
let issue = Issue::new_from_dir(issue_dir).unwrap();
|
let issue = Issue::new_from_dir(issue_dir).unwrap();
|
||||||
let expected = Issue {
|
let expected = Issue {
|
||||||
id: String::from("3943fc5c173fdf41c0a22251593cd476d96e6c9f"),
|
id: String::from("3943fc5c173fdf41c0a22251593cd476"),
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:36:25-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
tags: Vec::<String>::from([
|
tags: Vec::<String>::from([
|
||||||
String::from("TAG2"),
|
String::from("TAG2"),
|
||||||
|
String::from("bird/wing"),
|
||||||
|
String::from("bird/wing/feather"),
|
||||||
|
String::from("deer,antler"),
|
||||||
|
String::from("deer,antler,tassle"),
|
||||||
|
String::from("hop,scotch/shoe"),
|
||||||
String::from("i-am-also-a-tag"),
|
String::from("i-am-also-a-tag"),
|
||||||
String::from("tag1"),
|
String::from("tag1"),
|
||||||
]),
|
]),
|
||||||
|
|
@ -581,12 +748,12 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn read_issue_1() {
|
fn read_issue_1() {
|
||||||
let issue_dir = std::path::Path::new("test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/");
|
let issue_dir = std::path::Path::new("test/0000/7792b063eef6d33e7da5dc1856750c14/");
|
||||||
let issue = Issue::new_from_dir(issue_dir).unwrap();
|
let issue = Issue::new_from_dir(issue_dir).unwrap();
|
||||||
let expected = Issue {
|
let expected = Issue {
|
||||||
id: String::from("7792b063eef6d33e7da5dc1856750c149ba678c6"),
|
id: String::from("7792b063eef6d33e7da5dc1856750c14"),
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:37:07-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
|
||||||
|
|
@ -96,13 +96,13 @@ mod tests {
|
||||||
|
|
||||||
let mut expected = Issues::new();
|
let mut expected = Issues::new();
|
||||||
|
|
||||||
let uuid = String::from("7792b063eef6d33e7da5dc1856750c149ba678c6");
|
let uuid = String::from("7792b063eef6d33e7da5dc1856750c14");
|
||||||
let mut dir = std::path::PathBuf::from(issues_dir);
|
let mut dir = std::path::PathBuf::from(issues_dir);
|
||||||
dir.push(&uuid);
|
dir.push(&uuid);
|
||||||
expected.add_issue(crate::issue::Issue {
|
expected.add_issue(crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:37:07-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -115,19 +115,24 @@ mod tests {
|
||||||
dir,
|
dir,
|
||||||
});
|
});
|
||||||
|
|
||||||
let uuid = String::from("3943fc5c173fdf41c0a22251593cd476d96e6c9f");
|
let uuid = String::from("3943fc5c173fdf41c0a22251593cd476");
|
||||||
let mut dir = std::path::PathBuf::from(issues_dir);
|
let mut dir = std::path::PathBuf::from(issues_dir);
|
||||||
dir.push(&uuid);
|
dir.push(&uuid);
|
||||||
expected.add_issue(
|
expected.add_issue(
|
||||||
crate::issue::Issue {
|
crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:36:25-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
tags: Vec::<String>::from([
|
tags: Vec::<String>::from([
|
||||||
String::from("TAG2"),
|
String::from("TAG2"),
|
||||||
|
String::from("bird/wing"),
|
||||||
|
String::from("bird/wing/feather"),
|
||||||
|
String::from("deer,antler"),
|
||||||
|
String::from("deer,antler,tassle"),
|
||||||
|
String::from("hop,scotch/shoe"),
|
||||||
String::from("i-am-also-a-tag"),
|
String::from("i-am-also-a-tag"),
|
||||||
String::from("tag1"),
|
String::from("tag1"),
|
||||||
]),
|
]),
|
||||||
|
|
@ -149,13 +154,13 @@ mod tests {
|
||||||
|
|
||||||
let mut expected = Issues::new();
|
let mut expected = Issues::new();
|
||||||
|
|
||||||
let uuid = String::from("3fa5bfd93317ad25772680071d5ac3259cd2384f");
|
let uuid = String::from("3fa5bfd93317ad25772680071d5ac325");
|
||||||
let mut dir = std::path::PathBuf::from(issues_dir);
|
let mut dir = std::path::PathBuf::from(issues_dir);
|
||||||
dir.push(&uuid);
|
dir.push(&uuid);
|
||||||
expected.add_issue(crate::issue::Issue {
|
expected.add_issue(crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:37:46-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: Some(
|
done_time: Some(
|
||||||
|
|
@ -172,7 +177,7 @@ mod tests {
|
||||||
dir,
|
dir,
|
||||||
});
|
});
|
||||||
|
|
||||||
let uuid = String::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561");
|
let uuid = String::from("dd79c8cfb8beeacd0460429944b4ecbe");
|
||||||
let mut dir = std::path::PathBuf::from(issues_dir);
|
let mut dir = std::path::PathBuf::from(issues_dir);
|
||||||
dir.push(&uuid);
|
dir.push(&uuid);
|
||||||
let mut comment_dir = dir.clone();
|
let mut comment_dir = dir.clone();
|
||||||
|
|
@ -184,8 +189,8 @@ mod tests {
|
||||||
crate::comment::Comment {
|
crate::comment::Comment {
|
||||||
uuid: comment_uuid,
|
uuid: comment_uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00").unwrap().with_timezone(&chrono::Local),
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T10:08:38-06:00").unwrap().with_timezone(&chrono::Local),
|
||||||
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"),
|
description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe\n\nIt has multiple lines\n"),
|
||||||
dir: std::path::PathBuf::from(comment_dir),
|
dir: std::path::PathBuf::from(comment_dir),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -193,7 +198,7 @@ mod tests {
|
||||||
crate::issue::Issue {
|
crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
author: String::from("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T10:08:24-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -216,13 +221,13 @@ mod tests {
|
||||||
|
|
||||||
let mut expected = Issues::new();
|
let mut expected = Issues::new();
|
||||||
|
|
||||||
let uuid = String::from("3fa5bfd93317ad25772680071d5ac3259cd2384f");
|
let uuid = String::from("3fa5bfd93317ad25772680071d5ac325");
|
||||||
let mut dir = std::path::PathBuf::from(issues_dir);
|
let mut dir = std::path::PathBuf::from(issues_dir);
|
||||||
dir.push(&uuid);
|
dir.push(&uuid);
|
||||||
expected.add_issue(crate::issue::Issue {
|
expected.add_issue(crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:38:40-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -235,14 +240,14 @@ mod tests {
|
||||||
dir,
|
dir,
|
||||||
});
|
});
|
||||||
|
|
||||||
let uuid = String::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561");
|
let uuid = String::from("dd79c8cfb8beeacd0460429944b4ecbe");
|
||||||
let mut dir = std::path::PathBuf::from(issues_dir);
|
let mut dir = std::path::PathBuf::from(issues_dir);
|
||||||
dir.push(&uuid);
|
dir.push(&uuid);
|
||||||
expected.add_issue(
|
expected.add_issue(
|
||||||
crate::issue::Issue {
|
crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:39:20-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -256,22 +261,22 @@ mod tests {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let uuid = String::from("a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7");
|
let uuid = String::from("a85f81fc5f14cb5d4851dd445dc9744c");
|
||||||
let mut dir = std::path::PathBuf::from(issues_dir);
|
let mut dir = std::path::PathBuf::from(issues_dir);
|
||||||
dir.push(&uuid);
|
dir.push(&uuid);
|
||||||
expected.add_issue(
|
expected.add_issue(
|
||||||
crate::issue::Issue {
|
crate::issue::Issue {
|
||||||
id: uuid,
|
id: uuid,
|
||||||
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
author: String::from("sigil-03 <sigil@glyphs.tech>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:39:02-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
tags: Vec::<String>::new(),
|
tags: Vec::<String>::new(),
|
||||||
state: crate::issue::State::WontDo,
|
state: crate::issue::State::WontDo,
|
||||||
dependencies: Some(vec![
|
dependencies: Some(vec![
|
||||||
crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"),
|
crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac325"),
|
||||||
crate::issue::IssueHandle::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561"),
|
crate::issue::IssueHandle::from("dd79c8cfb8beeacd0460429944b4ecbe"),
|
||||||
]),
|
]),
|
||||||
assignee: None,
|
assignee: None,
|
||||||
description: String::from("issue with dependencies\n\na test has begun\nfor dependencies we seek\nintertwining life"),
|
description: String::from("issue with dependencies\n\na test has begun\nfor dependencies we seek\nintertwining life"),
|
||||||
|
|
|
||||||
0
test/0000/3943fc5c173fdf41c0a22251593cd476/tags/tag1
Normal file
0
test/0000/3943fc5c173fdf41c0a22251593cd476/tags/tag1
Normal file
|
|
@ -1,3 +0,0 @@
|
||||||
tag1
|
|
||||||
TAG2
|
|
||||||
i-am-also-a-tag
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe
|
||||||
|
|
||||||
|
It has multiple lines
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561
|
|
||||||
|
|
||||||
It has multiple lines
|
|
||||||
79
tools/update-tags-encoding
Executable file
79
tools/update-tags-encoding
Executable file
|
|
@ -0,0 +1,79 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Check out the `entomologist-data` branch in a temporary worktree.
|
||||||
|
# For each issue with a `tags` file, replace the old-style tags file with a new-style tags dir.
|
||||||
|
# git commit
|
||||||
|
|
||||||
|
set -e
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
function escape_tag() {
|
||||||
|
TAG="$1"
|
||||||
|
TAG=$(echo "${TAG}" | sed -re 's/,/,0/g')
|
||||||
|
TAG=$(echo "${TAG}" | sed -re 's/\//,1/g')
|
||||||
|
echo "${TAG}"
|
||||||
|
}
|
||||||
|
|
||||||
|
BRANCH=""
|
||||||
|
|
||||||
|
if [[ -n "$1" ]] && [[ -d "$1" ]]; then
|
||||||
|
echo "updating ent db in directory '$1'"
|
||||||
|
pushd "$1"
|
||||||
|
else
|
||||||
|
if [[ -n "$1" ]]; then
|
||||||
|
# better be a branch
|
||||||
|
BRANCH="$1"
|
||||||
|
else
|
||||||
|
BRANCH="entomologist-data"
|
||||||
|
fi
|
||||||
|
echo "updating ent db in branch '${BRANCH}'"
|
||||||
|
WORKTREE_DIR=$(mktemp --directory)
|
||||||
|
git worktree add "${WORKTREE_DIR}" "${BRANCH}"
|
||||||
|
pushd "${WORKTREE_DIR}" > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Now our current working directory is the ent db that we're supposed
|
||||||
|
# to update.
|
||||||
|
#
|
||||||
|
# If $BRANCH is empty, we're in a directory not tracked by git and we
|
||||||
|
# just change the files.
|
||||||
|
#
|
||||||
|
# If $BRANCH is not empty, we're in a git worktree of the branch we're
|
||||||
|
# supposed to change, so we commit as we go.
|
||||||
|
|
||||||
|
for ISSUE_ID in $(find . -maxdepth 1 -type d -regextype posix-extended -regex '\./[0-9a-f]{32}'); do
|
||||||
|
ISSUE_ID=$(basename "${ISSUE_ID}")
|
||||||
|
if ! [[ -f "${ISSUE_ID}/tags" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd "${ISSUE_ID}" > /dev/null
|
||||||
|
|
||||||
|
echo "${ISSUE_ID} has tags:"
|
||||||
|
TAGS=$(cat tags)
|
||||||
|
echo "${TAGS}"
|
||||||
|
rm tags
|
||||||
|
|
||||||
|
if [[ -n "${BRANCH}" ]]; then
|
||||||
|
git rm -f tags
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir tags
|
||||||
|
for TAG in ${TAGS}; do
|
||||||
|
TAG=$(escape_tag "${TAG}")
|
||||||
|
touch "tags/${TAG}"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n "${BRANCH}" ]]; then
|
||||||
|
git add tags
|
||||||
|
git commit -m "issue ${ISSUE_ID}: update tags to new format"
|
||||||
|
fi
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
|
||||||
|
if [[ -n "${BRANCH}" ]]; then
|
||||||
|
git worktree remove "${WORKTREE_DIR}"
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue