~kaction/forge-link

09b40104a13555c378f187458f66917a62bf0126 — Dmitry Bogatov 3 years ago cb1a325
Correctly handle remotes other than supported forges
1 files changed, 6 insertions(+), 0 deletions(-)

M forge-link
M forge-link => forge-link +6 -0
@@ 62,12 62,18 @@ fi

for remote; do
	base=$(git config "remote.${remote}.url")
	url=""
	if [ "${base}" != "${base##https://git.sr.ht/}" ] ; then
		url="${base}/tree/${sha1}${relpath}"
		if [ "${line}" != 0 ] ; then
			url="${url}#L${line}"
		fi
	fi

	if [ -z "${url}" ] ; then
		continue
	fi

	# Use HEAD method, don't waste our and forge's bandwidth.
	http_code=$(curl -I -s -o /dev/null "${url}" -w '%{http_code}')
	if [ "${http_code}" = 200 ] ; then