|
1 | 1 | use std::{collections::BTreeSet, fmt, sync::Arc}; |
2 | 2 |
|
3 | | -use git2::BranchType; |
| 3 | +use git2::{BranchType, Oid}; |
4 | 4 | use octocrab::models::IssueState; |
5 | 5 | use teloxide::types::{ChatId, Message}; |
6 | 6 | use tokio::{fs::read_dir, sync::Mutex}; |
@@ -146,6 +146,10 @@ pub async fn commit_check( |
146 | 146 | hash: &str, |
147 | 147 | ) -> Result<CommitCheckResult, Error> { |
148 | 148 | 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 | + } |
149 | 153 | let cache = repo_resources.cache().await?; |
150 | 154 | let all_branches = { |
151 | 155 | let commit = hash.to_string(); |
@@ -201,6 +205,13 @@ pub async fn commit_check( |
201 | 205 | Ok(check_result) |
202 | 206 | } |
203 | 207 |
|
| 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 | + |
204 | 215 | pub async fn pr_issue_add( |
205 | 216 | resources: &ChatRepoResources, |
206 | 217 | repo_resources: &RepoResources, |
|
0 commit comments