vcs

package
v0.0.0-...-17b87e8 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package vcs provides helper functions for working with various repositories (e.g. git).

Index

Constants

View Source
const SyzkallerRepo = "https://github.com/google/syzkaller"

Variables

This section is empty.

Functions

func CanonicalizeCommit

func CanonicalizeCommit(title string) string

CanonicalizeCommit returns commit title that can be used when checking if a particular commit is present in a git tree. Some trees add prefixes to commit titles during backporting, so we want e.g. commit "foo bar" match "BACKPORT: foo bar".

func CheckBranch

func CheckBranch(branch string) bool

CheckBranch does a best-effort approximate check of a git branch name.

func CheckCommitHash

func CheckCommitHash(hash string) bool

func CheckRepoAddress

func CheckRepoAddress(repo string) bool

CheckRepoAddress does a best-effort approximate check of a git repo address.

func CommitLink(url, hash string) string
func LogLink(url, hash string) string

func Patch

func Patch(dir string, patch []byte) error
func TreeLink(url, hash string) string

Types

type BisectEnv

type BisectEnv struct {
	Compiler     string
	KernelConfig []byte
}

type BisectResult

type BisectResult int
const (
	BisectBad BisectResult = iota
	BisectGood
	BisectSkip
)

type Bisecter

type Bisecter interface {
	// Bisect bisects good..bad commit range against the provided predicate (wrapper around git bisect).
	// The predicate should return an error only if there is no way to proceed
	// (it will abort the process), if possible it should prefer to return BisectSkip.
	// Progress of the process is streamed to the provided trace.
	// Returns the first commit on which the predicate returns BisectBad,
	// or multiple commits if bisection is inconclusive due to BisectSkip.
	Bisect(bad, good string, trace io.Writer, pred func() (BisectResult, error)) ([]*Commit, error)

	// PreviousReleaseTags returns list of preceding release tags that are reachable from the given commit.
	PreviousReleaseTags(commit string) ([]string, error)

	IsRelease(commit string) (bool, error)

	EnvForCommit(binDir, commit string, kernelConfig []byte) (*BisectEnv, error)
}

Bisecter may be optionally implemented by Repo.

type Commit

type Commit struct {
	Hash       string
	Title      string
	Author     string
	AuthorName string
	CC         []string
	Tags       []string
	Parents    []string
	Date       time.Time
}

type Repo

type Repo interface {
	// Poll checkouts the specified repository/branch.
	// This involves fetching/resetting/cloning as necessary to recover from all possible problems.
	// Returns hash of the HEAD commit in the specified branch.
	Poll(repo, branch string) (*Commit, error)

	// CheckoutBranch checkouts the specified repository/branch.
	CheckoutBranch(repo, branch string) (*Commit, error)

	// CheckoutCommit checkouts the specified repository on the specified commit.
	CheckoutCommit(repo, commit string) (*Commit, error)

	// SwitchCommit checkouts the specified commit without fetching.
	SwitchCommit(commit string) (*Commit, error)

	// HeadCommit returns info about the HEAD commit of the current branch of git repository.
	HeadCommit() (*Commit, error)

	// GetCommitByTitle finds commit info by the title.
	// Remote is not fetched, the commit needs to be reachable from the current repo state
	// (e.g. do CheckoutBranch before). If the commit is not found, nil is returned.
	GetCommitByTitle(title string) (*Commit, error)

	// GetCommitsByTitles is a batch version of GetCommitByTitle.
	// Returns list of commits and titles of commits that are not found.
	GetCommitsByTitles(titles []string) ([]*Commit, []string, error)

	// ListRecentCommits returns list of recent commit titles starting from baseCommit.
	ListRecentCommits(baseCommit string) ([]string, error)

	// ExtractFixTagsFromCommits extracts fixing tags for bugs from git log.
	// Given email = "user@domain.com", it searches for tags of the form "user+tag@domain.com"
	// and returns commits with these tags.
	ExtractFixTagsFromCommits(baseCommit, email string) ([]*Commit, error)
}

func NewRepo

func NewRepo(os, vm, dir string) (Repo, error)

func NewSyzkallerRepo

func NewSyzkallerRepo(dir string) Repo

type TestRepo

type TestRepo struct {
	Dir string

	Commits map[string]map[string]*Commit
	// contains filtered or unexported fields
}

func CloneTestRepo

func CloneTestRepo(t *testing.T, baseDir string, name string, originRepo *TestRepo) *TestRepo

func CreateTestRepo

func CreateTestRepo(t *testing.T, baseDir, name string) *TestRepo

func MakeTestRepo

func MakeTestRepo(t *testing.T, dir string) *TestRepo

func (*TestRepo) CommitChange

func (repo *TestRepo) CommitChange(description string) *Commit

func (*TestRepo) CommitFileChange

func (repo *TestRepo) CommitFileChange(branch, change string)

func (*TestRepo) Git

func (repo *TestRepo) Git(args ...string)

func (*TestRepo) SetTag

func (repo *TestRepo) SetTag(tag string)

func (*TestRepo) SupportsBisection

func (repo *TestRepo) SupportsBisection() bool

Jump to

Keyboard shortcuts

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