From eb47be630a96af035defbd47484627d4597e55c2 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 29 Nov 2023 18:18:03 +0300 Subject: [PATCH] Add a script to resolve rewritten URL --- git-resolve-remote | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 git-resolve-remote diff --git a/git-resolve-remote b/git-resolve-remote new file mode 100755 index 0000000..4c76cf6 --- /dev/null +++ b/git-resolve-remote @@ -0,0 +1,24 @@ +#! /bin/sh +# See https://stackoverflow.com/q/77560684/7976758 + +# Uses a transient repository so it's not effective to resolve many URLs. +# For many URLs create one repository, add remotes, +# get rewritten URLs and then remove the repository. + +set -e + +if [ $# -ne 1 ]; then + echo "Usage $0 URL" >&2 + exit 1 +fi + +cd /tmp +rm -rf _git_resolve_remote.tmp +git init --quiet _git_resolve_remote.tmp +cd _git_resolve_remote.tmp + +git remote add origin "$1" +git remote get-url origin + +cd .. +exec rm -rf _git_resolve_remote.tmp -- 2.39.5