1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-01-17 17:45:03 +02:00
woodpecker/cli/restart.go

40 lines
810 B
Go
Raw Normal View History

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