paulirish.git-open/pr-utils
2016-09-11 21:35:24 -07:00

19 lines
601 B
Plaintext

# Gets url to all PRs for branch
function getAllPrsUrl {
local giturl="$1";
# assumes $giturl is of the form .*/user/repo
local owner=`expr "$giturl" : '.*/\(.*\)/.*$'`
local repo=`expr "$giturl" : '.*/\(.*\)$'`
# github-only solution
local allPrsUrl="https://api.github.com/repos/"$owner"/"$repo"/pulls?head="$owner":"$branch
echo $allPrsUrl;
}
# Gets most recent PR from all PRs for branch
function getPrUrl {
local allPrsUrl="$1"
local unparsedPrUrl=$(curl -s $allPrsUrl | grep -m 1 html_url 2> /dev/null)
local prUrl=`expr "$unparsedPrUrl" : '.*\"\(.*\)\",$'`
echo $prUrl
}