git

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 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 "./"`)
	ErrFileNotValid = errors.New(`invalid file path, it can't be "",".", "..", start or end by "/" or contain "./"`)
)
View Source
var ErrNoReleases = errors.New("no releases found")
View Source
var ErrNonexistentCommitHash = fmt.Errorf("nonexistent commit hash")
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 or includedFiles is not empty, commits changing only files not contained in any of the includedDirs or includedFiles will be filtered out. Moreover, commits modifying only files present in excludedDirs or excludedFiles will be filtered out. Notice that if a file is excluded by a rule it is filtered out, even if another rule include it.

type CommitFilterOptionFunc

type CommitFilterOptionFunc func(s *CommitFilter) error

func ExcludedDependencies

func ExcludedDependencies(deps ...string) CommitFilterOptionFunc

func ExcludedDirs

func ExcludedDirs(excludedDirs ...string) CommitFilterOptionFunc

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

func ExcludedFiles

func ExcludedFiles(excludedFiles ...string) CommitFilterOptionFunc

ExcludedFiles returns an option that will filter commits with all changes in excludedFiles.

func IncludedDirs

func IncludedDirs(includedDirs ...string) CommitFilterOptionFunc

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

func IncludedFiles

func IncludedFiles(includedFiles ...string) CommitFilterOptionFunc

IncludedFiles returns an option that will filter commits with all changes not in includedFiles.

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 TagsMatchingCommits

func TagsMatchingCommits(getter CommitsGetter) TagOptionFunc

TagsMatchingCommits returns an option that will skip tags that do not point to a commit reachable from HEAD.

func TagsMatchingRegex

func TagsMatchingRegex(regex string) TagOptionFunc

TagsMatchingRegex 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