git

package
v0.0.0-...-7c31ad9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasFoldedPrefix

func HasFoldedPrefix(s, prefix string) bool

Combination of strings.EqualFold and strings.HasSuffix

func HasFoldedSuffix

func HasFoldedSuffix(s, suffix string) bool

Combination of strings.EqualFold and strings.HasSuffix

func SanitizeRemote

func SanitizeRemote(remote string) (string, error)

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

func SlugifyRemote(remoteURL string) string

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.

func StringToHash

func StringToHash(hash string) (plumbing.Hash, error)

Transform the rio commit ID to a git hash. Performs some basic checks on inputs.

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

func (c *Controller) Clone(ctx context.Context) error

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.

func (*Controller) Update

func (c *Controller) Update(ctx context.Context) error
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.

func (*Reader) Close

func (r *Reader) Close()

Closes the iterator

func (*Reader) Next

func (r *Reader) Next() (*Header, error)

Moves the reader to the next file and returns the files header information

func (*Reader) Read

func (r *Reader) Read(b []byte) (int, error)

Reads the current file contents.

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL