-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
Background
-
When Git LFS is installed on the client machine,
cmd/gocan work well with Git LFS, but only when using modules not via GOPROXY and GOPATH packages (called "packages" hereon for brevity). -
When Git LFS is not installed,
go getwill download the repository but not smudge, so any files stored in Git LFS are left as text-file refs. This can break builds when such files are required for the build (e.g. binary syso files). -
The Google-hosted
proxy.golang.orgusescmd/goto download package contents. That service does not have Git LFS installed, and so every module retrieved via the proxy lacks Git LFS content. This can break builds, and can also result in checksum mismatches when a user tries to verify a module they previously downloaded usingcmd/goin direct mode while having Git LFS installed. -
For further detailed background information, see proxy.golang.org: support git-lfs #47241.
Proposal
-
A new VCS named
git-lfsthat prescribes the use of Git LFS when fetching a Git repo. -
New
cmd/gosupport for the new VCS: using a built-in Git LFS client implementation, or one that relies on Git LFS installed on the client machine. For the latter:-
If not installed,
cmd/goshould inform the user that Git LFS is required before erroring out. i.e.cmd/goshould never leave un-smudged Git LFS ref files in a fetched package. -
Have Git LFS installed on
proxy.golang.org.
-
-
Module (package) owners opt-in to mandatory Git LFS package retrieval using the following:
-
Specifying
git-lfsas thevcsargument in thecontentattribute of the go-import meta tag. -
Using the new VCS qualifier,
-
in the
moduledirective in ago.modfile, e.g.module go.jpap.org/example.git-lfs.Here the
.git-lfssuffix forms part of the module path when used with the GOPROXY protocol and the local module caches ($GOPATH/pkg/mod). -
in the import comment in a package, e.g.
package example // import "go.jpap.org/example.git-lfs".
In both cases above, the
.git-lfssuffix should be ignored when matching the module path (package import path) against animportstatement in a Go source file. With reference to the examples above, the Go source having import statementimport "go.jpap.org/example"should match even though it does not specify the VCS qualifier. -
-
-
Module (package) users can explicitly qualify a module path (package import path) using the proposed VCS so that Git LFS is used to access the repository. This is helpful when there is no
go-importHTTP server available to resolve the repository URL. -
Where Git LFS is installed, explicitly disable smudging on
cmd/gofetches of modules (packages) not opted into thegit-lfsVCS qualifier as outlined in Item 3. This prevents the checksum mismatch problem outlined in proxy.golang.org: support git-lfs #47241. -
Irrespective of whether Git LFS is installed, when fetching a module (package)
cmd/goshould error out when it detects that a package has opted into Git LFS and the VCS qualifier is notgit-lfs. This forces module (package) users to also opt-in to using Git LFS, and prevents broken builds due to files not being smudged appropriately when Git LFS is not installed.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status