github.com/unclejack/drone@v0.2.1-0.20140918182345-831b034aa33b/pkg/build/git/git.go (about) 1 package git 2 3 const ( 4 DefaultGitDepth = 50 5 ) 6 7 // Git stores the configuration details for 8 // executing Git commands. 9 type Git struct { 10 // Depth options instructs git to create a shallow 11 // clone with a history truncated to the specified 12 // number of revisions. 13 Depth *int `yaml:"depth,omitempty"` 14 15 // The name of a directory to clone into. 16 Path *string `yaml:"path,omitempty"` 17 } 18 19 // GitDepth returns GitDefaultDepth 20 // when Git.Depth is empty. 21 // GitDepth returns Git.Depth 22 // when it is not empty. 23 func GitDepth(g *Git) int { 24 if g == nil || g.Depth == nil { 25 return DefaultGitDepth 26 } 27 return *g.Depth 28 } 29 30 // GitPath returns the given default path 31 // when Git.Path is empty. 32 // GitPath returns Git.Path 33 // when it is not empty. 34 func GitPath(g *Git, defaultPath string) string { 35 if g == nil || g.Path == nil { 36 return defaultPath 37 } 38 return *g.Path 39 }