Skip to content

Commit

Permalink
Merge pull request #31 from dwmkerr/feat/gpr
Browse files Browse the repository at this point in the history
feat: first cut of gpr
  • Loading branch information
dwmkerr committed Oct 9, 2018
2 parents 46c9ee1 + 416d643 commit 786b74c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions profile/git.sh
Expand Up @@ -24,3 +24,44 @@ alias gbranchr='for k in `git branch -r | \

# Push to origin. Use it all the time innit?
alias gpo='git push --set-upstream origin $(git_current_branch)'

# git push that directly opens merge request in GitLab
gpmr() {
# push to current branch to remote origin
gitOutput=`git push origin $(git_current_branch) 2>&1` && \
# get URL for merge request
mrURL=`echo $gitOutput | awk '/remote: http/ {print $2}'` && \
# open new merge request
open -a Google\ Chrome $mrURL
}

# git push that directly opens merge request in GitLab
gpmr() {
# push to current branch to remote origin
gitOutput=`git push origin $(git_current_branch) 2>&1` && \
# get URL for merge request
mrURL=`echo $gitOutput | awk '/remote: http/ {print $2}'` && \
# open new merge request
open -a Google\ Chrome $mrURL
}

# How to get the current branch:
#
gpr() {
# Get the current branch name.
branch=$(git symbolic-ref -q HEAD)
branch=${branch##refs/heads/}
branch=${branch:-HEAD}

# Push to origin, grabbing the output.
push_output=`git push origin -u $(branch) 2>&1`

# Show the output, so that it is clear to the user what is happening.
echo $(push_output)

# If there's anything which starts with http, it's a good guess it'll be a
# link to GitHub/GitLab/Whatever. So open it.
mrURL=`echo $gitOutput | awk '/remote: http/ {print $2}'` && \
# open new merge request
open -a Google\ Chrome $mrURL
}

0 comments on commit 786b74c

Please sign in to comment.