-
Notifications
You must be signed in to change notification settings - Fork 5k
[WIP] API support for pull requests #3755
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
Conversation
Great! Would love to see some tests for this. |
|
||
prs, maxResults, err := models.PullRequests(ctx.Repo.Repository.ID, &models.PullRequestsOptions{ | ||
Page: form.Page, | ||
State: form.State, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are always query-parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was experimenting with additional filters here and trying different ways to go about it. Going this route allows the parameters to be passed as JSON as well as plain query params.
Not really necessary for just two query parameters and I can switch it back (the standard way is still there but commented out in the code), but I thought this could be an improvement from a documentation perspective especially with extra filtering as all the query parameters end up defined as structs in the Gogs Client. Could be useful for the list issues endpoint, as that would benefit from extra filtering support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is that using form api.[...]
doesn't pick up query-params at all 😒
I'd suggest populating it with form
first, then override with ctx.Query
after (so query-params have a higher precedence than form-data) 🙂
m.Combo("/merge").Get(repo.IsPullRequestMerged).Post(reqRepoWriter(), repo.MergePullRequest) | ||
}) | ||
|
||
}, mustAllowPulls, context.ReferencesGitRepo()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't mustAllowPulls
be a function-call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm following the style for /issues, as it also places a similar condition mustAllowIssues. No point calling the endpoint functions if pull requests aren't enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems odd 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it works somehow so lets leave it this way
@@ -117,13 +117,21 @@ func (pr *PullRequest) LoadIssue() (err error) { | |||
func (pr *PullRequest) APIFormat() *api.PullRequest { | |||
|
|||
apiIssue := pr.Issue.APIFormat() | |||
baseBranch, _ := pr.BaseRepo.GetBranch(pr.BaseBranch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of an error, should we return nil
instead?
@lstahlman are you still working on this? |
Yup, would love to see this merged ! |
Hi, is this PR completed? |
Is this pull request dead? This a feature I would love to see in gogs, as we can't fetch pull requests via the api at all now, only issues. |
What is the current state of this PR? |
This PR provides initial API support for pull requests (get, list, create, edit, merge). See #2253 for the discussion regarding this portion of the API.
This is a work in progress and additional changes & documentation will be added.
This PR depends on gogs/go-gogs-client#53. This also overlaps with PR #3547.
Here is the wiki documentation:
Pull Requests
List pull requests for a repository
Response
Get a single pull request
Response
Create a pull request
Parameters
Example
Response
If a pull request already exists for the same head & base:
Otherwise if the pull request is created:
Edit a pull request
Repository owners and users with write access can perform this action.
Parameters
If a parameter is empty, that part of the pull request will remain unchanged
Example
Response
Merge a pull request
Only users with write access to a repository can perform this action.
Response
Success:
Failed to auto-merge or PR already merged:
Failure on attempt to merge a closed PR:
All other errors:
Check if a pull request is merged
Response
If merged:
If not merged: