Skip to content

API shows unexpected PR for a commit #32027

@betanummeric

Description

@betanummeric

Description

The API endpoint GET /repos/{owner}/{repo}/commits/{sha}/pull returns a pull request in more cases than I would expect:
I created the example repo https://demo.gitea.com/betanummeric/pr-test1 as an example:

* 2e0af5a76e4e02ff9ee4d52949d25fd229683754  (HEAD -> yetanother, origin/yetanother)
| * a8a7c696d7de8abd600798966caa4a47a6c420ca  (origin/other, other)
| * 827ed730869e32856e56da7be2a294dbf89a1b93  (origin/mergeme, mergeme)
|/  
* bd0050a443969356bf847bed330aa34a53be00cf  (origin/main, main)

I created a PR from branch mergeme to main: https://demo.gitea.com/betanummeric/pr-test1/pulls/1

The API returns that PR for every commit hash of the repo. I would have expected this to return the PR only for commit 827ed730869e32856e56da7be2a294dbf89a1b93, because only that will be applied to the target branch in the PR.

I'm using this endpoint to determine if a push event relates to some PR. I work around by checking if the PR head matches the head of the push event.

Gitea Version

1.22.1

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

tested with gitea 1.22.1 and https://demo.gitea.com/ at 1.23.0+dev-464-g19af534462

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions