Skip to content
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

APIs for pull requests #2253

Open
yurivict opened this issue Dec 20, 2015 · 23 comments
Open

APIs for pull requests #2253

yurivict opened this issue Dec 20, 2015 · 23 comments
Labels
🎯 feature Categorizes as related to a new feature status: assigned to community Take it on, you're the rockstar

Comments

@yurivict
Copy link

Particularly these commands are desired:

  • /api/v1/{user}/{repo}/pulls?status={open/closed}&id={id} - retrieves the list of pull requests (or one pull request)
  • /api/v1/{user}/{repo}/pull/{num}/files - retrieves the list of affected files for the pull request
  • /api/v1/{user}/{repo}/pull/{num}/diff - retrieves the diff file for the pull request
  • /api/v1/{user}/{repo}/pull/{num}/comments - retrieves the list of comments
  • /api/v1/{user}/{repo}/pull/{num}/comment-submit - PUT submits a new comment
@unknwon unknwon changed the title API needs to have access to the pull requests APIs for pull requests Dec 20, 2015
@unknwon unknwon added the 🎯 feature Categorizes as related to a new feature label Dec 20, 2015
@unknwon unknwon added this to the 0.9.0 milestone Dec 20, 2015
@unknwon unknwon removed this from the 0.9.0 milestone Feb 7, 2016
@romanresh
Copy link

Besides enumerated commands, we use the following PR API in GitLab:

  1. Accept pull request via API
  2. Reassign pull request
  3. Create comment in pull request

We'd like to migrate to Gogs from Gitlab, but these api commands are required in our infrastructure (PR are accepted via an external utility).

@kmadel
Copy link
Contributor

kmadel commented Aug 4, 2016

I just wanted to mention that I have written a Gogs Plugin for Jenkins to support Pipeline Multibranch and Org Scanning (auto creates project folders for repos and Pipeline projects for branches that have a Jenkinsfile in them). Initial release is available here: https://github.com/kmadel/gogs-branch-source-plugin/releases/tag/v0.1-alpha

The biggest missing features is support for Pull Requests. Even without a webhook or a Rest API to interact with them - is there anyway to interact with PRs via plain vanialla Git?

Thanks for the awesome work!

@kmadel
Copy link
Contributor

kmadel commented Aug 15, 2016

By the way, I would like to mention that I believe Pull Requests should be able to be retrieved the same way that repo branches are (and the way GitHub does it):

GET /repos/:owner/:repo/pulls

And with at least the 'state' parameter to filter:
state string Either open, closed, or all to filter by state. Default: open

@lstahlman
Copy link
Contributor

@unknown are you already working on this in conjunction with #2246? If not, I would like to help out.

@unknwon
Copy link
Member

unknwon commented Aug 15, 2016

@lstahlman OK, go ahead.

@unknwon unknwon added the status: assigned to community Take it on, you're the rockstar label Aug 15, 2016
@lstahlman
Copy link
Contributor

Thanks!

@hhenkel
Copy link

hhenkel commented Aug 15, 2016

One implementing the API should probably orientate himself at this github api?

@lstahlman
Copy link
Contributor

That makes sense. I think most of the features requested here fit with that api, though some are dependent on related features that are still in progress (e.g., comments API).

@kmadel
Copy link
Contributor

kmadel commented Sep 2, 2016

I also wanted to mention (and please correct me if I am wrong), but I don't believe it is even currently possible to get a list of Pull Request issues.

GET /repos/:owner/:repo/issues does not allow passing in the Issue option to include pull requests per https://github.com/gogits/gogs/blob/master/routers/api/v1/repo/issue.go#L19

@lstahlman
Copy link
Contributor

I am including the ability to pass options through /repos/:owner/:repo/pulls and I think there should be the same sort of support for issues. I was actually considering submitting a PR for that once I'm done with the initial work for the PR API.

@kmadel
Copy link
Contributor

kmadel commented Sep 2, 2016

@lstahlman How far along are you on the PR API - and did you see this PR: #3547

