@@ -139,28 +139,37 @@ func (u *upstream) get(gopath, repo, rev string) error {
139
139
return rr .VCS .Create (dir , rr .Repo )
140
140
}
141
141
142
- func (u * upstream ) tarballFromHoster () error {
143
- var tarURL string
142
+ func (u * upstream ) tarballUrl () (string , error ) {
144
143
repo := strings .TrimSuffix (u .rr .Repo , ".git" )
145
144
repoU , err := url .Parse (repo )
146
145
if err != nil {
147
- return fmt .Errorf ("parse URL: %w" , err )
146
+ return "" , fmt .Errorf ("parse URL: %w" , err )
148
147
}
149
148
150
149
switch repoU .Host {
151
150
case "github.com" :
152
- tarURL = fmt .Sprintf ("%s/archive/%s.tar.%s" ,
153
- repo , u .tag , u .compression )
151
+ return fmt .Sprintf ("%s/archive/%s.tar.%s" ,
152
+ repo , u .tag , u .compression ), nil
154
153
case "gitlab.com" , "salsa.debian.org" :
155
154
parts := strings .Split (repoU .Path , "/" )
156
155
if len (parts ) < 3 {
157
- return fmt .Errorf ("incomplete repo URL: %s" , u .rr .Repo )
156
+ return "" , fmt .Errorf ("incomplete repo URL: %s" , u .rr .Repo )
158
157
}
159
158
project := parts [2 ]
160
- tarURL = fmt .Sprintf ("%s/-/archive/%s/%s-%s.tar.%s" ,
161
- repo , u .tag , project , u .tag , u .compression )
159
+ return fmt .Sprintf ("%s/-/archive/%s/%s-%s.tar.%s" ,
160
+ repo , u .tag , project , u .tag , u .compression ), nil
161
+ case "git.sr.ht" :
162
+ return fmt .Sprintf ("%s/archive/%s.tar.%s" ,
163
+ repo , u .tag , u .compression ), nil
162
164
default :
163
- return errUnsupportedHoster
165
+ return "" , errUnsupportedHoster
166
+ }
167
+ }
168
+
169
+ func (u * upstream ) tarballFromHoster () error {
170
+ tarURL , err := u .tarballUrl ()
171
+ if err != nil {
172
+ return err
164
173
}
165
174
166
175
done := make (chan struct {})
0 commit comments