From 50f2b2a1bff348efc13c04d35440e5a6dadc1d66 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Sun, 20 Jul 2025 12:45:30 -0600 Subject: [PATCH] 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. --- src/issue.rs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/issue.rs b/src/issue.rs index 06f959f..81559f4 100644 --- a/src/issue.rs +++ b/src/issue.rs @@ -137,13 +137,7 @@ impl Issue { } else if file_name == "dependencies" && direntry.metadata()?.is_dir() { dependencies = Self::read_dependencies(&direntry.path())?; } else if file_name == "tags" { - let contents = std::fs::read_to_string(direntry.path())?; - tags = contents - .lines() - .filter(|s| s.len() > 0) - .map(|tag| String::from(tag.trim())) - .collect(); - tags.sort(); + tags = Self::read_tags(&direntry)?; } else if file_name == "comments" && direntry.metadata()?.is_dir() { Self::read_comments(&mut comments, &direntry.path())?; } else { @@ -525,6 +519,21 @@ 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 { + tags.push(String::from(direntry.file_name().to_string_lossy())); + } + } + tags.sort(); + Ok(tags) + } + fn commit_tags(&self, commit_message: &str) -> Result<(), IssueError> { let mut tags_filename = self.dir.clone(); tags_filename.push("tags");