Skip to content

Commit

Permalink
Refactor the logic on whether to download upstream tarball
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anthonyfok committed Aug 26, 2021
1 parent 1338367 commit 64dccd7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions make.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (u *upstream) tarballFromHoster() error {
tarURL = fmt.Sprintf("%s/-/archive/%s/%s-%s.tar.%s",
repo, u.tag, project, u.tag, u.compression)
default:
return fmt.Errorf("unsupported hoster")
return fmt.Errorf("unsupported hoster") // Don't change
}

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

if u.isRelease {
if u.hasGodeps {
log.Printf("Godeps/_workspace exists, not downloading tarball from hoster.")
} else {
if !u.hasGodeps { // No need to repack; fetch pristine tarball
u.compression = "gz"
err := u.tarballFromHoster()
if err != nil && err.Error() == "Unsupported hoster" {
log.Printf("INFO: Hoster does not provide release tarball\n")
} else {
return fmt.Errorf("tarball from hoster: %w", err)
if err := u.tarballFromHoster(); err != nil {
if err.Error() == "unsupported hoster" {
log.Printf("INFO: Hoster does not provide release tarball\n")
} else {
return fmt.Errorf("tarball from hoster: %w", err)
}
}
return nil
}
log.Printf("Godeps/_workspace exists, not downloading tarball from hoster.")
}

u.compression = "xz"
Expand Down

0 comments on commit 64dccd7

Please sign in to comment.