-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script for showing the deploy remote/branch
- Loading branch information
1 parent
4be60ed
commit 33b0ec1
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
|
||
# exit on error | ||
set -e | ||
|
||
print_help() { | ||
cat <<-__helpText__ | ||
Usage: $0 | ||
Show the remote/branch combination required for deploying the current branch. | ||
__helpText__ | ||
} | ||
|
||
# print help if any parameters are specified | ||
if [ $# -gt 0 ]; then | ||
print_help | ||
exit 1 | ||
fi | ||
|
||
# get remote and branch name | ||
output="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})" | ||
IFS="/" read remote_name branch <<< "$output" | ||
|
||
# the name of the remote may be different than the one of the remote URL | ||
remote="$(git remote get-url $remote_name | cut -d ':' -f 2 | cut -d '/' -f 1)" | ||
|
||
echo "$remote/$branch" |