git

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalRepoURL

func CanonicalRepoURL(repoURL string) (string, error)

Types

type Client

type Client struct {
	// Sh is the *shell.Sh instance this client uses for all shell interaction.
	Sh *shell.Sh
	// Bin is the path to the git binary. This defaults to "git", therefore
	// relying that git is in the path.
	Bin string
	// Version is the version of git at Bin.
	Version semv.Version
}

Client is a git client that shells out to locally installed git. It requires that git is in the path by default, although you can override that by setting the Bin field to a path to a different Git. Client is used to perform git commands within a particular directory, determined by its shell.Sh instance.

func NewClient

func NewClient(sh *shell.Sh) (*Client, error)

NewClient returns a git client, as long as `git --version` succeeds. The *shell.Sh is used for all commands. The client created by this func uses git in your path.

func NewClientInVersionRange

func NewClientInVersionRange(sh *shell.Sh, r semv.Range) (*Client, error)

NewClientInVersionRange is similar to NewClient, but returns nil and and error if the version of the installed git client is not in the specified range.

func (*Client) Clone

func (c *Client) Clone() *Client

Clone produces a clone of the client

func (*Client) CurrentBranch

func (c *Client) CurrentBranch() (string, error)

func (*Client) Dir

func (c *Client) Dir() string

func (*Client) ListFiles

func (c *Client) ListFiles() ([]string, error)

ListFiles lists all files that are tracked in the repo.

func (*Client) ListRemotes

func (c *Client) ListRemotes() (Remotes, error)

func (*Client) ListTags

func (c *Client) ListTags() ([]sous.Tag, error)

func (*Client) ListUnpushedCommits

func (c *Client) ListUnpushedCommits() ([]string, error)

ListUnpushedCommits returns a list of commit sha1s for commits that haven't been pushed to any remote

func (*Client) ModifiedFiles

func (c *Client) ModifiedFiles() ([]string, error)

func (*Client) NearestTag

func (c *Client) NearestTag() (string, error)

func (*Client) NewFiles

func (c *Client) NewFiles() ([]string, error)

func (*Client) OpenRepo

func (c *Client) OpenRepo(dirpath string) (*Repo, error)

OpenRepo opens a repo

func (*Client) RepoRoot

func (c *Client) RepoRoot() (string, error)

func (*Client) Revision

func (c *Client) Revision() (string, error)

func (*Client) RevisionAt

func (c *Client) RevisionAt(ref string) (string, error)

type Remote

type Remote struct {
	Name, PushURL, FetchURL string
}

type Remotes

type Remotes map[string]Remote

func (Remotes) AddFetch

func (rs Remotes) AddFetch(name, url string)

func (Remotes) AddPush

func (rs Remotes) AddPush(name, url string)

type Repo

type Repo struct {
	// Root is the root dir of this repo
	Root string
	// Client is a git client inside this repo.
	Client *Client
}

Repo is a git repository.

func NewRepo

func NewRepo(c *Client) (*Repo, error)

NewRepo takes a client, which it expects to already be inside a repo directory. It returns an error if the client is not inside a repository or if it fails to determine that fact. Note that it can be anywhere in a repository, it doesn't need to be in the root.

func (*Repo) SourceContext

func (r *Repo) SourceContext() (*sous.SourceContext, error)

SourceContext gathers together a number of bits of information about the repository such as its current branch, revision, nearest tag, nearest semver tag, etc.

Jump to

Keyboard shortcuts

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