an agent gets one todo when its pr starts conflicting with the target branch
This commit is contained in:
parent
32155f70aa
commit
11eb7dac9c
1 changed files with 963 additions and 21 deletions
42
swarm-controller/src/forge/base_pulls.rs
Normal file
42
swarm-controller/src/forge/base_pulls.rs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
//! The open pull requests that target one branch.
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use forgejo_api::structs::{
|
||||
PullRequest, RepoListPullRequestsQuery, RepoListPullRequestsQueryState,
|
||||
};
|
||||
|
||||
use super::Client;
|
||||
|
||||
impl Client {
|
||||
/// Every open pull request in `owner/repo` whose target branch is `base`,
|
||||
/// as the forge lists them: one call per page of 50.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// The forge refused or did not answer.
|
||||
pub async fn open_pulls_on(
|
||||
&self,
|
||||
owner: &str,
|
||||
repo: &str,
|
||||
base: &str,
|
||||
) -> Result<Vec<PullRequest>> {
|
||||
let query = RepoListPullRequestsQuery {
|
||||
state: Some(RepoListPullRequestsQueryState::Open),
|
||||
sort: None,
|
||||
milestone: None,
|
||||
labels: None,
|
||||
poster: None,
|
||||
base: Some(base.to_owned()),
|
||||
head: None,
|
||||
};
|
||||
self.api
|
||||
.call(|api| {
|
||||
Box::pin(
|
||||
api.repo_list_pull_requests(owner, repo, query.clone())
|
||||
.all(),
|
||||
)
|
||||
})
|
||||
.await
|
||||
.with_context(|| format!("list open pull requests on {base} in {owner}/{repo}"))
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue