vcsstate: github.com/shurcooL/vcsstate Index | Files

package vcsstate

import "github.com/shurcooL/vcsstate"

Package vcsstate allows getting the state of version control system repositories.

Index

Package Files

git17.go git28.go hg.go util.go vcsstate.go

Variables

var ErrNoRemote = errors.New("local repository has no valid remote")

ErrNoRemote is the error used when the local repository doesn't have a valid remote.

type NotFoundError Uses

type NotFoundError struct {
    Err error // Underlying error with more details.
}

NotFoundError records an error where the remote repository is not found.

func (NotFoundError) Error Uses

func (e NotFoundError) Error() string

type RemoteVCS Uses

type RemoteVCS interface {
    // RemoteBranchAndRevision returns the name and latest revision of the default branch
    // from the remote. If the remote repository is not found, NotFoundError is returned.
    RemoteBranchAndRevision(remoteURL string) (branch string, revision string, err error)
}

RemoteVCS describes how to use a version control system to get the remote status of a repository with remoteURL.

func NewRemoteVCS Uses

func NewRemoteVCS(vcs *vcs.Cmd) (RemoteVCS, error)

NewRemoteVCS creates a RemoteVCS with same type as vcs.

type VCS Uses

type VCS interface {
    // Status returns the status of working directory.
    // It returns empty string if no outstanding status.
    Status(dir string) (string, error)

    // Branch returns the name of the locally checked out branch.
    Branch(dir string) (string, error)

    // LocalRevision returns current local revision of default branch.
    LocalRevision(dir string, defaultBranch string) (string, error)

    // Stash returns a non-empty string if the repository has a stash.
    Stash(dir string) (string, error)

    // Contains reports whether the local default branch contains
    // the commit specified by revision.
    Contains(dir string, revision string, defaultBranch string) (bool, error)

    // RemoteContains reports whether the remote default branch contains
    // the commit specified by revision.
    RemoteContains(dir string, revision string) (bool, error)

    // RemoteURL returns primary remote URL, as set in the local repository.
    // If there's no remote, then ErrNoRemote is returned.
    RemoteURL(dir string) (string, error)

    // RemoteBranchAndRevision returns the name and latest revision of the default branch
    // from the remote. If there's no remote, then ErrNoRemote is returned, and the
    // default branch can be queried with NoRemoteDefaultBranch.
    // If the remote repository is not found, NotFoundError is returned,
    // and the default branch can be queried with NoRemoteDefaultBranch.
    // This operation requires the use of network, and will fail if offline.
    // When offline, CachedRemoteDefaultBranch can be used as a fallback.
    RemoteBranchAndRevision(dir string) (branch string, revision string, err error)

    // CachedRemoteDefaultBranch returns a locally cached remote default branch,
    // if it can do so successfully. It can be used to make a best effort guess
    // of the remote default branch when offline. If it fails, the only viable
    // next best fallback before online again is to use NoRemoteDefaultBranch.
    CachedRemoteDefaultBranch() (string, error)

    // NoRemoteDefaultBranch returns the default value of default branch for this vcs.
    // It can only be relied on when there's no remote, since remote can have a custom
    // value of default branch.
    NoRemoteDefaultBranch() string
}

VCS describes how to use a version control system to get the status of a repository rooted at dir.

func NewVCS Uses

func NewVCS(vcs *vcs.Cmd) (VCS, error)

NewVCS creates a VCS with same type as vcs.

Package vcsstate imports 9 packages (graph) and is imported by 6 packages. Updated 2017-07-15. Refresh now. Tools for package owners.