user1934428
user1934428

Reputation: 22225

git: How can I find out whether there is a pull request for a branch?

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

Answers (3)

Noam Freeman
Noam Freeman

Reputation: 303

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

Upvotes: 5

remynaps
remynaps

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

uml&#228;ute
uml&#228;ute

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

Related Questions