]>
Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/modcmd: inject modfetch.Fetcher_ into DownloadModule
This commit continues the injection of the global Fetcher_ variable into
the various function calls that make use of it. The purpose is to
prepare for the eventual removal of the global Fetcher_ variable and
eliminate global state within the modfetch package.
[git-generate]
cd src/cmd/go/internal/modcmd
rf '
inject modfetch.Fetcher_ DownloadModule
'
cd ../modfetch
rf '
add downloadZip:/f, err := tempFile.*/+0 _ = f \
file, err := tempFile(ctx, filepath.Dir(zipfile), filepath.Base(zipfile), 0o666) \
_ = file
'
rf '
add downloadZip:/f.Close\(\)/+0 file.Close()
rm downloadZip:/file.Close\(\)/-1
add downloadZip:/os.Remove\(f.Name\(\)\)/+0 os.Remove(file.Name())
rm downloadZip:/os.Remove\(file.Name\(\)\)/-1
'
sed -i '
s/ f, err := tempFile(ctx, filepath.Dir(zipfile), filepath.Base(zipfile), 0o666)/file, err := tempFile(ctx, filepath.Dir(zipfile), filepath.Base(zipfile), 0o666)/
s/err := repo.Zip(ctx, f, mod.Version)/err := repo.Zip(ctx, file, mod.Version)/
s/if _, err := f.Seek(0, io.SeekStart); err != nil {/if _, err := file.Seek(0, io.SeekStart); err != nil {/
s/if err := f.Truncate(0); err != nil {/if err := file.Truncate(0); err != nil {/
s/fi, err := f.Stat()/fi, err := file.Stat()/
s/z, err := zip.NewReader(f, fi.Size())/z, err := zip.NewReader(file, fi.Size())/
s/for _, f := range z.File {/for _, zf := range z.File {/
s/if !strings.HasPrefix(f.Name, prefix) {/if !strings.HasPrefix(zf.Name, prefix) {/
s/return fmt.Errorf("zip for %s has unexpected file %s", prefix\[:len(prefix)-1\], f.Name)/return fmt.Errorf("zip for %s has unexpected file %s", prefix[:len(prefix)-1], zf.Name)/
s/if err := f.Close(); err != nil {/if err := file.Close(); err != nil {/
s/if err := hashZip(fetcher_, mod, f.Name(), ziphashfile); err != nil {/if err := hashZip(fetcher_, mod, file.Name(), ziphashfile); err != nil {/
s/if err := os.Rename(f.Name(), zipfile); err != nil {/if err := os.Rename(file.Name(), zipfile); err != nil {/
' fetch.go
rf '
rm downloadZip:/_ = file/-3 downloadZip:/_ = file/-2 downloadZip:/file, err := tempFile\(ctx, filepath.Dir\(zipfile\), filepath.Base\(zipfile\), 0o666\)/+1
'
rf '
mv InfoFile.fetcher_ InfoFile.f
mv InfoFile Fetcher.InfoFile
mv GoModFile.fetcher_ GoModFile.f
mv GoModFile Fetcher.GoModFile
mv GoModSum.fetcher_ GoModSum.f
mv GoModSum Fetcher.GoModSum
mv Download.fetcher_ Download.f
mv Download Fetcher.Download
mv download.fetcher_ download.f
mv download Fetcher.download
mv DownloadZip.fetcher_ DownloadZip.f
mv DownloadZip Fetcher.DownloadZip
mv downloadZip.fetcher_ downloadZip.f
mv downloadZip Fetcher.downloadZip
mv checkMod.fetcher_ checkMod.f
mv checkMod Fetcher.checkMod
mv hashZip.fetcher_ hashZip.f
'
Change-Id: I1d2e09b8523f5ef2be04b91d858d98fb79c0a771
Reviewed-on: https://go-review.googlesource.com/c/go/+/724242
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>