From 81b6a6d1c8fd2cb250cc74a6fd0e69ce7615c0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Eriksson?= Date: Thu, 29 May 2014 15:27:50 +0200 Subject: [PATCH] Add git path overrides --- pkg/build/git/git.go | 16 ++++++++++++---- pkg/queue/worker.go | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/build/git/git.go b/pkg/build/git/git.go index 36e67f13e..74e711cc0 100644 --- a/pkg/build/git/git.go +++ b/pkg/build/git/git.go @@ -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 +} diff --git a/pkg/queue/worker.go b/pkg/queue/worker.go index 71adb15bd..53d6101bb 100644 --- a/pkg/queue/worker.go +++ b/pkg/queue/worker.go @@ -184,7 +184,7 @@ func (w *worker) runBuild(task *BuildTask, buildscript *script.Build, buf io.Wri Branch: task.Commit.Branch, Commit: task.Commit.Hash, PR: task.Commit.PullRequest, - Dir: filepath.Join("/var/cache/drone/src", task.Repo.Slug), + Dir: filepath.Join("/var/cache/drone/src", git.GitPath(buildscript.Git, task.Repo.Slug)), Depth: git.GitDepth(buildscript.Git), }