Skip to content

Commit

Permalink
Enable LFS automatic pulling for the go_modules ecosystem
Browse files Browse the repository at this point in the history
Turning GIT_LFS_SKIP_SMUDGE on enables automatic pulling by default.
This default is respected by the Go toolchain when downloading module
sources directly from git servers (e.g. GitHub).

Git LFS support is important when Go modules embed large files using
go:embed. Direct download is more common for private repositories but
it is also possible for public repositories (which are often downloaded
from the module-proxy).

The Go toolchain uses the local git installation to fetch archives of
modules from Git servers directly. Some companies commits large files
using Git LFS which happen to be part of their Go module source tree.
Without git-lfs installed, the local git installation does not
automatically resolve those files which causes "checksum mismatch"
against the committed go.sum.
  • Loading branch information
danielorbach authored and sachin-sandhu committed Jul 10, 2024
1 parent ccb9ffc commit 179bbc1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions go_modules/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ ENV GOTOOLCHAIN="go1.20.10"
# This pre-installs go 1.20 so that each job doesn't have to do it.
RUN go version
ENV GO_LEGACY=$GOTOOLCHAIN

# Enable automatic pulling of files stored with Git LFS.
# This is crucial for the Go toolchain to correctly compute module hashes in repositories
# with LFS committed files.
# This is relevant only for Go Modules embedding (with //go:embed) large files and does not
# affect repositories that do not commit files to LFS.
ENV GIT_LFS_SKIP_SMUDGE=1

0 comments on commit 179bbc1

Please sign in to comment.