aboutsummaryrefslogblamecommitdiffstats
path: root/git-req.sh
blob: 5c86116359f0dc3627309e5b521dabb1ad789dde (plain) (tree)






















                                                                              
#!/bin/bash
set -eux

[ "$#" -lt 1 ] && exit 1

req_no="$1"

if ! git rev-parse --git-dir >/dev/null 2>&1 ; then
    echo "Must be run from git repo checkout."
    exit 2
fi

repo_url="$(git config --get remote.origin.url)"
if [[ "${repo_url}" =~ gitlab ]] ; then
    rem_ref_name="merge-requests"
    loc_ref_name="mr"
else
    rem_ref_name="pull"
    loc_ref_name="pr"
fi

git fetch origin refs/"$rem_ref_name"/"$req_no"/head:"$loc_ref_name"/"$req_no"
git checkout "$loc_ref_name/$req_no"