Compare commits
2 commits
6b27a560e3
...
6ddf787d9e
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ddf787d9e | |||
| 35b68bbca1 |
2 changed files with 53 additions and 6 deletions
24
src/issue.rs
24
src/issue.rs
|
|
@ -137,12 +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();
|
|
||||||
} 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 {
|
||||||
|
|
@ -217,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,
|
||||||
|
|
|
||||||
35
tools/update-tags-encoding
Executable file
35
tools/update-tags-encoding
Executable file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Check out the `entomologist-data` branch in a temporary worktree.
|
||||||
|
# For each issue with a `tags` file:
|
||||||
|
# read
|
||||||
|
|
||||||
|
set -e
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
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
|
||||||
|
if ! [[ -f "${ISSUE_ID}/tags" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd "${ISSUE_ID}" > /dev/null
|
||||||
|
|
||||||
|
echo "${ISSUE_ID} has tags:"
|
||||||
|
TAGS=$(cat tags)
|
||||||
|
git rm tags
|
||||||
|
mkdir tags
|
||||||
|
for TAG in ${TAGS}; do
|
||||||
|
touch "tags/${TAG}"
|
||||||
|
done
|
||||||
|
git add tags
|
||||||
|
#git commit -m "issue ${ISSUE_ID}: update tags to new format"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
git worktree remove "${WORKTREE_DIR}"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue