Compare commits

..

No commits in common. "97a575316e4af91300b6c0414e5f3160578b3691" and "04b33eb70f6e413fed5e438bd8cc1b728d101fd0" have entirely different histories.

2 changed files with 14 additions and 40 deletions

View file

@ -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 {

View file

@ -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) => {
println!(
"failed to parse issue {}, skipping",
direntry.file_name().to_string_lossy()
);
println!("ignoring error: {:?}", e);
continue;
}
Ok(issue) => {
issues.add_issue(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 {