vcs

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRepoNotFound = errors.New("no repository found")
)

Functions

func FindRepo

func FindRepo(path string) (bool, string, string, error)

FindRepo searches for a repository that the given path is located in and returns the paths that hold a .git directory.

Types

type BuildRequest

type BuildRequest struct {
	// contains filtered or unexported fields
}

func (*BuildRequest) String

func (br *BuildRequest) String() string

type Lookup

type Lookup struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLookup

func NewLookup(scope string, fn LookupBuildFn) (*Lookup, error)

func (*Lookup) Close

func (l *Lookup) Close() error

func (*Lookup) GetDirtyOkay

func (l *Lookup) GetDirtyOkay(ref *plumbing.Reference) chan interface{}

GetDirtyOkay returns the lookup table even when it doesn't match the given ref. However the lookup table must have been build at least once.

If this isn't the case a build will be triggered and the caller can wait until it succeeds. When nil is requested will queue the request and answer it once any ref of the lookup has been built.

func (*Lookup) IsStale

func (l *Lookup) IsStale(head *plumbing.Reference) bool

func (*Lookup) Open

func (l *Lookup) Open() error

Open starts a goroutine to hande build requests.

func (*Lookup) RequestBuild

func (l *Lookup) RequestBuild(ref *plumbing.Reference)

func (*Lookup) String

func (l *Lookup) String() string

type LookupBuildFn

type LookupBuildFn func() (*plumbing.Reference, interface{}, error)

type Repo

type Repo struct {
	sync.RWMutex

	// Root of the repository's worktree.
	Path string
	// contains filtered or unexported fields
}

func NewRepo

func NewRepo(mainpath string, subpath string, gr *git.Repository, b *bus.Broker) (*Repo, error)

NewRepo initializes a new Repo. A mainpath must always be given, an optional subpath may be given when submodules are in use. Optionally an existing Repository may be provided, if none is provided one will be created on the fly.

func (*Repo) Close

func (r *Repo) Close() error

func (*Repo) HasHeadChanged

func (r *Repo) HasHeadChanged() bool

func (*Repo) HasUpstreamChanged

func (r *Repo) HasUpstreamChanged() (bool, error)

func (*Repo) IsStale

func (r *Repo) IsStale() bool

func (*Repo) ModifiedWithContext

func (r *Repo) ModifiedWithContext(ctx context.Context, path string) (time.Time, error)

Modified considers any changes in and below given path as a change to the path. The path must be absolute and rooted at the repository path.

func (*Repo) Open

func (r *Repo) Open() error

func (*Repo) String

func (r *Repo) String() string

func (*Repo) UpdateFromUpstream

func (r *Repo) UpdateFromUpstream() error

UpdateFromUpstream updates the currently checked out reference from upstream.

TODO: This currently fails with "object not found" or "already up-to-date", or "not-fast-forward", when this shouldn't be the case. We probably have to switch to fetch+hard reset.

func (*Repo) Version

func (r *Repo) Version() (*Version, error)

Version returns the current checked out version.

func (*Repo) Versions

func (r *Repo) Versions() (*Versions, error)

Versions are sorted tags (we remove a leading "v") and branches (which are prefixed by "dev-", as to avoid collisions with tag names).

type Version

type Version struct {
	Name string
	Ref  *plumbing.Reference
	// contains filtered or unexported fields
}

func AsLiveVersion

func AsLiveVersion(v *Version) *Version

AsLiveVersion converts a version into a "live" one.

func NewVersionFromRef

func NewVersionFromRef(ref *plumbing.Reference) *Version

func (*Version) String

func (v *Version) String() string

type Versions

type Versions struct {
	// contains filtered or unexported fields
}

func (*Versions) Add

func (vs *Versions) Add(v *Version)

func (*Versions) Filter

func (vs *Versions) Filter(fn func(*Version) bool) *Versions

func (*Versions) ForEach

func (vs *Versions) ForEach(fn func(*Version) error) error

func (*Versions) Len

func (vs *Versions) Len() int

func (*Versions) Less

func (vs *Versions) Less(i, j int) bool

Less will help sort on a best effort basis.

First names of tags and names of branches are separately clustered. Tags come before branches. But the special "live" version comes always first.

Inside the tag cluster tags following semver are sorted according to its rules. If they do not follow the spec they are sorted lexicographically.

Inside the branch cluster names are always sorted lexicographically.

func (*Versions) Names

func (vs *Versions) Names() []string

func (*Versions) Swap

func (vs *Versions) Swap(i, j int)

Jump to

Keyboard shortcuts

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