Skip to content

Commit 5da1c42

Browse files
committed
Pre-check commit before cache checking
1 parent 78d79b5 commit 5da1c42

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/chat/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{collections::BTreeSet, fmt, sync::Arc};
22

3-
use git2::BranchType;
3+
use git2::{BranchType, Oid};
44
use octocrab::models::IssueState;
55
use teloxide::types::{ChatId, Message};
66
use tokio::{fs::read_dir, sync::Mutex};
@@ -146,6 +146,10 @@ pub async fn commit_check(
146146
hash: &str,
147147
) -> Result<CommitCheckResult, Error> {
148148
log::info!("checking commit ({task}, {hash})", task = resources.task);
149+
if let Err(e) = commit_pre_check(repo_resources, hash).await {
150+
commit_remove(resources, hash).await?;
151+
return Err(e);
152+
}
149153
let cache = repo_resources.cache().await?;
150154
let all_branches = {
151155
let commit = hash.to_string();
@@ -201,6 +205,13 @@ pub async fn commit_check(
201205
Ok(check_result)
202206
}
203207

208+
pub async fn commit_pre_check(repo_resources: &RepoResources, hash: &str) -> Result<(), Error> {
209+
let repo = repo_resources.repo.lock().await;
210+
let id = Oid::from_str(hash)?;
211+
let _commit = repo.find_commit(id)?;
212+
Ok(())
213+
}
214+
204215
pub async fn pr_issue_add(
205216
resources: &ChatRepoResources,
206217
repo_resources: &RepoResources,

0 commit comments

Comments
 (0)