-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
API shows unexpected PR for a commit #32027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The However, now the API can return a PR even if it has not been merged yet. This is caused by a bug. Here we try to get the SHA by the gitea/routers/api/v1/repo/commits.go Line 357 in 2fc347b
But there is not a sha param in the path. The correct param should be ref .Lines 1286 to 1289 in 2fc347b
|
Thanks for the quick fix. :) For the record, I wanted to use the API endpoint to get the PR (if any) by commit sha regardless of whether the PR is merged or not. I want to check in a push webhook if the push belongs to a PR. I guess I need to find a different solution for that now. |
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:
I created a PR from branch
mergeme
tomain
: https://demo.gitea.com/betanummeric/pr-test1/pulls/1The 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
The text was updated successfully, but these errors were encountered: