Documentation ¶
Overview ¶
The git warehouse is a repository style warehouse. This means that the hashes given represent a given state of the repository instead of describing the state of a fileset. This git repository has several properties that are unique.
- You cannot write to it idempotently.
- Repositories are not interchangeable.
- Different hashes can result in equivalent filesets
- We cannot detect different forks of a repository.
This warehouse requires git-upload-pack to be on the path. But otherwise is much less dependent on the host's git implementation
Index ¶
- func HasFoldedPrefix(s, prefix string) bool
- func HasFoldedSuffix(s, suffix string) bool
- func SanitizeRemote(remote string) (string, error)
- func SlugifyRemote(remoteURL string) string
- func StringToHash(hash string) (plumbing.Hash, error)
- type Controller
- func (c *Controller) Clone(ctx context.Context) error
- func (c *Controller) Contains(hash string) bool
- func (c *Controller) GetCommit(hash string) (*object.Commit, error)
- func (c *Controller) GetTree(hash string) (*object.Tree, error)
- func (c *Controller) NewReader(commitHash string) (*Reader, error)
- func (c *Controller) NewTreeWalker(commitHash string) (*object.TreeWalker, error)
- func (c *Controller) Submodules(commitHash string) (map[string]Submodule, error)
- func (c *Controller) Update(ctx context.Context) error
- type Header
- type Reader
- type Submodule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasFoldedPrefix ¶
Combination of strings.EqualFold and strings.HasSuffix
func HasFoldedSuffix ¶
Combination of strings.EqualFold and strings.HasSuffix
func SanitizeRemote ¶
We force https when talking to github because github may refuse to respond to http urls. Otherwise this will return an endpoint that will use the correct protocol based on the remote. We could improve behavior by overriding installing new protocols. Perhaps using a particular git user agent would avoid the strange github behavior.
func SlugifyRemote ¶
Return a string that's safe to use as a dir name.
Uses URL query escaping so it remains roughly readable. Does not attempt any URL normalization.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Combo of remote repo interactions and a local (possibly on-disk) cache; these responsibilities are combined because in the case of "remote" repos that are actually also local, we'll use their object stores directly rather than replicating the entire object store again to our cache areas.
func NewController ¶
func NewController(workingDirectory riofs.FS, addr api.WarehouseLocation) (*Controller, error)
Initialize a new warehouse controller that operates on a local filesystem.
May return errors of category:
- `rio.ErrUsage` -- for unsupported addressses
- `rio.ErrWarehouseUnavailable` -- if the warehouse doesn't exist
- `rio.ErrLocalCacheProblem` -- if unable to create a cache directory
func (*Controller) Contains ¶
func (c *Controller) Contains(hash string) bool
Returns true if the repository contains the commit for the given hash
func (*Controller) GetCommit ¶
func (c *Controller) GetCommit(hash string) (*object.Commit, error)
Returns the commit for the given hash
func (*Controller) GetTree ¶
func (c *Controller) GetTree(hash string) (*object.Tree, error)
Returns the tree for a given commit hash
func (*Controller) NewReader ¶
func (c *Controller) NewReader(commitHash string) (*Reader, error)
Creates a reader/iterator for extracting files from a particular commit.
func (*Controller) NewTreeWalker ¶
func (c *Controller) NewTreeWalker(commitHash string) (*object.TreeWalker, error)
func (*Controller) Submodules ¶
func (c *Controller) Submodules(commitHash string) (map[string]Submodule, error)
Returns the submodule map for a given commit hash.
Keys in the map are submodules "names" as given in the committed '.gitmodules' file; values contain the repeated name, the path, the url from the '.gitmodules' file, and the hash as a string.
If a path specified in '.gitmodules' does not have a gitlink (i.e., no real hash is there, or, some other kind of object is in the repo at that path), we'll return an error. It's also quite possible that there will be *more* gitlinks in the tree; we won't notice this here, because this function does not do a full treewalk.
type Header ¶
type Header struct { Name string // name of header file entry Mode int64 // permission and mode bits Size int64 // length in bytes Binary bool }
File header information
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a utility for extracting files from the repository. It is loosely based on the `archive/tar` package.
type Submodule ¶
type Submodule struct { // Name module name Name string // Path defines the path, relative to the top-level directory of the Git // working tree. Path string // URL defines a URL from which the submodule repository can be cloned. URL string // Branch is a remote branch name for tracking updates in the upstream // submodule. Optional value. Branch string // Ye olde hash! Hash string }