Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 5f93bf0

Browse files
committed
Try then fall back
1 parent 189f2dd commit 5f93bf0

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

buildserver/deps.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,17 +495,20 @@ func FetchCommonDeps() {
495495
// Source 1 and 2 are performance optimizations over cloning the whole repo.
496496
var NewDepRepoVFS = func(ctx context.Context, cloneURL *url.URL, rev string, zipURLTemplate *string) (ctxvfs.FileSystem, error) {
497497
if zipURLTemplate != nil {
498-
var repoName string
499-
if strings.HasSuffix(cloneURL.Path, ".git") {
500-
repoName = strings.TrimSuffix(cloneURL.Path, ".git")
501-
} else {
502-
repoName = cloneURL.Path
503-
}
504-
zipURL := fmt.Sprintf(*zipURLTemplate, path.Join(cloneURL.Host, repoName), rev)
498+
zipURL := fmt.Sprintf(*zipURLTemplate, path.Join(cloneURL.Host, cloneURL.Path), rev)
505499
archive, err := vfsutil.NewZipVFS(ctx, zipURL, depZipFetch.Inc, depZipFetchFailed.Inc, false)
506500
if archive != nil && err == nil {
507501
return archive, nil
508502
}
503+
504+
// If the repository name ends with `.git` then try again without it.
505+
if strings.HasSuffix(cloneURL.Path, ".git") {
506+
zipURL := fmt.Sprintf(*zipURLTemplate, path.Join(cloneURL.Host, strings.TrimSuffix(cloneURL.Path, ".git")), rev)
507+
archive, err := vfsutil.NewZipVFS(ctx, zipURL, depZipFetch.Inc, depZipFetchFailed.Inc, false)
508+
if archive != nil && err == nil {
509+
return archive, nil
510+
}
511+
}
509512
}
510513

511514
// Fast-path for GitHub repos, which we can fetch on-demand from

0 commit comments

Comments
 (0)