Compare commits
7 commits
bedcc8a352
...
b1c32fbf63
| Author | SHA1 | Date | |
|---|---|---|---|
| b1c32fbf63 | |||
| eace6ca35d | |||
| 64979ad603 | |||
| 36ba5c3a12 | |||
| a57482f662 | |||
| 3b64acbf3f | |||
| 64b64efddc |
4 changed files with 18 additions and 78 deletions
|
|
@ -219,7 +219,7 @@ mod tests {
|
||||||
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-24T10:08:38-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.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 dd79c8cfb8beeacd0460429944b4ecbe\n\nIt has multiple lines\n"),
|
||||||
|
|
|
||||||
64
src/issue.rs
64
src/issue.rs
|
|
@ -577,28 +577,12 @@ impl Issue {
|
||||||
Ok(tag)
|
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_dir_name = self.dir.clone();
|
let mut tags_filename = self.dir.clone();
|
||||||
tags_dir_name.push("tags");
|
tags_filename.push("tags");
|
||||||
match std::fs::remove_dir_all(&tags_dir_name) {
|
let mut tags_file = std::fs::File::create(&tags_filename)?;
|
||||||
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 {
|
||||||
let mut tag_filename = tags_dir_name.clone();
|
writeln!(tags_file, "{}", tag)?;
|
||||||
tag_filename.push(Issue::tag_to_filename(tag));
|
|
||||||
std::fs::File::create(&tag_filename)?;
|
|
||||||
}
|
}
|
||||||
self.commit(commit_message)?;
|
self.commit(commit_message)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -677,42 +661,6 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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/3943fc5c173fdf41c0a22251593cd476/");
|
let issue_dir = std::path::Path::new("test/0000/3943fc5c173fdf41c0a22251593cd476/");
|
||||||
|
|
@ -720,7 +668,7 @@ mod tests {
|
||||||
let expected = Issue {
|
let expected = Issue {
|
||||||
id: String::from("3943fc5c173fdf41c0a22251593cd476"),
|
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-24T08:36:25-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -753,7 +701,7 @@ mod tests {
|
||||||
let expected = Issue {
|
let expected = Issue {
|
||||||
id: String::from("7792b063eef6d33e7da5dc1856750c14"),
|
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-24T08:37:07-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ mod tests {
|
||||||
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-24T08:37:07-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -122,7 +122,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-24T08:36:25-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -160,7 +160,7 @@ mod tests {
|
||||||
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-24T08:37:46-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: Some(
|
done_time: Some(
|
||||||
|
|
@ -189,7 +189,7 @@ 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-24T10:08:38-06:00").unwrap().with_timezone(&chrono::Local),
|
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"),
|
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),
|
||||||
}
|
}
|
||||||
|
|
@ -198,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-24T10:08:24-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -226,8 +226,8 @@ mod tests {
|
||||||
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("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:38:40-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -246,8 +246,8 @@ mod tests {
|
||||||
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("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:39:20-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
@ -267,8 +267,8 @@ mod tests {
|
||||||
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("Sebastian Kuzminsky <seb@highlab.com>"),
|
||||||
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-24T08:39:02-06:00")
|
creation_time: chrono::DateTime::parse_from_rfc3339("2025-07-23T15:06:31-06:00")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.with_timezone(&chrono::Local),
|
.with_timezone(&chrono::Local),
|
||||||
done_time: None,
|
done_time: None,
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,6 @@
|
||||||
set -e
|
set -e
|
||||||
#set -x
|
#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=""
|
BRANCH=""
|
||||||
|
|
||||||
if [[ -n "$1" ]] && [[ -d "$1" ]]; then
|
if [[ -n "$1" ]] && [[ -d "$1" ]]; then
|
||||||
|
|
@ -60,7 +53,6 @@ for ISSUE_ID in $(find . -maxdepth 1 -type d -regextype posix-extended -regex '\
|
||||||
|
|
||||||
mkdir tags
|
mkdir tags
|
||||||
for TAG in ${TAGS}; do
|
for TAG in ${TAGS}; do
|
||||||
TAG=$(escape_tag "${TAG}")
|
|
||||||
touch "tags/${TAG}"
|
touch "tags/${TAG}"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue