1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-12 08:23:48 +02:00
woodpecker/cli/restart.go

40 lines
812 B
Go
Raw Normal View History

2014-07-16 10:34:23 +03:00
package main
import (
"github.com/codegangsta/cli"
2014-08-10 02:51:08 +03:00
"github.com/drone/drone/client"
2014-07-16 10:34:23 +03:00
)
// NewRestartCommand returns the CLI command for "restart".
func NewRestartCommand() cli.Command {
return cli.Command{
Name: "restart",
2014-08-08 08:22:04 +03:00
Usage: "restarts a build on the server",
2014-07-16 10:34:23 +03:00
Flags: []cli.Flag{},
Action: func(c *cli.Context) {
handle(c, restartCommandFunc)
},
}
}
// restartCommandFunc executes the "restart" command.
2014-08-10 02:51:08 +03:00
func restartCommandFunc(c *cli.Context, client *client.Client) error {
var host, owner, repo, branch, sha string
var args = c.Args()
2014-07-16 10:34:23 +03:00
2014-08-14 22:36:04 +03:00
if len(args) != 0 {
2014-08-10 02:51:08 +03:00
host, owner, repo = parseRepo(args[0])
2014-08-14 22:36:04 +03:00
}
switch len(args) {
case 2:
branch = "master"
sha = args[1]
case 3, 4, 5:
2014-08-14 22:36:04 +03:00
branch = args[1]
sha = args[2]
2014-07-16 10:34:23 +03:00
}
2014-08-10 02:51:08 +03:00
return client.Commits.Rebuild(host, owner, repo, branch, sha)
2014-07-16 10:34:23 +03:00
}