mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 23:46:24 -04:00
Merge pull request #641 from tj/fix_pull_request_upstream
pull_request: should use detected upstream instead of hardcore origin
This commit is contained in:
commit
6e9da2a4e7
|
|
@ -41,16 +41,22 @@ test -z "$user" && abort "git config user.email required"
|
|||
# branch
|
||||
|
||||
branch=${1-$(git symbolic-ref HEAD | sed 's/refs\/heads\///')}
|
||||
remote=$(git config branch."$branch".remote)
|
||||
if [ -z "$remote" ]; then
|
||||
echo 'no upstream found, push to origin as default'
|
||||
remote="origin"
|
||||
fi
|
||||
[ "$remote" == "." ] && abort "the upstream should be a remote branch."
|
||||
|
||||
# make sure it's pushed
|
||||
|
||||
git push origin "$branch" || abort "failed to push $branch"
|
||||
git push "$remote" "$branch" || abort "failed to push $branch"
|
||||
|
||||
origin=$(git config remote.origin.url)
|
||||
if [[ $origin == git@* ]]; then
|
||||
project=${origin##*:}
|
||||
remote_url=$(git config remote."$remote".url)
|
||||
if [[ "$remote_url" == git@* ]]; then
|
||||
project=${remote_url##*:}
|
||||
else
|
||||
project=${origin#https://*/}
|
||||
project=${remote_url#https://*/}
|
||||
fi
|
||||
project=${project%.git}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue