From 358243ed0784f3f43599d2c74b74dc9c31ebecc6 Mon Sep 17 00:00:00 2001 From: Trevor Hartman Date: Thu, 11 Aug 2016 16:57:22 -0600 Subject: [PATCH] Add support for "drone build start foo/bar last" This starts the build on the default branch --- drone/build_start.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drone/build_start.go b/drone/build_start.go index 8aaf6399..bf9ff3cf 100644 --- a/drone/build_start.go +++ b/drone/build_start.go @@ -35,16 +35,28 @@ func buildStart(c *cli.Context) (err error) { if err != nil { return err } - number, err := strconv.Atoi(c.Args().Get(1)) - if err != nil { - return err - } client, err := newClient(c) if err != nil { return err } + buildArg := c.Args().Get(1) + var number int + if buildArg == "last" { + // Fetch the build number from the last build + build, err := client.BuildLast(owner, name, "") + if err != nil { + return err + } + number = build.Number + } else { + number, err = strconv.Atoi(buildArg) + if err != nil { + return err + } + } + params := parseKVPairs(c.StringSlice("param")) var build *model.Build