Documentation ¶
Overview ¶
Copyright 2016 The gta AUTHORS. All rights reserved.
Use of this source code is governed by the Apache 2 license that can be found in the LICENSE file.
Package gta provides a set of utilites to build a set of dirty packages and their dependents that can be used to target code changes.
Copyright 2016 The gta AUTHORS. All rights reserved.
Use of this source code is governed by the Apache 2 license that can be found in the LICENSE file.
Copyright 2016 The gta AUTHORS. All rights reserved.
Use of this source code is governed by the Apache 2 license that can be found in the LICENSE file.
Copyright 2016 The gta AUTHORS. All rights reserved.
Use of this source code is governed by the Apache 2 license that can be found in the LICENSE file.
Copyright 2016 The gta AUTHORS. All rights reserved.
Use of this source code is governed by the Apache 2 license that can be found in the LICENSE file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoDiffer is returned when there is no differ set on the GTA. ErrNoDiffer = errors.New("there is no differ set") // ErrNoPackager is returned when there is no packager set on the GTA. ErrNoPackager = errors.New("there is no packager set") )
Functions ¶
This section is empty.
Types ¶
type Differ ¶
type Differ interface { // Diff returns a set of absolute pathed directories that have files that // have been modified. Diff() (map[string]Directory, error) // DiffFiles returns a map whose keys are absolute files paths. A map value // is true when the file exists. DiffFiles() (map[string]bool, error) }
A Differ implements provides methods that return values to understand the directories and files that have changed. and the dirs they in which occur.
func NewFileDiffer ¶
NewFileDiffer returns a Differ that operates on a list of absolute paths of changed files.
func NewGitDiffer ¶
func NewGitDiffer(opts ...GitDifferOption) Differ
NewGitDiffer returns a Differ that determines differences using git.
type GTA ¶
type GTA struct {
// contains filtered or unexported fields
}
A GTA provides a method of building dirty packages, and their dependent packages.
func New ¶
New returns a new GTA with various options passed to New. Options will be applied in order so that later options can override earlier options.
func (*GTA) ChangedPackages ¶
ChangedPackages uses the differ and packager to build a map of changed root packages to their dependent packages where dependent is defined as "changed" as well due to their dependency to the changed packages. It returns the dependency graph, the changes differ detected and a set of all unique packages (including the changes).
As an example: package "foo" is imported by packages "bar" and "qux". If "foo" has changed, it has two dependent packages, "bar" and "qux". The result would be then:
Dependencies = {"foo": ["bar", "qux"]} Changes = ["foo"] AllChanges = ["foo", "bar", "qux]
Note that two different changed package might have the same dependent package. Below you see that both "foo" and "foo2" has changed. Each have "bar" because "bar" imports both "foo" and "foo2", i.e:
Dependencies = {"foo": ["bar", "qux"], "foo2" : ["afa", "bar", "qux"]} Changes = ["foo", "foo2"] AllChanges = ["foo", "foo2", "afa", "bar", "qux]
type GitDifferOption ¶
type GitDifferOption func(*git)
GitDifferOption is an option function used to modify a git differ
func SetBaseBranch ¶
func SetBaseBranch(baseBranch string) GitDifferOption
SetBaseBranch sets the baseBranch field on a git differ
func SetUseMergeCommit ¶
func SetUseMergeCommit(useMergeCommit bool) GitDifferOption
SetUseMergeCommit sets the useMergeCommit field on a git differ
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is an adjacency list representation of a graph using maps.
type Option ¶
Option is an option function used to modify a GTA.
func SetPrefixes ¶
SetPrefixes sets a list of prefix to be included
type Package ¶
type Package struct { ImportPath string // Dir the absolute path of the directory containing the package. // bug(bc): this is currently unreliable and in GOPATH mode only identifies // the src directory for the GOPATH that hosts the package. Currently, the // only guarantee is that Dir will not be empty when the package exists. Dir string }
type Packager ¶
type Packager interface { // Get a go package from directory. Should return a *build.NoGoError value // when there are no Go files in the directory. PackageFromDir(string) (*Package, error) // Get a go package from an empty directory. PackageFromEmptyDir(string) (*Package, error) // Get a go package from import path. Should return a *build.NoGoError value // when there are no Go files in the directory. PackageFromImport(string) (*Package, error) // DependentGraph returns the DependentGraph for the current // Golang workspace as defined by their import paths. DependentGraph() (*Graph, error) // EmbeddedBy returns the package import paths of packages that embed a file. EmbeddedBy(string) []string }
Packager interface defines a set of means to access golang build Package information.
func NewPackager ¶
type Packages ¶
type Packages struct { // Dependencies contains a map of changed packages to their dependencies Dependencies map[string][]Package // Changes represents the changed files Changes []Package // AllChanges represents all packages that are dirty including the initial // changed packages. AllChanges []Package }
Packages contains various detailed information about the structure of packages GTA has detected.
func (*Packages) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*Packages) UnmarshalJSON ¶
UnmarshalJSON used by gtartifacts when providing a changed package list see `useChangedPackagesFrom()`
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
gta
Command gta uses git to find the subset of code changes from a branch and then builds the list of go packages that have changed as a result, including all dependent go packages.
|
Command gta uses git to find the subset of code changes from a branch and then builds the list of go packages that have changed as a result, including all dependent go packages. |