Skip to content

Commit

Permalink
Add script for showing the deploy remote/branch
Browse files Browse the repository at this point in the history
  • Loading branch information
julianschuler committed Feb 18, 2025
1 parent 4be60ed commit 33b0ec1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scripts/show_deploy
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"

0 comments on commit 33b0ec1

Please sign in to comment.