mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-27 02:40:30 +00:00
added code to specify a gopath
This commit is contained in:
parent
aec9b33048
commit
43e382b5a1
3 changed files with 18 additions and 5 deletions
|
@ -1,4 +1,6 @@
|
|||
image: go1.2
|
||||
git:
|
||||
path: github.com/drone/drone
|
||||
env:
|
||||
- GOROOT=/usr/local/go
|
||||
script:
|
||||
|
|
|
@ -170,6 +170,9 @@ func (w *worker) execute(task *BuildTask) error {
|
|||
}
|
||||
|
||||
func (w *worker) runBuild(task *BuildTask, buf io.Writer) (bool, error) {
|
||||
var path = filepath.Join(task.Repo.Host, task.Repo.Owner, task.Repo.Name)
|
||||
path = git.GitPath(task.Script.Git, path)
|
||||
|
||||
repo := &r.Repo{
|
||||
Name: task.Repo.Host + task.Repo.Owner + task.Repo.Name,
|
||||
Path: task.Repo.CloneURL,
|
||||
|
@ -177,7 +180,7 @@ func (w *worker) runBuild(task *BuildTask, buf io.Writer) (bool, error) {
|
|||
Commit: task.Commit.Sha,
|
||||
PR: task.Commit.PullRequest,
|
||||
//TODO the builder should handle this
|
||||
Dir: filepath.Join("/var/cache/drone/src", task.Repo.Host, task.Repo.Owner, task.Repo.Name),
|
||||
Dir: filepath.Join("/var/cache/drone/src", path),
|
||||
Depth: git.GitDepth(task.Script.Git),
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,7 @@ type Git struct {
|
|||
Depth *int `yaml:"depth,omitempty"`
|
||||
|
||||
// The name of a directory to clone into.
|
||||
// TODO this still needs to be implemented. this field is
|
||||
// critical for forked Go projects, that need to clone
|
||||
// to a specific repository.
|
||||
Path string `yaml:"path,omitempty"`
|
||||
Path *string `yaml:"path,omitempty"`
|
||||
}
|
||||
|
||||
// GitDepth returns GitDefaultDepth
|
||||
|
@ -29,3 +26,14 @@ func GitDepth(g *Git) int {
|
|||
}
|
||||
return *g.Depth
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue