#!/usr/bin/bash

# DESCRIPTION:
#
# Get remote url for a branch. Prefer push url.
#
# env: GIT_ROOT, GIT_REMOTE

cd "$GIT_ROOT"

remote_url="$(/usr/bin/git config --get remote."$GIT_REMOTE".pushurl)"
if [ -z "$remote_url" ]; then
    remote_url="$(/usr/bin/git config --get remote."$GIT_REMOTE".url)"
fi

if [ -n "$remote_url" ]; then
    echo "$remote_url"
fi
