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

feat: first cut of gpr #31

Merged
merged 1 commit into from Oct 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}