Categorygithub.com/thediveo/gitrepofs
modulepackage
0.9.5
Repository: https://github.com/thediveo/gitrepofs.git
Documentation: pkg.go.dev

# README

gitrepofs

PkgGoDev GitHub build and test Coverage Go Report Card

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")

Other Implementations

  • @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 that path.Clean is supposed to sanitize.

  • out of competition: @posener/gitfs tackles http.FileSystem instead.

Supported Go Versions

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).

Copyright and License

gitrepofs is Copyright 2023 Harald Albrecht, and licensed under the Apache License, Version 2.0.

# Packages

No description provided by the author
Package version implements finding the latest and greatest tagged version in a remote git repository.

# Functions

New returns a [fs.FS] for the specified tree of the git repository object, and using the specified modification time.
NewDirectory returns a new Directory object representing a git tree.
NewDirEntry returns a new DirEntry object for a file or directory entry.
NewFile returns a new File object, given a file information object and the file's contents blob.
NewFileInfo returns a new FileInfo object, given a git tree entry, file size and modification time stamp.
NewFileInfoFromTree returns a new FileInfo object that represents the specified tree as a directory itself.
NewForRevision returns a [fs.FS] git repository file system object that provides read access to the files in the remote repository at the specified tag.

# Structs

Directory represents completely unexpectedly a git directory.
DirEntry represents an entry read from a directory.
File represents a git regular or executable file.
FileInfo implements fs.FileInfo for both a git (regular/executable) file blob as well as a directory.
FS provides a view into a specific git tree.