4

I'm on a git branch. Is there a way to see, whether there is a pull-request for this branch?

In this particular case, Atlassian-Stash is used to manage pull requests. Of course I can use the web interface of Stash to search for the pull request; but can I do this from a script too, just using git command line tools?

user1934428
  • 19,864
  • 7
  • 42
  • 87
  • `git-request-pull` *exists*, but it's more of a way to submit requests to a maintainer. In all honesty, the maintainer usually knows whether or not those are in flight, as they'd have received some sort of notice about them. Further, the broader knowledge of pull requests is something that third party hosts like GitHub and Stash provide. – Makoto Jul 15 '15 at 09:15

3 Answers3

6

Core Git doesn't have anything like (github's, atlassian's,...) pull request feature, so you are out of luck with standard git commands. (Well there is git-request-pull, but this is slightly different).

luckily, atlassian/stash (and github) provide APIs that allow you to use them via cmdline-tools (as opposed to via the browser).

Once you have created a small script that queries the server for pull-requests, you can turn this into a subcommand, by prefixing your script with git- and putting it somewhere in your search path.

e.g. if your script is named git-check-pulls, you can use it as git check-pulls ...

umläute
  • 28,885
  • 9
  • 68
  • 122
4

Like umlaute explained, you could use a small script to check if there are any pull requests.

Here is a small python script i used a while ago to check for pull requests.

import urllib2
from StringIO import StringIO
import json

data = urllib2.urlopen("https://api.github.com/repos/<username>/<branch>/pulls").read()
io = StringIO(data)
jsondata = json.load(io)
for item in jsondata:
    print "pull request :: " + item['title'] 

A different url would be needed to pull the data from stash. And the json data seems to have a slightly different structure.

for item in jsondata['values']:

Is the line that would need to be changed to get the pull requests from stash.

remynaps
  • 61
  • 6
4

with github command line tool you can just: gh pr view

Noam Freeman
  • 143
  • 1
  • 8