diff --git a/README.md b/README.md index e4975a3..0608154 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ Usage: `git-bb-create-pull-request` - opens the bitbucket page to create a new PR for the branch you're on. +### git-bb-list-pull-requests + +Usage: + +`git-bb-list-pull-requests` - opens the bitbucket pull-request page for the repository. + ### git-bb-open Usage: diff --git a/bin/git-bb-list-pull-requests b/bin/git-bb-list-pull-requests new file mode 100755 index 0000000..06a12d4 --- /dev/null +++ b/bin/git-bb-list-pull-requests @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +# +# Open the PR page on bitbucket for the current repository +# +# Copyright 2016 Joe Block +# +# License: Apache 2.0 + +def push_loadpath + $: << File.expand_path(File.dirname(caller.first)) +end + +push_loadpath + +require 'pathname' +require 'bbhelpers' + +def construct_PR_list_URL + remote = git_remote() + bbloc = remote.index('bitbucket.org') + if not bbloc + puts "Only works for repositories with their origin remote on bitbucket.org" + exit 1 + end + return "https://#{remote[bbloc..-5]}/pull-requests/" +end + +if ARGV.length > 0 + puts 'Usage: git-bb-list-pull-requests' + puts ' Opens the PR page on bitbucket for the current repository' +end + +openURL(construct_PR_list_URL())