Replace dirty unwrap() with expect("TODO")
This makes it obvious where better error handling is still needed.
This commit is contained in:
parent
983ceb2076
commit
b66e8c8d9c
5 changed files with 25 additions and 15 deletions
|
|
@ -123,9 +123,9 @@ fn element_from_issue(issue: &forgejo_api::structs::Issue) -> anyhow::Result<cra
|
|||
|
||||
let ty = ty_labels
|
||||
.first()
|
||||
.unwrap()
|
||||
.expect("TODO")
|
||||
.strip_prefix("Type/")
|
||||
.unwrap()
|
||||
.expect("TODO")
|
||||
.to_owned();
|
||||
|
||||
let has_completed_label = labels
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub async fn make_bot_comment(
|
|||
.await?;
|
||||
|
||||
Ok(BotCommentInfo {
|
||||
id: res.id.unwrap(),
|
||||
id: res.id.expect("TODO"),
|
||||
body: initial_message.to_owned(),
|
||||
})
|
||||
}
|
||||
|
|
@ -55,11 +55,11 @@ pub async fn find_bot_comment(
|
|||
let maybe_bot_comment = comments
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|comment| comment.user.as_ref().unwrap().id == Some(-2));
|
||||
.find(|comment| comment.user.as_ref().expect("TODO").id == Some(-2));
|
||||
|
||||
Ok(maybe_bot_comment.map(|c| BotCommentInfo {
|
||||
body: c.body.clone().unwrap_or("".to_owned()),
|
||||
id: c.id.unwrap(),
|
||||
id: c.id.expect("TODO"),
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ pub async fn remove_stale_label(ctx: &crate::Context, issue_number: u64) -> anyh
|
|||
.iter()
|
||||
.filter(|l| l.name.as_deref() == Some("Stale"))
|
||||
.next()
|
||||
.map(|l| l.id.unwrap());
|
||||
.map(|l| l.id.expect("TODO"));
|
||||
|
||||
if let Some(stale_label_id) = stale_label_id {
|
||||
log::info!("Removing `Stale` label from issue #{issue_number}...");
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ async fn run() -> anyhow::Result<()> {
|
|||
"{}/{}",
|
||||
meta.issue.repository.owner, meta.issue.repository.name
|
||||
))
|
||||
.unwrap();
|
||||
.expect("TODO");
|
||||
|
||||
let repo_auth_url = token.as_ref().map(|token| {
|
||||
let mut repo_auth_url = repo_url.clone();
|
||||
repo_auth_url.set_username("forgejo-actions").unwrap();
|
||||
repo_auth_url.set_password(Some(&token)).unwrap();
|
||||
repo_auth_url.set_username("forgejo-actions").expect("TODO");
|
||||
repo_auth_url.set_password(Some(&token)).expect("TODO");
|
||||
repo_auth_url
|
||||
});
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ async fn run() -> anyhow::Result<()> {
|
|||
}
|
||||
|
||||
'issues: for issue in tree.iter_issues() {
|
||||
let subtree = tree.subtree_for_issue(issue).unwrap();
|
||||
let subtree = tree.subtree_for_issue(issue).expect("TODO");
|
||||
let hash = subtree.stable_hash();
|
||||
|
||||
let (bot_comment, _is_new) = issue::find_or_make_bot_comment(&ctx, issue)
|
||||
|
|
|
|||
|
|
@ -84,8 +84,18 @@ pub async fn publish(ctx: &crate::Context, rendered: &RenderedTree) -> anyhow::R
|
|||
.arg("-C")
|
||||
.arg(&rendered.repo_dir)
|
||||
.arg("add")
|
||||
.arg(rendered.dot_file.strip_prefix(&rendered.repo_dir).unwrap())
|
||||
.arg(rendered.svg_file.strip_prefix(&rendered.repo_dir).unwrap())
|
||||
.arg(
|
||||
rendered
|
||||
.dot_file
|
||||
.strip_prefix(&rendered.repo_dir)
|
||||
.expect("TODO"),
|
||||
)
|
||||
.arg(
|
||||
rendered
|
||||
.svg_file
|
||||
.strip_prefix(&rendered.repo_dir)
|
||||
.expect("TODO"),
|
||||
)
|
||||
.success()
|
||||
.context("Failed to add generated graph files to git index")?;
|
||||
|
||||
|
|
|
|||
|
|
@ -165,8 +165,8 @@ impl Tree {
|
|||
}
|
||||
|
||||
pub fn add_dependency_by_issue_number(&mut self, dependant: u64, dependency: u64) {
|
||||
let a = self.find_element_by_issue_number(dependant).unwrap();
|
||||
let b = self.find_element_by_issue_number(dependency).unwrap();
|
||||
let a = self.find_element_by_issue_number(dependant).expect("TODO");
|
||||
let b = self.find_element_by_issue_number(dependency).expect("TODO");
|
||||
self.graph.add_edge(a, b, ());
|
||||
}
|
||||
|
||||
|
|
@ -422,7 +422,7 @@ impl<'a> Subtree<'a> {
|
|||
.collect();
|
||||
edges.sort();
|
||||
|
||||
let json_data = serde_json::ser::to_string(&(nodes, edges, HASH_EPOCH)).unwrap();
|
||||
let json_data = serde_json::ser::to_string(&(nodes, edges, HASH_EPOCH)).expect("TODO");
|
||||
sha256::digest(json_data)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue