git

package
v0.0.0-...-3a64406 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyTreeID = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"

EmptyTreeID is the universal git empty tree sha1.

Variables

View Source
var ErrDirNotValid = errors.New(`invalid dir path, it can't be ".", "..", start by "/" or contain "./"`)
View Source
var MatchAllTags = regexp.MustCompile("")

Functions

This section is empty.

Types

type Commit

type Commit struct {
	Message string
	Hash    string
	Author  string
	Files   []string
}

type CommitFilter

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

CommitFilter filters commits from a git repository based in included and excluded directories.

func NewCommitFilter

func NewCommitFilter(commitsGetter CommitsGetter, opts ...CommitFilterOptionFunc) (*CommitFilter, error)

func (*CommitFilter) Commits

func (s *CommitFilter) Commits(lastHash string) ([]Commit, error)

Commits calls commitGetter to get a list of commits until lastHash. If includedDirs is not empty, only commits changing at least one file contained in any of the includedDirs will be returned. If excludedDirs is not empty, commits that only change files present in excludedDirs will be filtered out.

type CommitFilterOptionFunc

type CommitFilterOptionFunc func(s *CommitFilter) error

func ExcludedDirs

func ExcludedDirs(excludedDirs ...string) CommitFilterOptionFunc

ExcludedDirs returns an option that will filter commits with all changes in excludedDirs.

func IncludedDirs

func IncludedDirs(includedDirs ...string) CommitFilterOptionFunc

IncludedDirs returns an option that will filter commits with all changes not in includedDirs.

type CommitsGetter

type CommitsGetter interface {
	Commits(lastHash string) ([]Commit, error)
}

type RepoCommitsGetter

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

RepoCommitsGetter gets commits from a git repository.

func NewRepoCommitsGetter

func NewRepoCommitsGetter(workDir string) *RepoCommitsGetter

func (*RepoCommitsGetter) Commits

func (s *RepoCommitsGetter) Commits(lastHash string) ([]Commit, error)

Commits returns all the commits from Head ordered from top to bottom until LastHash, if lastHash is empty, all commits are returned.

type RepoTagsGetter

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

func NewRepoTagsGetter

func NewRepoTagsGetter(workDir string, opts ...TagOptionFunc) (*RepoTagsGetter, error)

func (*RepoTagsGetter) Tags

func (s *RepoTagsGetter) Tags() ([]Tag, error)

type Tag

type Tag struct {
	Name string
	Hash string
}

type TagOptionFunc

type TagOptionFunc func(s *RepoTagsGetter) error

func TagsMatching

func TagsMatching(regex string) TagOptionFunc

TagsMatching returns an option that will make the getter to ignore tags that do not match regex.

type TagSourceOptionFunc

type TagSourceOptionFunc func(s *TagsSource)

func TagSourceReplacing

func TagSourceReplacing(existing, replacement string) TagSourceOptionFunc

TagSourceReplacing returns an option that will perform a string replacement on tags that match the regex before attempting to parse them as versions. It is useful to, for example, strip prefixes from tags matched with TagMatching.

type TagsGetter

type TagsGetter interface {
	Tags() ([]Tag, error)
}

type TagsSource

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

TagsSource implements the `version.Source` interface, using tags from a git repository as a source for previous versions. It also implements TagsVersionGetter to be used by extractor services.

func NewTagsSource

func NewTagsSource(tagsGetter TagsGetter, opts ...TagSourceOptionFunc) *TagsSource

func (*TagsSource) LastVersionHash

func (s *TagsSource) LastVersionHash() (string, error)

func (*TagsSource) Versions

func (s *TagsSource) Versions() ([]*semver.Version, error)

type TagsVersionGetter

type TagsVersionGetter interface {
	Versions() ([]*semver.Version, error)
	LastVersionHash() (string, error)
}

Jump to

Keyboard shortcuts

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