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 19, 2025
1 parent 4be60ed commit faa1e8a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/show_deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# 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_url="$(git remote get-url $remote_name)"

if [[ $remote_url == http* ]]; then
remote="$(echo $remote_url | cut -d '/' -f 4)"
else
remote="$(echo $remote_url | cut -d ':' -f 2 | cut -d '/' -f 1)"
fi

echo "$remote/$branch"

0 comments on commit faa1e8a

Please sign in to comment.