From b9265a9c05177ff28776ace23b930af832aba069 Mon Sep 17 00:00:00 2001 From: Joe Block Date: Fri, 8 Apr 2016 09:53:00 -0700 Subject: [PATCH] Add pull request helper script --- bin/git-bb-create-pull-request | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 bin/git-bb-create-pull-request diff --git a/bin/git-bb-create-pull-request b/bin/git-bb-create-pull-request new file mode 100755 index 0000000..6a8641e --- /dev/null +++ b/bin/git-bb-create-pull-request @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +# +# Open a file/directory on bitbucket in the current branch +# +# 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_URL + remote = git_remote() + bbloc = remote.index('bitbucket.org') + if not bbloc + "only works for repositories with their origin remote on bitbucket.org" + exit 1 + end + return "https://#{remote[bbloc..-5]}/pull-requests/new?source=#{git_branch()}&t=1" +end + +if ARGV.length > 0 + puts 'Usage: git-bb-create-pull-request' + puts 'Open the create PR page on bitbucket for the current branch' +end + +openURL(construct_PR_URL())