Compare commits
5 commits
04b33eb70f
...
6a1e438c94
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a1e438c94 | |||
| e79fc4917d | |||
| c217434071 | |||
| 97a575316e | |||
| 2ba13ebaeb |
4 changed files with 136 additions and 74 deletions
|
|
@ -48,19 +48,23 @@ impl Comment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if description == None {
|
let Some(description) = description else {
|
||||||
return Err(CommentError::CommentParseError);
|
return Err(CommentError::CommentParseError);
|
||||||
}
|
};
|
||||||
|
|
||||||
let author = crate::git::git_log_oldest_author(comment_dir)?;
|
let author = crate::git::git_log_oldest_author(comment_dir)?;
|
||||||
let creation_time = crate::git::git_log_oldest_timestamp(comment_dir)?;
|
let creation_time = crate::git::git_log_oldest_timestamp(comment_dir)?;
|
||||||
let dir = std::path::PathBuf::from(comment_dir);
|
let dir = std::path::PathBuf::from(comment_dir);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
uuid: String::from(dir.file_name().unwrap().to_string_lossy()),
|
uuid: String::from(
|
||||||
|
dir.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
|
),
|
||||||
author,
|
author,
|
||||||
creation_time,
|
creation_time,
|
||||||
description: description.unwrap(),
|
description,
|
||||||
dir: std::path::PathBuf::from(comment_dir),
|
dir: std::path::PathBuf::from(comment_dir),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -109,7 +113,11 @@ impl Comment {
|
||||||
&format!(
|
&format!(
|
||||||
"add comment {} on issue {}",
|
"add comment {} on issue {}",
|
||||||
comment.uuid,
|
comment.uuid,
|
||||||
issue.dir.file_name().unwrap().to_string_lossy(),
|
issue
|
||||||
|
.dir
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
@ -130,10 +138,15 @@ impl Comment {
|
||||||
crate::git::add(&description_filename)?;
|
crate::git::add(&description_filename)?;
|
||||||
if crate::git::worktree_is_dirty(&self.dir.to_string_lossy())? {
|
if crate::git::worktree_is_dirty(&self.dir.to_string_lossy())? {
|
||||||
crate::git::commit(
|
crate::git::commit(
|
||||||
&description_filename.parent().unwrap(),
|
&description_filename
|
||||||
|
.parent()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?,
|
||||||
&format!(
|
&format!(
|
||||||
"edit comment {} on issue FIXME", // FIXME: name the issue that the comment is on
|
"edit comment {} on issue FIXME", // FIXME: name the issue that the comment is on
|
||||||
self.dir.file_name().unwrap().to_string_lossy()
|
self.dir
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy()
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
self.read_description()?;
|
self.read_description()?;
|
||||||
|
|
@ -165,8 +178,8 @@ impl Comment {
|
||||||
.spawn()?
|
.spawn()?
|
||||||
.wait_with_output()?;
|
.wait_with_output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(CommentError::EditorError);
|
return Err(CommentError::EditorError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
125
src/git.rs
125
src/git.rs
|
|
@ -48,8 +48,8 @@ impl Worktree {
|
||||||
.args(["worktree", "add", &path.path().to_string_lossy(), branch])
|
.args(["worktree", "add", &path.path().to_string_lossy(), branch])
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(Self { path })
|
Ok(Self { path })
|
||||||
|
|
@ -67,8 +67,8 @@ impl Worktree {
|
||||||
])
|
])
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(Self { path })
|
Ok(Self { path })
|
||||||
|
|
@ -87,8 +87,8 @@ pub fn checkout_branch_in_worktree(
|
||||||
.args(["worktree", "add", &worktree_dir.to_string_lossy(), branch])
|
.args(["worktree", "add", &worktree_dir.to_string_lossy(), branch])
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -99,8 +99,8 @@ pub fn git_worktree_prune() -> Result<(), GitError> {
|
||||||
.args(["worktree", "prune"])
|
.args(["worktree", "prune"])
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -111,8 +111,8 @@ pub fn git_remove_branch(branch: &str) -> Result<(), GitError> {
|
||||||
.args(["branch", "-D", branch])
|
.args(["branch", "-D", branch])
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -139,11 +139,14 @@ pub fn worktree_is_dirty(dir: &str) -> Result<bool, GitError> {
|
||||||
pub fn add(file: &std::path::Path) -> Result<(), GitError> {
|
pub fn add(file: &std::path::Path) -> Result<(), GitError> {
|
||||||
let result = std::process::Command::new("git")
|
let result = std::process::Command::new("git")
|
||||||
.args(["add", &file.to_string_lossy()])
|
.args(["add", &file.to_string_lossy()])
|
||||||
.current_dir(file.parent().unwrap())
|
.current_dir(
|
||||||
|
file.parent()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?,
|
||||||
|
)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
@ -152,11 +155,14 @@ pub fn add(file: &std::path::Path) -> Result<(), GitError> {
|
||||||
pub fn restore_file(file: &std::path::Path) -> Result<(), GitError> {
|
pub fn restore_file(file: &std::path::Path) -> Result<(), GitError> {
|
||||||
let result = std::process::Command::new("git")
|
let result = std::process::Command::new("git")
|
||||||
.args(["restore", &file.to_string_lossy()])
|
.args(["restore", &file.to_string_lossy()])
|
||||||
.current_dir(file.parent().unwrap())
|
.current_dir(
|
||||||
|
file.parent()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?,
|
||||||
|
)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
@ -168,8 +174,8 @@ pub fn commit(dir: &std::path::Path, msg: &str) -> Result<(), GitError> {
|
||||||
.current_dir(dir)
|
.current_dir(dir)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -180,12 +186,18 @@ pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> {
|
||||||
git_dir.pop();
|
git_dir.pop();
|
||||||
|
|
||||||
let result = std::process::Command::new("git")
|
let result = std::process::Command::new("git")
|
||||||
.args(["add", &file.file_name().unwrap().to_string_lossy()])
|
.args([
|
||||||
|
"add",
|
||||||
|
&file
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
|
])
|
||||||
.current_dir(&git_dir)
|
.current_dir(&git_dir)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,15 +207,20 @@ pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> {
|
||||||
"-m",
|
"-m",
|
||||||
&format!(
|
&format!(
|
||||||
"update '{}' in issue {}",
|
"update '{}' in issue {}",
|
||||||
file.file_name().unwrap().to_string_lossy(),
|
file.file_name()
|
||||||
git_dir.file_name().unwrap().to_string_lossy()
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
|
git_dir
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy()
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
.current_dir(&git_dir)
|
.current_dir(&git_dir)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,8 +233,8 @@ pub fn git_fetch(dir: &std::path::Path, remote: &str) -> Result<(), GitError> {
|
||||||
.current_dir(dir)
|
.current_dir(dir)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -253,13 +270,13 @@ pub fn sync(dir: &std::path::Path, remote: &str, branch: &str) -> Result<(), Git
|
||||||
"Sync failed! 'git log' error! Help, a human needs to fix the mess in {:?}",
|
"Sync failed! 'git log' error! Help, a human needs to fix the mess in {:?}",
|
||||||
branch
|
branch
|
||||||
);
|
);
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
if result.stdout.len() > 0 {
|
if result.stdout.len() > 0 {
|
||||||
println!("Changes fetched from remote {}:", remote);
|
println!("Changes fetched from remote {}:", remote);
|
||||||
println!("{}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("{}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,13 +296,13 @@ pub fn sync(dir: &std::path::Path, remote: &str, branch: &str) -> Result<(), Git
|
||||||
"Sync failed! 'git log' error! Help, a human needs to fix the mess in {:?}",
|
"Sync failed! 'git log' error! Help, a human needs to fix the mess in {:?}",
|
||||||
branch
|
branch
|
||||||
);
|
);
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
if result.stdout.len() > 0 {
|
if result.stdout.len() > 0 {
|
||||||
println!("Changes to push to remote {}:", remote);
|
println!("Changes to push to remote {}:", remote);
|
||||||
println!("{}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("{}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -299,8 +316,8 @@ pub fn sync(dir: &std::path::Path, remote: &str, branch: &str) -> Result<(), Git
|
||||||
"Sync failed! Merge error! Help, a human needs to fix the mess in {:?}",
|
"Sync failed! Merge error! Help, a human needs to fix the mess in {:?}",
|
||||||
branch
|
branch
|
||||||
);
|
);
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -314,8 +331,8 @@ pub fn sync(dir: &std::path::Path, remote: &str, branch: &str) -> Result<(), Git
|
||||||
"Sync failed! Push error! Help, a human needs to fix the mess in {:?}",
|
"Sync failed! Push error! Help, a human needs to fix the mess in {:?}",
|
||||||
branch
|
branch
|
||||||
);
|
);
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,13 +349,16 @@ pub fn git_log_oldest_timestamp(
|
||||||
"log",
|
"log",
|
||||||
"--pretty=format:%at",
|
"--pretty=format:%at",
|
||||||
"--",
|
"--",
|
||||||
&path.file_name().unwrap().to_string_lossy(),
|
&path
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
])
|
])
|
||||||
.current_dir(&git_dir)
|
.current_dir(&git_dir)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
let timestamp_str = std::str::from_utf8(&result.stdout).unwrap();
|
let timestamp_str = std::str::from_utf8(&result.stdout).unwrap();
|
||||||
|
|
@ -358,13 +378,16 @@ pub fn git_log_oldest_author(path: &std::path::Path) -> Result<String, GitError>
|
||||||
"log",
|
"log",
|
||||||
"--pretty=format:%an <%ae>",
|
"--pretty=format:%an <%ae>",
|
||||||
"--",
|
"--",
|
||||||
&path.file_name().unwrap().to_string_lossy(),
|
&path
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
])
|
])
|
||||||
.current_dir(&git_dir)
|
.current_dir(&git_dir)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
let author_str = std::str::from_utf8(&result.stdout).unwrap();
|
let author_str = std::str::from_utf8(&result.stdout).unwrap();
|
||||||
|
|
@ -383,8 +406,8 @@ pub fn create_orphan_branch(branch: &str) -> Result<(), GitError> {
|
||||||
.args(["worktree", "prune"])
|
.args(["worktree", "prune"])
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -400,8 +423,8 @@ fn create_orphan_branch_at_path(
|
||||||
.args(["worktree", "add", "--orphan", "-b", branch, &worktree_dir])
|
.args(["worktree", "add", "--orphan", "-b", branch, &worktree_dir])
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -418,8 +441,8 @@ fn create_orphan_branch_at_path(
|
||||||
.current_dir(worktree_path)
|
.current_dir(worktree_path)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -428,8 +451,8 @@ fn create_orphan_branch_at_path(
|
||||||
.current_dir(worktree_path)
|
.current_dir(worktree_path)
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
39
src/issue.rs
39
src/issue.rs
|
|
@ -153,9 +153,9 @@ impl Issue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if description == None {
|
let Some(description) = description else {
|
||||||
return Err(IssueError::IssueParseError);
|
return Err(IssueError::IssueParseError);
|
||||||
}
|
};
|
||||||
|
|
||||||
// parse the issue ID from the directory name
|
// parse the issue ID from the directory name
|
||||||
let id = if let Some(parsed_id) = match dir.file_name() {
|
let id = if let Some(parsed_id) = match dir.file_name() {
|
||||||
|
|
@ -179,7 +179,7 @@ impl Issue {
|
||||||
state: state,
|
state: state,
|
||||||
dependencies,
|
dependencies,
|
||||||
assignee,
|
assignee,
|
||||||
description: description.unwrap(),
|
description,
|
||||||
comments,
|
comments,
|
||||||
dir: std::path::PathBuf::from(dir),
|
dir: std::path::PathBuf::from(dir),
|
||||||
})
|
})
|
||||||
|
|
@ -267,9 +267,9 @@ impl Issue {
|
||||||
"edit description of issue {}",
|
"edit description of issue {}",
|
||||||
description_filename
|
description_filename
|
||||||
.parent()
|
.parent()
|
||||||
.unwrap()
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
.file_name()
|
.file_name()
|
||||||
.unwrap()
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
.to_string_lossy(),
|
.to_string_lossy(),
|
||||||
))?;
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -293,7 +293,10 @@ impl Issue {
|
||||||
write!(state_file, "{}", new_state)?;
|
write!(state_file, "{}", new_state)?;
|
||||||
self.commit(&format!(
|
self.commit(&format!(
|
||||||
"change state of issue {}, {} -> {}",
|
"change state of issue {}, {} -> {}",
|
||||||
self.dir.file_name().unwrap().to_string_lossy(),
|
self.dir
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
old_state,
|
old_state,
|
||||||
new_state,
|
new_state,
|
||||||
))?;
|
))?;
|
||||||
|
|
@ -323,7 +326,10 @@ impl Issue {
|
||||||
self.done_time = Some(done_time.clone());
|
self.done_time = Some(done_time.clone());
|
||||||
self.commit(&format!(
|
self.commit(&format!(
|
||||||
"set done-time of issue {} to {}",
|
"set done-time of issue {} to {}",
|
||||||
self.dir.file_name().unwrap().to_string_lossy(),
|
self.dir
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
done_time,
|
done_time,
|
||||||
))?;
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -341,7 +347,10 @@ impl Issue {
|
||||||
write!(assignee_file, "{}", new_assignee)?;
|
write!(assignee_file, "{}", new_assignee)?;
|
||||||
self.commit(&format!(
|
self.commit(&format!(
|
||||||
"change assignee of issue {}, {} -> {}",
|
"change assignee of issue {}, {} -> {}",
|
||||||
self.dir.file_name().unwrap().to_string_lossy(),
|
self.dir
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
old_assignee,
|
old_assignee,
|
||||||
new_assignee,
|
new_assignee,
|
||||||
))?;
|
))?;
|
||||||
|
|
@ -358,7 +367,10 @@ impl Issue {
|
||||||
self.tags.sort();
|
self.tags.sort();
|
||||||
self.commit_tags(&format!(
|
self.commit_tags(&format!(
|
||||||
"issue {} add tag {}",
|
"issue {} add tag {}",
|
||||||
self.dir.file_name().unwrap().to_string_lossy(),
|
self.dir
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
tag
|
tag
|
||||||
))?;
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -373,7 +385,10 @@ impl Issue {
|
||||||
self.tags.remove(index);
|
self.tags.remove(index);
|
||||||
self.commit_tags(&format!(
|
self.commit_tags(&format!(
|
||||||
"issue {} remove tag {}",
|
"issue {} remove tag {}",
|
||||||
self.dir.file_name().unwrap().to_string_lossy(),
|
self.dir
|
||||||
|
.file_name()
|
||||||
|
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
||||||
|
.to_string_lossy(),
|
||||||
tag
|
tag
|
||||||
))?;
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -432,8 +447,8 @@ impl Issue {
|
||||||
.spawn()?
|
.spawn()?
|
||||||
.wait_with_output()?;
|
.wait_with_output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
||||||
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
||||||
return Err(IssueError::EditorError);
|
return Err(IssueError::EditorError);
|
||||||
}
|
}
|
||||||
if !description_filename.exists() || description_filename.metadata()?.len() == 0 {
|
if !description_filename.exists() || description_filename.metadata()?.len() == 0 {
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,19 @@ impl Issues {
|
||||||
for direntry in dir.read_dir()? {
|
for direntry in dir.read_dir()? {
|
||||||
if let Ok(direntry) = direntry {
|
if let Ok(direntry) = direntry {
|
||||||
if direntry.metadata()?.is_dir() {
|
if direntry.metadata()?.is_dir() {
|
||||||
let issue = crate::issue::Issue::new_from_dir(direntry.path().as_path())?;
|
match crate::issue::Issue::new_from_dir(direntry.path().as_path()) {
|
||||||
issues.add_issue(issue);
|
Err(e) => {
|
||||||
|
eprintln!(
|
||||||
|
"failed to parse issue {}, skipping",
|
||||||
|
direntry.file_name().to_string_lossy()
|
||||||
|
);
|
||||||
|
eprintln!("ignoring error: {:?}", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Ok(issue) => {
|
||||||
|
issues.add_issue(issue);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if direntry.file_name() == "config.toml" {
|
} else if direntry.file_name() == "config.toml" {
|
||||||
issues.parse_config(direntry.path().as_path())?;
|
issues.parse_config(direntry.path().as_path())?;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue