A Go fs.FS git repository file system to easily access a repository at a specific tag (or other git reference).
The main envisioned use case is for go generate
-based updates from upstream
repositories to fetch the latest C definitions without the need to integrate
upstream C libraries.
remoteURL := "https://gohub.org/froozle/baduzle"
latest, latestref, err := version.LatestReleaseTag(context.Background(),
remoteURL, version.SemverMatcher)
gfs, err := NewForRevision(context.Background(), remoteURL, latestref)
contents, err := fs.ReadFile(gfs, "some/useful/file.h")
-
@hairyhenderson/go-fsimpl includes a git file system implementation (beside others). It uses the neat trick of cloning a repository into a local work tree in memory (instead of on "disk") and then serves from this memory-based file system. This design requires files to be present twice: once in the in-memory cloned repository and another time in the memory-based file system. Actively maintained at the time of this writing, as well as equiped with lots of unit tests.
-
@ear7h/go-git-fs serves directly from an in-memory git repository clone without a work tree. It doesn't come with any unit tests and hasn't been maintained since May 2021. The code does the fs.ValidPath checks but then adds an unnecessary path.Clean because
fs.ValidPath
blocks all the things thatpath.Clean
is supposed to sanitize. -
out of competition: @posener/gitfs tackles http.FileSystem instead.
gitrepofs
supports versions of Go that are noted by the Go release policy,
that is, major versions N and N-1 (where N is the current major version).
gitrepofs
is Copyright 2023 Harald Albrecht, and licensed under the Apache
License, Version 2.0.