Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support to internal github install #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions git-open-pr.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/bin/sh
_get_repo() {
echo "$1" | sed -e "s/.git$//" -e "s/.*github.com[:/]\(.*\)/\1/"
# shellcheck disable=SC2039
local repo_domain
repo_domain="$(echo "$1" | awk -F[/:] '{print $4}')"
echo "$1" | sed -e "s/.*$repo_domain[:/]\(.*\)/\1/"
}

_build_url() {
# shellcheck disable=SC2039
local upstream origin branch repo pr_url target
upstream="$(git config --get remote.upstream.url)"
origin="$(git config --get remote.origin.url)"
origin="$(git config --get remote.origin.url | sed -e "s/.git$//")"
branch="$(git symbolic-ref --short HEAD)"
repo="$(_get_repo "$origin")"
pr_url="https://github.com/$repo/pull/new"
pr_url="$origin/pull/new"
target="$1"
test -z "$target" && target=$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f 2)
test -z "$target" && target="master"
Expand Down