From 22dd16df81be895f9767516bfd93645e8e13cc77 Mon Sep 17 00:00:00 2001 From: Jorin Vogel Date: Thu, 19 Jan 2017 09:05:20 +0100 Subject: [PATCH] Fix parsing of repo options. Before this it break when leaving, for example, the `brew` section empty. --- pipeline/repos/repos.go | 3 +++ pipeline/repos/repos_test.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/pipeline/repos/repos.go b/pipeline/repos/repos.go index 20740a5f6..b709b45ea 100644 --- a/pipeline/repos/repos.go +++ b/pipeline/repos/repos.go @@ -31,5 +31,8 @@ func (Pipe) Run(ctx *context.Context) (err error) { func split(pair string) (string, string) { parts := strings.Split(pair, "/") + if len(parts) == 1 { + return parts[0], "" + } return parts[0], parts[1] } diff --git a/pipeline/repos/repos_test.go b/pipeline/repos/repos_test.go index 6c21c4706..e6e69b2ae 100644 --- a/pipeline/repos/repos_test.go +++ b/pipeline/repos/repos_test.go @@ -11,4 +11,20 @@ func TestSplit(t *testing.T) { a, b := split("a/b") assert.Equal("a", a) assert.Equal("b", b) + + a, b = split("") + assert.Equal("", a) + assert.Equal("", b) + + a, b = split("a") + assert.Equal("a", a) + assert.Equal("", b) + + a, b = split("a/") + assert.Equal("a", a) + assert.Equal("", b) + + a, b = split("/b") + assert.Equal("", a) + assert.Equal("b", b) }