Not quite as robust as what GitHub includes for PRs, but a simple start - I suppose you may already have something better.

@lstahlman
Copy link
Contributor

Yeah I saw that and am somewhat dependent on that PR getting accepted. I had my own version in dev, but it very closely matches what you submitted.

I'm pretty far along on the basics (list, get, create, update). I was starting to add support for PR commit/file details, but I think I will split that into a separate contribution.

@bkcsoft
Copy link
Contributor

bkcsoft commented Oct 10, 2016

@lstahlman Are you still working on this one? if so can you send a PR for what you have? 😃

@lstahlman
Copy link
Contributor

I paused while waiting for #3547 & gogs/go-gogs-client#47 to be accepted, but I'll go ahead and post a WIP PR shortly so the code is out there.

@lstahlman
Copy link
Contributor

The WIP PRs I just posted implement the basic list, get, create, edit & merge features. I'm open to feedback and can add in extra bits where needed. I still need to finish the documentation markdown but should be able to post that in the next day or so.

@kmadel this is going to conflict with your PR #3547 as I changed the API format of the PR struct to more closely match the Github API (there seems to be a bit of a push for this).

@lstahlman
Copy link
Contributor

FYI I updated the PR to include the documentation. It's lengthy so I won't cross-post it here.

@guyzmo
Copy link

guyzmo commented Dec 25, 2016

Along with the support of pull requests — if it's not already implemented — please, really please make it possible to git fetch the pull-requests as git refs.

git fetch github pull/42/head # how it's implemented on github

Both github and gitlab support this and it's one of the great features they share, and bitbucket lack of it is the most frustrating side of the tool. Don't be like bitbucket, be like the others!

@hhenkel
Copy link

hhenkel commented Jan 2, 2017

@guyzmo what you're requesting is already there? #1655

@guyzmo
Copy link

guyzmo commented Jan 2, 2017

@hhenkel Brilliant!

Just need the PR listing/creation/close/comment API and it's going to be 👌

@guyzmo
Copy link

guyzmo commented Jan 2, 2017

BTW, if I may comment on the API structure, it's better to use a more RESTful structure:

  • /api/v1/{user}/{repo}/pullrequest
  • GET: (with ?status={open/closed}&id={id} params) retrieves (and filters) the list of pull requests
  • POST: creates a new PR
  • /api/v1/{user}/{repo}/pullrequest/{num}
  • GET: retrieves all details about a given PR
  • UPDATE: modifies mutable values of the PR
  • DELETE: ø (to close a PR update its status value)
  • /api/v1/{user}/{repo}/pullrequest/{num}/comment
    • GET: retrieves the list of comments
    • POST: creates a new comment
    • UPDATE/PUT: updates an existing comment
    • DELETE: deletes a comment

  • /api/v1/{user}/{repo}/pull/{num}/diff
    • would that one be really necessary? I mean, a simple property with link of the existing diff web page and patch raw file should be enough.
  • Though if that info cannot be reached using API's auth on the web content pages, then the API endpoint needs to be there
  • /api/v1/{user}/{repo}/pullrequest/{num}/files - retrieves the list of affected files for the pull request
  • idem: would it be necessary? The list of affected files can be easily extracted from a patch file.

my €0.02

@bkcsoft
Copy link
Contributor

bkcsoft commented Jan 2, 2017

@guyzmo Gogs is following the GitHub API as close as possible, so deviating from it by choice (for little reason) would not be merged.

@guyzmo
Copy link

guyzmo commented Jan 2, 2017

This is a good idea, as from my experience implementing git services APIs, I have to admit github API is a very good one (whether you name it pull, pulls or pullrequest is just a minor technical detail). And what I suggested is following that API, cf Github documentation. I'm just suggesting to take baby steps in implementing it 😉

the really necessary

the nice to have

you can also get commit list (which is not really useful if you implement the commit list endpoint):

@ricardobranco777
Copy link

Any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 feature Categorizes as related to a new feature status: assigned to community Take it on, you're the rockstar
Projects
None yet
Development

No branches or pull requests

9 participants