Skip to content

Commit b851343

Browse files
committed
Fix empty tarball in case of "unsupported hoster"
This fixes the error that I introduced on 2021-08-26 in commit 64dccd7 "Refactor the logic on whether to download upstream tarball" Thanks to @mdosch for the report and @creekorful for tips on error handling Fixes #180
1 parent d713261 commit b851343

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

make.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"errors"
45
"flag"
56
"fmt"
67
"io"
@@ -31,6 +32,8 @@ const (
3132

3233
var wrapAndSort string
3334

35+
var errUnsupportedHoster = errors.New("unsupported hoster")
36+
3437
func passthroughEnv() []string {
3538
var relevantVariables = []string{
3639
"HOME",
@@ -156,7 +159,7 @@ func (u *upstream) tarballFromHoster() error {
156159
tarURL = fmt.Sprintf("%s/-/archive/%s/%s-%s.tar.%s",
157160
repo, u.tag, project, u.tag, u.compression)
158161
default:
159-
return fmt.Errorf("unsupported hoster") // Don't change
162+
return errUnsupportedHoster
160163
}
161164

162165
done := make(chan struct{})
@@ -179,18 +182,18 @@ func (u *upstream) tar(gopath, repo string) error {
179182
f.Close()
180183

181184
if u.isRelease {
182-
if !u.hasGodeps { // No need to repack; fetch pristine tarball
185+
if u.hasGodeps {
186+
log.Printf("Godeps/_workspace exists, not downloading tarball from hoster.")
187+
} else {
183188
u.compression = "gz"
184-
if err := u.tarballFromHoster(); err != nil {
185-
if err.Error() == "unsupported hoster" {
186-
log.Printf("INFO: Hoster does not provide release tarball\n")
187-
} else {
188-
return fmt.Errorf("tarball from hoster: %w", err)
189-
}
189+
if err := u.tarballFromHoster(); err == nil {
190+
return nil
191+
} else if err == errUnsupportedHoster {
192+
log.Printf("INFO: Hoster does not provide release tarball\n")
193+
} else {
194+
return fmt.Errorf("tarball from hoster: %w", err)
190195
}
191-
return nil
192196
}
193-
log.Printf("Godeps/_workspace exists, not downloading tarball from hoster.")
194197
}
195198

196199
u.compression = "xz"

0 commit comments

Comments
 (0)