diff --git a/Cargo.toml b/Cargo.toml index 4d2d2c5..864691a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,6 @@ edition = "2024" default = [] log = ["dep:log", "dep:simple_logger"] -[dev-dependencies] -pretty_assertions = "1.4.1" - [dependencies] anyhow = "1.0.95" chrono = "0.4.41" diff --git a/src/comment.rs b/src/comment.rs index 6424e58..e042f63 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -208,21 +208,19 @@ impl Comment { #[cfg(test)] mod tests { use super::*; - use pretty_assertions::assert_eq; #[test] fn read_comment_0() { - let comment_dir = std::path::Path::new( - "test/0001/dd79c8cfb8beeacd0460429944b4ecbe/comments/9055dac36045fe36545bed7ae7b49347", - ); + let comment_dir = + std::path::Path::new("test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/comments/9055dac36045fe36545bed7ae7b49347"); let comment = Comment::new_from_dir(comment_dir).unwrap(); let expected = Comment { uuid: String::from("9055dac36045fe36545bed7ae7b49347"), author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00") .unwrap() .with_timezone(&chrono::Local), - description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe\n\nIt has multiple lines\n"), + description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"), dir: std::path::PathBuf::from(comment_dir), }; assert_eq!(comment, expected); diff --git a/src/git.rs b/src/git.rs index 6e70fa8..3a03bac 100644 --- a/src/git.rs +++ b/src/git.rs @@ -502,7 +502,6 @@ fn create_orphan_branch_at_path( #[cfg(test)] mod tests { use super::*; - use pretty_assertions::assert_eq; #[test] fn test_worktree() { diff --git a/src/issue.rs b/src/issue.rs index 1db0792..03cca1d 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -48,10 +48,6 @@ pub enum IssueError { ChronoParseError(#[from] chrono::format::ParseError), #[error("Failed to parse issue")] 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")] StateParseError, #[error("Failed to run git")] @@ -216,6 +212,23 @@ impl Issue { Ok(dependencies) } + fn read_tags(tags_direntry: &std::fs::DirEntry) -> Result, 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::::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. pub fn add_comment( &mut self, @@ -523,60 +536,6 @@ impl Issue { Ok(()) } - fn read_tags(tags_direntry: &std::fs::DirEntry) -> Result, IssueError> { - if !tags_direntry.metadata()?.is_dir() { - eprintln!("issue has old-style tags file"); - return Err(IssueError::IssueParseError); - } - let mut tags = Vec::::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 { - 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) - } - fn commit_tags(&self, commit_message: &str) -> Result<(), IssueError> { let mut tags_filename = self.dir.clone(); tags_filename.push("tags"); @@ -601,86 +560,22 @@ impl Issue { #[cfg(test)] mod tests { use super::*; - 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 read_issue_0() { - let issue_dir = std::path::Path::new("test/0000/3943fc5c173fdf41c0a22251593cd476/"); + let issue_dir = std::path::Path::new("test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/"); let issue = Issue::new_from_dir(issue_dir).unwrap(); let expected = Issue { - id: String::from("3943fc5c173fdf41c0a22251593cd476"), + id: String::from("3943fc5c173fdf41c0a22251593cd476d96e6c9f"), author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: None, tags: Vec::::from([ - 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("tag1"), + String::from("TAG2"), + String::from("i-am-also-a-tag"), ]), state: State::New, dependencies: None, @@ -696,12 +591,12 @@ mod tests { #[test] fn read_issue_1() { - let issue_dir = std::path::Path::new("test/0000/7792b063eef6d33e7da5dc1856750c14/"); + let issue_dir = std::path::Path::new("test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/"); let issue = Issue::new_from_dir(issue_dir).unwrap(); let expected = Issue { - id: String::from("7792b063eef6d33e7da5dc1856750c14"), + id: String::from("7792b063eef6d33e7da5dc1856750c149ba678c6"), author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: None, diff --git a/src/issues.rs b/src/issues.rs index 8db4c26..a01f41c 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -87,7 +87,6 @@ impl Issues { #[cfg(test)] mod tests { use super::*; - use pretty_assertions::assert_eq; #[test] fn read_issues_0000() { @@ -96,13 +95,13 @@ mod tests { let mut expected = Issues::new(); - let uuid = String::from("7792b063eef6d33e7da5dc1856750c14"); + let uuid = String::from("7792b063eef6d33e7da5dc1856750c149ba678c6"); let mut dir = std::path::PathBuf::from(issues_dir); dir.push(&uuid); expected.add_issue(crate::issue::Issue { id: uuid, author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: None, @@ -115,26 +114,21 @@ mod tests { dir, }); - let uuid = String::from("3943fc5c173fdf41c0a22251593cd476"); + let uuid = String::from("3943fc5c173fdf41c0a22251593cd476d96e6c9f"); let mut dir = std::path::PathBuf::from(issues_dir); dir.push(&uuid); expected.add_issue( crate::issue::Issue { id: uuid, author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T12:14:26-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: None, tags: Vec::::from([ - 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("tag1"), + String::from("TAG2"), + String::from("i-am-also-a-tag") ]), state: crate::issue::State::New, dependencies: None, @@ -154,13 +148,13 @@ mod tests { let mut expected = Issues::new(); - let uuid = String::from("3fa5bfd93317ad25772680071d5ac325"); + let uuid = String::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"); let mut dir = std::path::PathBuf::from(issues_dir); dir.push(&uuid); expected.add_issue(crate::issue::Issue { id: uuid, author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: Some( @@ -177,7 +171,7 @@ mod tests { dir, }); - let uuid = String::from("dd79c8cfb8beeacd0460429944b4ecbe"); + let uuid = String::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561"); let mut dir = std::path::PathBuf::from(issues_dir); dir.push(&uuid); let mut comment_dir = dir.clone(); @@ -189,8 +183,8 @@ mod tests { crate::comment::Comment { uuid: comment_uuid, author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00").unwrap().with_timezone(&chrono::Local), - description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe\n\nIt has multiple lines\n"), + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-07T15:26:26-06:00").unwrap().with_timezone(&chrono::Local), + description: String::from("This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561\n\nIt has multiple lines\n"), dir: std::path::PathBuf::from(comment_dir), } ); @@ -198,7 +192,7 @@ mod tests { crate::issue::Issue { id: uuid, author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-03T11:59:44-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: None, @@ -221,13 +215,13 @@ mod tests { let mut expected = Issues::new(); - let uuid = String::from("3fa5bfd93317ad25772680071d5ac325"); + let uuid = String::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"); let mut dir = std::path::PathBuf::from(issues_dir); dir.push(&uuid); expected.add_issue(crate::issue::Issue { id: uuid, - author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + author: String::from("sigil-03 "), + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: None, @@ -240,14 +234,14 @@ mod tests { dir, }); - let uuid = String::from("dd79c8cfb8beeacd0460429944b4ecbe"); + let uuid = String::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561"); let mut dir = std::path::PathBuf::from(issues_dir); dir.push(&uuid); expected.add_issue( crate::issue::Issue { id: uuid, - author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + author: String::from("sigil-03 "), + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: None, @@ -261,22 +255,22 @@ mod tests { }, ); - let uuid = String::from("a85f81fc5f14cb5d4851dd445dc9744c"); + let uuid = String::from("a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7"); let mut dir = std::path::PathBuf::from(issues_dir); dir.push(&uuid); expected.add_issue( crate::issue::Issue { id: uuid, - author: String::from("Sebastian Kuzminsky "), - creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00") + author: String::from("sigil-03 "), + creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-05T13:55:49-06:00") .unwrap() .with_timezone(&chrono::Local), done_time: None, tags: Vec::::new(), state: crate::issue::State::WontDo, dependencies: Some(vec![ - crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac325"), - crate::issue::IssueHandle::from("dd79c8cfb8beeacd0460429944b4ecbe"), + crate::issue::IssueHandle::from("3fa5bfd93317ad25772680071d5ac3259cd2384f"), + crate::issue::IssueHandle::from("dd79c8cfb8beeacd0460429944b4ecbe95a31561"), ]), assignee: None, description: String::from("issue with dependencies\n\na test has begun\nfor dependencies we seek\nintertwining life"), diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/bird,1wing,1feather b/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/bird,1wing,1feather deleted file mode 100644 index e69de29..0000000 diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/deer,0antler b/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/deer,0antler deleted file mode 100644 index e69de29..0000000 diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/deer,0antler,0tassle b/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/deer,0antler,0tassle deleted file mode 100644 index e69de29..0000000 diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/hop,0scotch,1shoe b/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/hop,0scotch,1shoe deleted file mode 100644 index e69de29..0000000 diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/i-am-also-a-tag b/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/i-am-also-a-tag deleted file mode 100644 index e69de29..0000000 diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/tag1 b/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/tag1 deleted file mode 100644 index e69de29..0000000 diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/description b/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/description similarity index 100% rename from test/0000/3943fc5c173fdf41c0a22251593cd476/description rename to test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/description diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/tags b/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/tags new file mode 100644 index 0000000..04e82a6 --- /dev/null +++ b/test/0000/3943fc5c173fdf41c0a22251593cd476d96e6c9f/tags @@ -0,0 +1,3 @@ +tag1 +TAG2 +i-am-also-a-tag diff --git a/test/0000/7792b063eef6d33e7da5dc1856750c14/assignee b/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/assignee similarity index 100% rename from test/0000/7792b063eef6d33e7da5dc1856750c14/assignee rename to test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/assignee diff --git a/test/0000/7792b063eef6d33e7da5dc1856750c14/description b/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/description similarity index 100% rename from test/0000/7792b063eef6d33e7da5dc1856750c14/description rename to test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/description diff --git a/test/0000/7792b063eef6d33e7da5dc1856750c14/state b/test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/state similarity index 100% rename from test/0000/7792b063eef6d33e7da5dc1856750c14/state rename to test/0000/7792b063eef6d33e7da5dc1856750c149ba678c6/state diff --git a/test/0001/3fa5bfd93317ad25772680071d5ac325/description b/test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/description similarity index 100% rename from test/0001/3fa5bfd93317ad25772680071d5ac325/description rename to test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/description diff --git a/test/0001/3fa5bfd93317ad25772680071d5ac325/done_time b/test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/done_time similarity index 100% rename from test/0001/3fa5bfd93317ad25772680071d5ac325/done_time rename to test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/done_time diff --git a/test/0001/3fa5bfd93317ad25772680071d5ac325/state b/test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/state similarity index 100% rename from test/0001/3fa5bfd93317ad25772680071d5ac325/state rename to test/0001/3fa5bfd93317ad25772680071d5ac3259cd2384f/state diff --git a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe/comments/9055dac36045fe36545bed7ae7b49347/description b/test/0001/dd79c8cfb8beeacd0460429944b4ecbe/comments/9055dac36045fe36545bed7ae7b49347/description deleted file mode 100644 index daa3d62..0000000 --- a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe/comments/9055dac36045fe36545bed7ae7b49347/description +++ /dev/null @@ -1,3 +0,0 @@ -This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe - -It has multiple lines diff --git a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/comments/9055dac36045fe36545bed7ae7b49347/description b/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/comments/9055dac36045fe36545bed7ae7b49347/description new file mode 100644 index 0000000..f9de678 --- /dev/null +++ b/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/comments/9055dac36045fe36545bed7ae7b49347/description @@ -0,0 +1,3 @@ +This is a comment on issue dd79c8cfb8beeacd0460429944b4ecbe95a31561 + +It has multiple lines diff --git a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe/description b/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description similarity index 100% rename from test/0001/dd79c8cfb8beeacd0460429944b4ecbe/description rename to test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description diff --git a/test/0001/dd79c8cfb8beeacd0460429944b4ecbe/state b/test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state similarity index 100% rename from test/0001/dd79c8cfb8beeacd0460429944b4ecbe/state rename to test/0001/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state diff --git a/test/0002/3fa5bfd93317ad25772680071d5ac325/description b/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/description similarity index 100% rename from test/0002/3fa5bfd93317ad25772680071d5ac325/description rename to test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/description diff --git a/test/0002/3fa5bfd93317ad25772680071d5ac325/state b/test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/state similarity index 100% rename from test/0002/3fa5bfd93317ad25772680071d5ac325/state rename to test/0002/3fa5bfd93317ad25772680071d5ac3259cd2384f/state diff --git a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c/dependencies/3fa5bfd93317ad25772680071d5ac325 b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c/dependencies/3fa5bfd93317ad25772680071d5ac325 deleted file mode 100644 index e69de29..0000000 diff --git a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c/dependencies/dd79c8cfb8beeacd0460429944b4ecbe b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c/dependencies/dd79c8cfb8beeacd0460429944b4ecbe deleted file mode 100644 index e69de29..0000000 diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/TAG2 b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/dependencies/3fa5bfd93317ad25772680071d5ac3259cd2384f similarity index 100% rename from test/0000/3943fc5c173fdf41c0a22251593cd476/tags/TAG2 rename to test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/dependencies/3fa5bfd93317ad25772680071d5ac3259cd2384f diff --git a/test/0000/3943fc5c173fdf41c0a22251593cd476/tags/bird,1wing b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/dependencies/dd79c8cfb8beeacd0460429944b4ecbe95a31561 similarity index 100% rename from test/0000/3943fc5c173fdf41c0a22251593cd476/tags/bird,1wing rename to test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/dependencies/dd79c8cfb8beeacd0460429944b4ecbe95a31561 diff --git a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c/description b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description similarity index 100% rename from test/0002/a85f81fc5f14cb5d4851dd445dc9744c/description rename to test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/description diff --git a/test/0002/a85f81fc5f14cb5d4851dd445dc9744c/state b/test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/state similarity index 100% rename from test/0002/a85f81fc5f14cb5d4851dd445dc9744c/state rename to test/0002/a85f81fc5f14cb5d4851dd445dc9744c7f16ccc7/state diff --git a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe/description b/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description similarity index 100% rename from test/0002/dd79c8cfb8beeacd0460429944b4ecbe/description rename to test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/description diff --git a/test/0002/dd79c8cfb8beeacd0460429944b4ecbe/state b/test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state similarity index 100% rename from test/0002/dd79c8cfb8beeacd0460429944b4ecbe/state rename to test/0002/dd79c8cfb8beeacd0460429944b4ecbe95a31561/state diff --git a/tools/update-tags-encoding b/tools/update-tags-encoding index c06ba74..87c5a5d 100755 --- a/tools/update-tags-encoding +++ b/tools/update-tags-encoding @@ -1,41 +1,17 @@ #!/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 +# For each issue with a `tags` file: +# read set -e #set -x -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. +WORKTREE_DIR=$(mktemp --directory) +git worktree add "${WORKTREE_DIR}" entomologist-data +pushd "${WORKTREE_DIR}" > /dev/null 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 @@ -44,28 +20,16 @@ for ISSUE_ID in $(find . -maxdepth 1 -type d -regextype posix-extended -regex '\ echo "${ISSUE_ID} has tags:" TAGS=$(cat tags) - echo "${TAGS}" - rm tags - - if [[ -n "${BRANCH}" ]]; then - git rm -f tags - fi - + git rm tags mkdir tags for TAG in ${TAGS}; do touch "tags/${TAG}" done - - if [[ -n "${BRANCH}" ]]; then - git add tags - git commit -m "issue ${ISSUE_ID}: update tags to new format" - fi + git add tags + #git commit -m "issue ${ISSUE_ID}: update tags to new format" popd > /dev/null done popd > /dev/null - -if [[ -n "${BRANCH}" ]]; then - git worktree remove "${WORKTREE_DIR}" -fi +git worktree remove "${WORKTREE_DIR}"