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 ParseGitDiff(patch []byte) []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 BisectEnv
- type BisectResult
- type Bisecter
- type Commit
- type ConfigMinimizer
- type RecipientInfo
- type RecipientType
- type Recipients
- type Repo
- type RepoOpt
- type TestRepo
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 ParseGitDiff ¶
ParseGitDiff extracts the files modified in the git patch.
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 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 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 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 = "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) // 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) // ListCommitHashes lists all commit hashes reachable from baseCommit. ListCommitHashes(baseCommit string) ([]string, 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 }