@@ -42,6 +42,24 @@ VERSION=$1
4242TAP_PATH=${2:- ${HOMEBREW_TAP_PATH:- " $REPO_ROOT /../homebrew-tap"  } 
4343FORMULA_PATH=" $TAP_PATH /Formula/rsworktree.rb" 
4444
45+ infer_repo_url () {
46+   case  " $1 " in 
47+     git@github.com:* )
48+       local  path=${1# git@ github.com: } 
49+       path=${path% .git} 
50+       echo  " https://github.com/$path " 
51+       ;;
52+     https://github.com/* )
53+       local  path=${1# https:// github.com/ } 
54+       path=${path% .git} 
55+       echo  " https://github.com/$path " 
56+       ;;
57+     * )
58+       echo  " " 
59+       ;;
60+   esac 
61+ }
62+ 
4563if  [[ !  -d  " $TAP_PATH " ;  then 
4664  echo  " error: tap path '$TAP_PATH ' not found" >&2 
4765  exit  1
@@ -62,14 +80,24 @@ if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
6280  exit  1
6381fi 
6482
65- TARBALL_URL=${HOMEBREW_TARBALL_URL:- " https://github.com/ozan/rust-git-worktree/archive/refs/tags/v${VERSION} .tar.gz"  
83+ origin_url=$( git -C " $REPO_ROOT " 2> /dev/null ||  true) 
84+ default_repo_url=$( infer_repo_url " $origin_url " ) 
85+ if  [[ -z  " $default_repo_url " ;  then 
86+   default_repo_url=" https://github.com/ozankasikci/rust-git-worktree" 
87+ fi 
88+ 
89+ TARBALL_URL=${HOMEBREW_TARBALL_URL:- " ${default_repo_url} /archive/refs/tags/v${VERSION} .tar.gz"  
6690
6791tmpdir=$( mktemp -d) 
6892trap  ' rm -rf "$tmpdir"' 
6993tarball=" $tmpdir /rsworktree-${VERSION} .tar.gz" 
7094
7195echo  " Downloading release tarball to compute checksum..." 
72- curl -sSL --fail " $TARBALL_URL " " $tarball " 
96+ if  !  curl -sSL --fail " $TARBALL_URL " " $tarball " ;  then 
97+   echo  " error: failed to download $TARBALL_URL " >&2 
98+   echo  "        make sure tag v$VERSION  is published or set HOMEBREW_TARBALL_URL" >&2 
99+   exit  1
100+ fi 
73101
74102SHA256=$( $checksum_cmd  " $tarball " |  awk ' {print $1}' ) 
75103
0 commit comments