Skip to content

Commit 64dccd7

Browse files
committed
Refactor the logic on whether to download upstream tarball
This resolves an error introduced by the "Annotate errors with context" but ultimately due to the somewhat confusing way I coded the error handling before.
1 parent 1338367 commit 64dccd7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

make.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (u *upstream) tarballFromHoster() error {
156156
tarURL = fmt.Sprintf("%s/-/archive/%s/%s-%s.tar.%s",
157157
repo, u.tag, project, u.tag, u.compression)
158158
default:
159-
return fmt.Errorf("unsupported hoster")
159+
return fmt.Errorf("unsupported hoster") // Don't change
160160
}
161161

162162
done := make(chan struct{})
@@ -179,17 +179,18 @@ func (u *upstream) tar(gopath, repo string) error {
179179
f.Close()
180180

181181
if u.isRelease {
182-
if u.hasGodeps {
183-
log.Printf("Godeps/_workspace exists, not downloading tarball from hoster.")
184-
} else {
182+
if !u.hasGodeps { // No need to repack; fetch pristine tarball
185183
u.compression = "gz"
186-
err := u.tarballFromHoster()
187-
if err != nil && err.Error() == "Unsupported hoster" {
188-
log.Printf("INFO: Hoster does not provide release tarball\n")
189-
} else {
190-
return fmt.Errorf("tarball from hoster: %w", err)
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+
}
191190
}
191+
return nil
192192
}
193+
log.Printf("Godeps/_workspace exists, not downloading tarball from hoster.")
193194
}
194195

195196
u.compression = "xz"

0 commit comments

Comments
 (0)