]> Cypherpunks repositories - gostls13.git/commit
cmd/go: add -reuse flag to make proxy invocations more efficient
authorRuss Cox <rsc@golang.org>
Fri, 10 Jun 2022 16:03:06 +0000 (12:03 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 5 Jul 2022 12:57:45 +0000 (12:57 +0000)
commit5f305ae8e5796ea3821088863a6842117c58da72
treeef0b79878e83bbf59b44761a8c4013f0560fd2e6
parent84e091eef033255b4a3fdb515d677faa135714dc
cmd/go: add -reuse flag to make proxy invocations more efficient

The go list -m and go mod download commands now have a -reuse flag,
which is passed the name of a file containing the JSON output from a
previous run of the same command. (It is up to the caller to ensure
that flags such as -versions or -retracted, which affect the output,
are consistent between the old and new run.)

The new run uses the old JSON to evaluate whether the answer is
unchanged since the old run. If so, it reuses that information,
avoiding a costly 'git fetch', and sets a new Reuse: true field in its
own JSON output.

This dance with saving the JSON output and passing it back to -reuse
is not necessary on most systems, because the go command caches
version control checkouts in the module cache. That cache means that a
new 'git fetch' would only download the commits that are new since the
previous one (often none at all).

The dance becomes important only on systems that do not preserve the
module cache, for example by running 'go clean -modcache' aggressively
or by running in some environment that starts with an empty file
system.

For #53644.

Change-Id: I447960abf8055f83cc6dbc699a9fde9931130004
Reviewed-on: https://go-review.googlesource.com/c/go/+/411398
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 files changed:
src/cmd/go/alldocs.go
src/cmd/go/internal/list/list.go
src/cmd/go/internal/modcmd/download.go
src/cmd/go/internal/modcmd/why.go
src/cmd/go/internal/modfetch/cache.go
src/cmd/go/internal/modfetch/codehost/codehost.go
src/cmd/go/internal/modfetch/codehost/git.go
src/cmd/go/internal/modfetch/coderepo.go
src/cmd/go/internal/modinfo/info.go
src/cmd/go/internal/modload/build.go
src/cmd/go/internal/modload/edit.go
src/cmd/go/internal/modload/list.go
src/cmd/go/internal/modload/mvs.go
src/cmd/go/internal/modload/query.go
src/cmd/go/testdata/script/reuse_git.txt [new file with mode: 0644]