Documentation ¶
Index ¶
- func CanonicalRepoURL(repoURL string) (string, error)
- type Client
- func (c *Client) CloneClient() *Client
- func (c *Client) CloneRepo(repo, localPath string) error
- func (c *Client) CurrentBranch() (string, error)
- func (c *Client) Dir() string
- func (c *Client) ListFiles() ([]string, error)
- func (c *Client) ListRemotes() (Remotes, error)
- func (c *Client) ListTags() ([]sous.Tag, error)
- func (c *Client) ListUnpushedCommits() ([]string, error)
- func (c *Client) ModifiedFiles() ([]string, error)
- func (c *Client) NearestTag() (string, error)
- func (c *Client) NewFiles() ([]string, error)
- func (c *Client) OpenRepo(dirpath string) (*Repo, error)
- func (c *Client) RepoRoot() (string, error)
- func (c *Client) Revision() (string, error)
- func (c *Client) RevisionAt(ref string) (string, error)
- type Remote
- type Remotes
- type Repo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalRepoURL ¶
CanonicalRepoURL returns a canonicalised Git repository URL. It accepts input URLs using the protocols ssh, git, https, possibly including credentials, and possibly ending with ".git", and returns a clean path of the form: <hostname>/<repo-path>.
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 ¶
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 ¶
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) CloneClient ¶ added in v0.0.3
CloneClient produces a clone of the client.
func (*Client) CurrentBranch ¶
CurrentBranch returns the currently checked out branch name.
func (*Client) ListRemotes ¶
ListRemotes lists all configured remotes.
func (*Client) ListUnpushedCommits ¶
ListUnpushedCommits returns a list of commit sha1s for commits that haven't been pushed to any remote
func (*Client) ModifiedFiles ¶
ModifiedFiles returns the list of tracked, modified files.
func (*Client) NearestTag ¶
NearestTag returns the nearest tag contained in the HEAD revision.
type Remotes ¶
Remotes is a map of Git remote name to Remote.
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 ¶
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 ¶
SourceContext gathers together a number of bits of information about the repository such as its current branch, revision, nearest tag, nearest semver tag, etc.