Documentation
¶
Overview ¶
Package vcs provides helper functions for working with various repositories (e.g. git).
Index ¶
- Constants
- Variables
- func CanonicalizeCommit(title string) string
- func CheckBranch(branch string) bool
- func CheckCommitHash(hash string) bool
- func CheckRepoAddress(repo string) bool
- func CommitLink(url, hash string) string
- func FileLink(url, hash, file string, line int) string
- func LogLink(url, hash string) string
- func ParseReleaseTag(tag string) (v1, v2, rc, v3 int)
- func Patch(dir string, patch []byte) error
- func TreeLink(url, hash string) string
- type BackportCommit
- type BaseCommit
- type BisectEnv
- type BisectResult
- type Bisecter
- type Commit
- type CommitShort
- type ConfigMinimizer
- type FileContent
- type Git
- func (git Git) Apply(patch []byte) error
- func (git Git) BaseForDiff(diff []byte, tracer debugtracer.DebugTracer) ([]*BaseCommit, error)
- func (git Git) BranchesThatContain(commit string, since time.Time) ([]branchCommit, error)
- func (git Git) Commit(hash string) (*Commit, error)
- func (git Git) CommitExists(commit string) (bool, error)
- func (git Git) Diff(commitA, commitB string) ([]byte, error)
- func (git Git) Reset() error
- func (git Git) Run(args ...string) ([]byte, error)
- type ModifiedFile
- type RecipientInfo
- type RecipientType
- type Recipients
- type Repo
- type RepoOpt
- type TestRepo
- func (repo *TestRepo) CommitChange(description string) *Commit
- func (repo *TestRepo) CommitChangeset(description string, actions ...FileContent) *Commit
- func (repo *TestRepo) CommitFileChange(branch, change string)
- func (repo *TestRepo) Git(args ...string)
- func (repo *TestRepo) SetTag(tag string)
- func (repo *TestRepo) SupportsBisection() bool
Constants ¶
const HEAD = "HEAD"
const SyzkallerRepo = "https://github.com/google/syzkaller"
Variables ¶
var ErrBadKconfig = errors.New("failed to parse Kconfig")
Functions ¶
func CanonicalizeCommit ¶
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 ¶
CheckBranch does a best-effort approximate check of a git branch name.
func CheckCommitHash ¶
func CheckRepoAddress ¶
CheckRepoAddress does a best-effort approximate check of a git repo address.
func CommitLink ¶
func ParseReleaseTag ¶
Types ¶
type BackportCommit ¶
type BackportCommit struct {
// Backport is only applied if the commit is reachable from HEAD.
GuiltyHash string `json:"guilty_hash"`
// The hash of the commit to cherry-pick.
FixHash string `json:"fix_hash"`
// The title of the commit to cherry-pick.
// It's used to determine whether the fix is already in place.
FixTitle string `json:"fix_title"`
// The field is only intended to make config files less cryptic.
Comment string `json:"comment"`
}
BackportCommit describes a fix commit that must be cherry-picked to an older kernel revision in order to enable kernel build / boot.
type BaseCommit ¶
type BisectResult ¶
type BisectResult int
const ( BisectBad BisectResult = iota BisectGood BisectSkip )
type Bisecter ¶
type Bisecter interface {
// Can be used for last minute preparations like pulling release tags into the bisected repo, which
// is required to determin the compiler version to use on linux. Can be an empty function.
PrepareBisect() error
// 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, dt debugtracer.DebugTracer, pred func() (BisectResult, error)) ([]*Commit, error)
// PreviousReleaseTags returns list of preceding release tags that are reachable from the given commit.
// If the commit itself has a release tag, this tag is not included.
PreviousReleaseTags(commit, compilerType string) ([]string, error)
IsRelease(commit string) (bool, error)
EnvForCommit(defaultCompiler, compilerType, binDir, commit string,
kernelConfig []byte, backports []BackportCommit) (*BisectEnv, error)
}
Bisecter may be optionally implemented by Repo.
type CommitShort ¶
type ConfigMinimizer ¶
type ConfigMinimizer interface {
Minimize(target *targets.Target, original, baseline []byte, types []crash.Type,
dt debugtracer.DebugTracer, pred func(test []byte) (BisectResult, error)) ([]byte, error)
}
type FileContent ¶
func (*FileContent) Apply ¶
func (fc *FileContent) Apply(repo *TestRepo) error
type Git ¶
func (Git) Apply ¶
Apply invokes git apply for a series of git patches. It is different from Patch() in that it normally handles raw patch emails.
func (Git) BaseForDiff ¶
func (git Git) BaseForDiff(diff []byte, tracer debugtracer.DebugTracer) ([]*BaseCommit, error)
BaseForDiff returns a list of commits that could have been the base commit for the specified git patch. For the purposes of optimization, the function only considers the commits that are newer than one year. The returned list is minimized to only contain the commits that are represented in different subsets of branches.
func (Git) BranchesThatContain ¶
func (Git) CommitExists ¶
CommitExists relies on 'git cat-file -e'. If object exists its exit status is 0. If object doesn't exist its exit status is 1 (not documented). Otherwise, the exit status is 128 (not documented).
type ModifiedFile ¶
func ParseGitDiff ¶
func ParseGitDiff(patch []byte) []ModifiedFile
ParseGitDiff extracts the files modified in the git patch.
type RecipientInfo ¶
type RecipientInfo struct {
Address mail.Address
Type RecipientType
}
type RecipientType ¶
type RecipientType int
const ( To RecipientType = iota Cc )
func (RecipientType) String ¶
func (t RecipientType) String() string
type Recipients ¶
type Recipients []RecipientInfo
func NewRecipients ¶
func NewRecipients(emails []string, t RecipientType) Recipients
func ParseMaintainersLinux ¶
func ParseMaintainersLinux(text []byte) Recipients
func (Recipients) GetEmails ¶
func (r Recipients) GetEmails(filter RecipientType) []string
func (Recipients) Len ¶
func (r Recipients) Len() int
func (Recipients) Less ¶
func (r Recipients) Less(i, j int) bool
func (Recipients) Swap ¶
func (r Recipients) Swap(i, j int)
func (Recipients) ToDash ¶
func (r Recipients) ToDash() dashapi.Recipients
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)
// Commit returns info about the specified commit hash.
// The commit may be the special value HEAD for the current commit.
Commit(com string) (*Commit, error)
// GetCommitByTitle finds commit info by the title. If the commit is not found, nil is returned.
// Remote is not fetched and only commits reachable from the checked out HEAD are searched
// (e.g. do CheckoutBranch before).
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)
// ExtractFixTagsFromCommits extracts fixing tags for bugs from git log.
// Given email = "[email protected]", it searches for tags of the form "[email protected]"
// and returns commits with these tags.
ExtractFixTagsFromCommits(baseCommit, email string) ([]*Commit, error)
// ReleaseTag returns the latest release tag that is reachable from the given commit.
ReleaseTag(commit string) (string, error)
// Returns true if the current tree contains the specified commit.
// Remote is not fetched and only commits reachable from the checked out HEAD are searched
// (e.g. do CheckoutBranch before).
Contains(commit string) (bool, error)
// LatestCommits lists all latest commit hashes well as their commit dates.
// If afterCommit is specified, the output only includes the commits from which afterCommit is reachable.
// If afterDate is specified, the output only includes the newe commits.
LatestCommits(afterCommit string, afterDate time.Time) ([]CommitShort, error)
// Object returns the contents of a git repository object at the particular moment in history.
Object(name, commit string) ([]byte, error)
// MergeBases returns good common ancestors of the two commits.
MergeBases(firstCommit, secondCommit string) ([]*Commit, error)
// CommitExists check for the commit presence in local checkout.
CommitExists(commit string) (bool, error)
// PushCommit is used to store commit in remote repo.
PushCommit(repo, commit string) error
}
func NewLKMLRepo ¶
func NewSyzkallerRepo ¶
type RepoOpt ¶
type RepoOpt int
const ( // RepoPrecious is intended for command-line tools that work with a user-provided repo. // Such repo won't be re-created to recover from errors, but rather return errors. // If this option is not specified, the repo can be re-created from scratch to recover from any errors. OptPrecious RepoOpt = iota // Don't use sandboxing suitable for pkg/build. OptDontSandbox )
type TestRepo ¶
type TestRepo struct {
Dir string
Commits map[string]map[string]*Commit
// contains filtered or unexported fields
}
func (*TestRepo) CommitChange ¶
func (*TestRepo) CommitChangeset ¶
func (repo *TestRepo) CommitChangeset(description string, actions ...FileContent) *Commit