2014-02-12 17:58:07 +00:00
|
|
|
package git
|
|
|
|
|
|
|
|
const (
|
|
|
|
DefaultGitDepth = 50
|
|
|
|
)
|
|
|
|
|
|
|
|
// Git stores the configuration details for
|
|
|
|
// executing Git commands.
|
|
|
|
type Git struct {
|
2014-02-18 05:41:56 +00:00
|
|
|
// Depth options instructs git to create a shallow
|
|
|
|
// clone with a history truncated to the specified
|
|
|
|
// number of revisions.
|
2014-02-12 17:58:07 +00:00
|
|
|
Depth *int `yaml:"depth,omitempty"`
|
2014-02-18 05:41:56 +00:00
|
|
|
|
|
|
|
// The name of a directory to clone into.
|
2014-05-29 13:27:50 +00:00
|
|
|
Path *string `yaml:"path,omitempty"`
|
2014-02-12 17:58:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GitDepth returns GitDefaultDepth
|
|
|
|
// when Git.Depth is empty.
|
|
|
|
// GitDepth returns Git.Depth
|
|
|
|
// when it is not empty.
|
|
|
|
func GitDepth(g *Git) int {
|
|
|
|
if g == nil || g.Depth == nil {
|
|
|
|
return DefaultGitDepth
|
|
|
|
}
|
|
|
|
return *g.Depth
|
|
|
|
}
|
2014-05-29 13:27:50 +00:00
|
|
|
|
|
|
|
// GitPath returns the given default path
|
|
|
|
// when Git.Path is empty.
|
|
|
|
// GitPath returns Git.Path
|
|
|
|
// when it is not empty.
|
|
|
|
func GitPath(g *Git, defaultPath string) string {
|
|
|
|
if g == nil || g.Path == nil {
|
|
|
|
return defaultPath
|
|
|
|
}
|
|
|
|
return *g.Path
|
|
|
|
}
|