1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-06 08:16:19 +02:00

Fixing build and formatting issues

This commit is contained in:
Don Olmstead 2015-08-18 18:28:35 -07:00 committed by Olmstead
parent 6b0f24cc11
commit b7635ec844
6 changed files with 24 additions and 26 deletions

View File

@ -5,9 +5,7 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"net/url"
"os" "os"
"path/filepath"
"strings" "strings"
log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus" log "github.com/drone/drone/Godeps/_workspace/src/github.com/Sirupsen/logrus"
@ -68,7 +66,7 @@ func main() {
return return
} }
createClone(ctx) createClone(ctx)
var execs []execFunc var execs []execFunc
if *clone { if *clone {
execs = append(execs, execClone) execs = append(execs, execClone)
@ -130,13 +128,15 @@ func createClone(c *Context) error {
// to the clone object for merge requests from bitbucket, gitlab, et al // to the clone object for merge requests from bitbucket, gitlab, et al
// if len(c.Commit.PullRequest) != 0 { // if len(c.Commit.PullRequest) != 0 {
// } // }
pathv, ok := c.Conf.Clone.Config["path"]
url_, err := url.Parse(c.Repo.Link) if ok {
if err != nil { path, ok := pathv.(string)
return err if ok {
c.Clone.Dir = path
return nil
}
} }
c.Clone.Dir, _ = c.Conf.Clone.Config["path"] return fmt.Errorf("Workspace path not found")
return nil
} }
func parseContext() (*Context, error) { func parseContext() (*Context, error) {

View File

@ -1,8 +1,6 @@
package main package main
import ( import (
"path/filepath"
"github.com/drone/drone/Godeps/_workspace/src/github.com/samalba/dockerclient" "github.com/drone/drone/Godeps/_workspace/src/github.com/samalba/dockerclient"
common "github.com/drone/drone/pkg/types" common "github.com/drone/drone/pkg/types"
"github.com/drone/drone/pkg/yaml" "github.com/drone/drone/pkg/yaml"

View File

@ -2,14 +2,14 @@ package builtin
import ( import (
"bytes" "bytes"
"crypto/tls"
"crypto/x509"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"time" "time"
"crypto/tls"
"crypto/x509"
"github.com/drone/drone/Godeps/_workspace/src/github.com/samalba/dockerclient" "github.com/drone/drone/Godeps/_workspace/src/github.com/samalba/dockerclient"
"github.com/drone/drone/pkg/docker" "github.com/drone/drone/pkg/docker"

View File

@ -116,7 +116,7 @@ func Test_Linter(t *testing.T) {
g.It("Should pass with cache path inside workspace", func() { g.It("Should pass with cache path inside workspace", func() {
c := &common.Config{ c := &common.Config{
Build: &common.Step{ Build: &common.Step{
Cache: []string{".git","/.git","/.git/../.git/../.git"}, Cache: []string{".git", "/.git", "/.git/../.git/../.git"},
}, },
} }
g.Assert(expectCacheInWorkspace(c) == nil).IsTrue() g.Assert(expectCacheInWorkspace(c) == nil).IsTrue()
@ -125,7 +125,7 @@ func Test_Linter(t *testing.T) {
g.It("Should fail with cache path outside workspace", func() { g.It("Should fail with cache path outside workspace", func() {
c := &common.Config{ c := &common.Config{
Build: &common.Step{ Build: &common.Step{
Cache: []string{".git","/.git","../../.git"}, Cache: []string{".git", "/.git", "../../.git"},
}, },
} }
g.Assert(expectCacheInWorkspace(c) != nil).IsTrue() g.Assert(expectCacheInWorkspace(c) != nil).IsTrue()
@ -134,7 +134,7 @@ func Test_Linter(t *testing.T) {
g.It("Should fail when caching workspace directory", func() { g.It("Should fail when caching workspace directory", func() {
c := &common.Config{ c := &common.Config{
Build: &common.Step{ Build: &common.Step{
Cache: []string{".git",".git/../"}, Cache: []string{".git", ".git/../"},
}, },
} }
g.Assert(expectCacheInWorkspace(c) != nil).IsTrue() g.Assert(expectCacheInWorkspace(c) != nil).IsTrue()
@ -143,7 +143,7 @@ func Test_Linter(t *testing.T) {
g.It("Should fail when : is in the cache path", func() { g.It("Should fail when : is in the cache path", func() {
c := &common.Config{ c := &common.Config{
Build: &common.Step{ Build: &common.Step{
Cache: []string{".git",".git:/../"}, Cache: []string{".git", ".git:/../"},
}, },
} }
g.Assert(expectCacheInWorkspace(c) != nil).IsTrue() g.Assert(expectCacheInWorkspace(c) != nil).IsTrue()

View File

@ -71,7 +71,7 @@ func RemovePrivileged(c *common.Config) {
// Repo executes all transformers that rely on repository // Repo executes all transformers that rely on repository
// information. // information.
func Repo(c *common.Config, r *common.Repo) { func Repo(c *common.Config, r *common.Repo) {
transformWorkspace(c, r) transformWorkspace(c, r)
transformCache(c, r) transformCache(c, r)
} }
@ -227,7 +227,7 @@ func transformWorkspace(c *common.Config, r *common.Repo) {
func transformCache(c *common.Config, r *common.Repo) { func transformCache(c *common.Config, r *common.Repo) {
cacheCount := len(c.Build.Cache) cacheCount := len(c.Build.Cache)
if cacheCount == 0 { if cacheCount == 0 {
return return
} }
@ -287,7 +287,7 @@ func imageNameDefault(name, defaultName string) string {
// workspaceRoot is a helper function that determines the // workspaceRoot is a helper function that determines the
// default workspace the build runs in. // default workspace the build runs in.
func workspaceRoot(r *common.Repo) string { func workspaceRoot(r *common.Repo) string {
return filepath.Join(buildRoot, repoPath(r)) return filepath.Join(buildRoot, repoPath(r))
} }
// cacheRoot is a helper function that deteremines the // cacheRoot is a helper function that deteremines the

View File

@ -151,20 +151,20 @@ func Test_Transform(t *testing.T) {
Config: map[string]interface{}{}, Config: map[string]interface{}{},
}, },
Build: &common.Step{ Build: &common.Step{
Cache: []string{".git","foo","bar"}, Cache: []string{".git", "foo", "bar"},
}, },
Notify: map[string]*common.Step{}, Notify: map[string]*common.Step{},
Deploy: map[string]*common.Step{}, Deploy: map[string]*common.Step{},
Publish: map[string]*common.Step{}, Publish: map[string]*common.Step{},
} }
r := &common.Repo{ r := &common.Repo{
Link: "https://github.com/drone/drone", Link: "https://github.com/drone/drone",
FullName: "drone/drone", FullName: "drone/drone",
} }
transformWorkspace(c, r) transformWorkspace(c, r)
transformCache(c, r) transformCache(c, r)
cacheCount := len(c.Build.Cache) cacheCount := len(c.Build.Cache)
test := func(s *common.Step) { test := func(s *common.Step) {
g.Assert(len(s.Volumes)).Equal(cacheCount) g.Assert(len(s.Volumes)).Equal(cacheCount)
@ -176,7 +176,7 @@ func Test_Transform(t *testing.T) {
} }
} }
test(c.Setup) test(c.Setup)
test(c.Clone) test(c.Clone)
test(c.Build) test(c.Build)
testRange(c.Publish) testRange(c.Publish)
@ -192,7 +192,7 @@ func Test_Transform(t *testing.T) {
}, },
} }
r := &common.Repo{ r := &common.Repo{
Link: "https://github.com/drone/drone", Link: "https://github.com/drone/drone",
FullName: "drone/drone", FullName: "drone/drone",
} }
transformWorkspace(c, r) transformWorkspace(c, r)
@ -209,7 +209,7 @@ func Test_Transform(t *testing.T) {
}, },
} }
r := &common.Repo{ r := &common.Repo{
Link: "https://github.com/drone/drone", Link: "https://github.com/drone/drone",
FullName: "drone/drone", FullName: "drone/drone",
} }
transformWorkspace(c, r) transformWorkspace(c, r)