Reputation: 22225
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?
Upvotes: 7
Views: 9116
Reputation: 61
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.
Upvotes: 4
Reputation: 31284
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 ...
Upvotes: 7