Compare commits
No commits in common. "6a1e438c9471f0be5d9137626c1158fbe7a47b9c" and "04b33eb70f6e413fed5e438bd8cc1b728d101fd0" have entirely different histories.
6a1e438c94
...
04b33eb70f
4 changed files with 74 additions and 136 deletions
|
|
@ -48,23 +48,19 @@ impl Comment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let Some(description) = description else {
|
if description == None {
|
||||||
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(
|
uuid: String::from(dir.file_name().unwrap().to_string_lossy()),
|
||||||
dir.file_name()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
|
||||||
.to_string_lossy(),
|
|
||||||
),
|
|
||||||
author,
|
author,
|
||||||
creation_time,
|
creation_time,
|
||||||
description,
|
description: description.unwrap(),
|
||||||
dir: std::path::PathBuf::from(comment_dir),
|
dir: std::path::PathBuf::from(comment_dir),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -113,11 +109,7 @@ impl Comment {
|
||||||
&format!(
|
&format!(
|
||||||
"add comment {} on issue {}",
|
"add comment {} on issue {}",
|
||||||
comment.uuid,
|
comment.uuid,
|
||||||
issue
|
issue.dir.file_name().unwrap().to_string_lossy(),
|
||||||
.dir
|
|
||||||
.file_name()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
|
||||||
.to_string_lossy(),
|
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
@ -138,15 +130,10 @@ 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
|
&description_filename.parent().unwrap(),
|
||||||
.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
|
self.dir.file_name().unwrap().to_string_lossy()
|
||||||
.file_name()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
|
||||||
.to_string_lossy()
|
|
||||||
),
|
),
|
||||||
)?;
|
)?;
|
||||||
self.read_description()?;
|
self.read_description()?;
|
||||||
|
|
@ -178,8 +165,8 @@ impl Comment {
|
||||||
.spawn()?
|
.spawn()?
|
||||||
.wait_with_output()?;
|
.wait_with_output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -139,14 +139,11 @@ 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(
|
.current_dir(file.parent().unwrap())
|
||||||
file.parent()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?,
|
|
||||||
)
|
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
@ -155,14 +152,11 @@ 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(
|
.current_dir(file.parent().unwrap())
|
||||||
file.parent()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?,
|
|
||||||
)
|
|
||||||
.output()?;
|
.output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
@ -174,8 +168,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -186,18 +180,12 @@ 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([
|
.args(["add", &file.file_name().unwrap().to_string_lossy()])
|
||||||
"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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,20 +195,15 @@ pub fn git_commit_file(file: &std::path::Path) -> Result<(), GitError> {
|
||||||
"-m",
|
"-m",
|
||||||
&format!(
|
&format!(
|
||||||
"update '{}' in issue {}",
|
"update '{}' in issue {}",
|
||||||
file.file_name()
|
file.file_name().unwrap().to_string_lossy(),
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
git_dir.file_name().unwrap().to_string_lossy()
|
||||||
.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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,8 +216,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -270,13 +253,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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!("{}", &String::from_utf8_lossy(&result.stdout));
|
println!("{}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -296,13 +279,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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!("{}", &String::from_utf8_lossy(&result.stdout));
|
println!("{}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("");
|
println!("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,8 +299,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -331,8 +314,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -349,16 +332,13 @@ pub fn git_log_oldest_timestamp(
|
||||||
"log",
|
"log",
|
||||||
"--pretty=format:%at",
|
"--pretty=format:%at",
|
||||||
"--",
|
"--",
|
||||||
&path
|
&path.file_name().unwrap().to_string_lossy(),
|
||||||
.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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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();
|
||||||
|
|
@ -378,16 +358,13 @@ pub fn git_log_oldest_author(path: &std::path::Path) -> Result<String, GitError>
|
||||||
"log",
|
"log",
|
||||||
"--pretty=format:%an <%ae>",
|
"--pretty=format:%an <%ae>",
|
||||||
"--",
|
"--",
|
||||||
&path
|
&path.file_name().unwrap().to_string_lossy(),
|
||||||
.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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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();
|
||||||
|
|
@ -406,8 +383,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -423,8 +400,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -441,8 +418,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -451,8 +428,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: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
return Err(GitError::Oops);
|
return Err(GitError::Oops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
39
src/issue.rs
39
src/issue.rs
|
|
@ -153,9 +153,9 @@ impl Issue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(description) = description else {
|
if description == None {
|
||||||
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: description.unwrap(),
|
||||||
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()
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
.unwrap()
|
||||||
.file_name()
|
.file_name()
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
.unwrap()
|
||||||
.to_string_lossy(),
|
.to_string_lossy(),
|
||||||
))?;
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -293,10 +293,7 @@ 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
|
self.dir.file_name().unwrap().to_string_lossy(),
|
||||||
.file_name()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
|
||||||
.to_string_lossy(),
|
|
||||||
old_state,
|
old_state,
|
||||||
new_state,
|
new_state,
|
||||||
))?;
|
))?;
|
||||||
|
|
@ -326,10 +323,7 @@ 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
|
self.dir.file_name().unwrap().to_string_lossy(),
|
||||||
.file_name()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
|
||||||
.to_string_lossy(),
|
|
||||||
done_time,
|
done_time,
|
||||||
))?;
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -347,10 +341,7 @@ 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
|
self.dir.file_name().unwrap().to_string_lossy(),
|
||||||
.file_name()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
|
||||||
.to_string_lossy(),
|
|
||||||
old_assignee,
|
old_assignee,
|
||||||
new_assignee,
|
new_assignee,
|
||||||
))?;
|
))?;
|
||||||
|
|
@ -367,10 +358,7 @@ impl Issue {
|
||||||
self.tags.sort();
|
self.tags.sort();
|
||||||
self.commit_tags(&format!(
|
self.commit_tags(&format!(
|
||||||
"issue {} add tag {}",
|
"issue {} add tag {}",
|
||||||
self.dir
|
self.dir.file_name().unwrap().to_string_lossy(),
|
||||||
.file_name()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
|
||||||
.to_string_lossy(),
|
|
||||||
tag
|
tag
|
||||||
))?;
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -385,10 +373,7 @@ 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
|
self.dir.file_name().unwrap().to_string_lossy(),
|
||||||
.file_name()
|
|
||||||
.ok_or(std::io::Error::from(std::io::ErrorKind::NotFound))?
|
|
||||||
.to_string_lossy(),
|
|
||||||
tag
|
tag
|
||||||
))?;
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -447,8 +432,8 @@ impl Issue {
|
||||||
.spawn()?
|
.spawn()?
|
||||||
.wait_with_output()?;
|
.wait_with_output()?;
|
||||||
if !result.status.success() {
|
if !result.status.success() {
|
||||||
println!("stdout: {}", &String::from_utf8_lossy(&result.stdout));
|
println!("stdout: {}", std::str::from_utf8(&result.stdout).unwrap());
|
||||||
println!("stderr: {}", &String::from_utf8_lossy(&result.stderr));
|
println!("stderr: {}", std::str::from_utf8(&result.stderr).unwrap());
|
||||||
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,19 +56,8 @@ 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() {
|
||||||
match crate::issue::Issue::new_from_dir(direntry.path().as_path()) {
|
let issue = crate::issue::Issue::new_from_dir(direntry.path().as_path())?;
|
||||||
Err(e) => {
|
issues.add_issue(issue);
|
||||||
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