Skip to content

Commit

Permalink
GitHub gives a list of PR
Browse files Browse the repository at this point in the history
Also add some logs just in case that's not it.
  • Loading branch information
elegaanz committed Sep 30, 2024
1 parent d132419 commit fb45f5f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,20 @@ async fn github_hook<G: GitHubAuth>(
// Check that the author of this PR is the same as the one of
// the previous version.
if let Some(current_pr) = &pr {
debug!("There is a current PR");
if let Some(previous_commit) =
check::authors::commit_for_previous_version(package)
{
if let Ok(previous_pr) = api_client
.pr_for_commit(repository.owner(), repository.name(), previous_commit)
debug!("Found previous commit: {previous_commit}");
if let Ok(Some(previous_pr)) = api_client
.prs_for_commit(repository.owner(), repository.name(), previous_commit)
.await
.map(|prs| prs.into_iter().next())
{
debug!(
"Found previous PR: #{} (author: {})",
previous_pr.number, previous_pr.user.login
);
if previous_pr.user.login != current_pr.user.login {
if let Err(e) = api_client
.post_pr_comment(
Expand Down
4 changes: 2 additions & 2 deletions src/github/api/pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ impl GitHub<AuthInstallation> {
Ok(())
}

pub async fn pr_for_commit(
pub async fn prs_for_commit(
&self,
owner: OwnerId,
repo: RepoId,
commit: String,
) -> Result<PullRequest, ApiError> {
) -> Result<Vec<PullRequest>, ApiError> {
self.get(format!("repos/{owner}/{repo}/commits/{commit}/pulls"))
.send()
.await?
Expand Down

0 comments on commit fb45f5f

Please sign in to comment.