1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-03-03 15:22:25 +02:00
woodpecker/cmd/restart.go

37 lines
800 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-09 16:51:08 -07:00
if len(args) == 5 {
host, owner, repo = parseRepo(args[0])
} else {
host = "unknown"
owner = "unknown"
repo = "unknown"
branch = "unknown"
sha = "unknown"
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
}