1
0
mirror of https://github.com/drone/drone-cli.git synced 2026-02-01 23:53:35 +01:00

Merge pull request #198 from drone/feature/dron-34-auto-cancel-running

provides ability to update auto-cancel-running flag on repo
This commit is contained in:
TP Honey 2021-08-27 15:12:57 +01:00 committed by GitHub
commit b8b8a24077
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 13 deletions

@ -56,4 +56,7 @@ Private: {{ .Private }}
Trusted: {{ .Trusted }}
Protected: {{ .Protected }}
Remote: {{ .HTTPURL }}
CancelRunning: {{ .CancelRunning }}
CancelPulls: {{ .CancelPulls }}
CancelPush: {{ .CancelPush }}
`

@ -52,6 +52,10 @@ var repoUpdateCmd = cli.Command{
Name: "auto-cancel-pushes",
Usage: "automatically cancel pending push builds",
},
cli.BoolFlag{
Name: "auto-cancel-running",
Usage: "automatically cancel running builds if newer commit pushed",
},
cli.StringFlag{
Name: "config",
Usage: "repository configuration path (e.g. .drone.yml)",
@ -80,18 +84,19 @@ func repoUpdate(c *cli.Context) error {
}
var (
visibility = c.String("visibility")
config = c.String("config")
timeout = c.Duration("timeout")
trusted = c.Bool("trusted")
throttle = c.Int64("throttle")
protected = c.Bool("protected")
ignoreForks = c.Bool("ignore-forks")
ignorePulls = c.Bool("ignore-pull-requests")
cancelPulls = c.Bool("auto-cancel-pull-requests")
cancelPush = c.Bool("auto-cancel-pushes")
buildCounter = c.Int64("build-counter")
unsafe = c.Bool("unsafe")
visibility = c.String("visibility")
config = c.String("config")
timeout = c.Duration("timeout")
trusted = c.Bool("trusted")
throttle = c.Int64("throttle")
protected = c.Bool("protected")
ignoreForks = c.Bool("ignore-forks")
ignorePulls = c.Bool("ignore-pull-requests")
cancelPulls = c.Bool("auto-cancel-pull-requests")
cancelPush = c.Bool("auto-cancel-pushes")
cancelRunning = c.Bool("auto-cancel-running")
buildCounter = c.Int64("build-counter")
unsafe = c.Bool("unsafe")
)
patch := new(drone.RepoPatch)
@ -123,6 +128,9 @@ func repoUpdate(c *cli.Context) error {
if c.IsSet("auto-cancel-pushes") {
patch.CancelPush = &cancelPush
}
if c.IsSet("auto-cancel-running") {
patch.CancelRunning = &cancelRunning
}
if c.IsSet("visibility") {
switch visibility {
case "public", "private", "internal":

2
go.mod

@ -6,7 +6,7 @@ replace github.com/docker/docker => github.com/docker/engine v17.12.0-ce-rc1.0.2
require (
github.com/docker/go-units v0.3.3
github.com/drone/drone-go v1.6.1
github.com/drone/drone-go v1.6.2
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d
github.com/drone/drone-yaml v0.0.0-20190729072335-70fa398b3560
github.com/drone/envsubst v1.0.3

2
go.sum

@ -35,6 +35,8 @@ github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/drone/drone-go v1.6.1 h1:6GRwCxu6K3vUWVUfRvqGhROzjkRE7OsV5UwxGW9sVfk=
github.com/drone/drone-go v1.6.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-go v1.6.2 h1:QT7o6Bfe5UCUea4ZU74JfzgkwFYbBNduuSQZTr1fQJE=
github.com/drone/drone-go v1.6.2/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-runtime v1.0.7-0.20190729070836-38f28a11afe8/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d h1:P5HI/Y9hARTZ3F3EKs0kYijhjXZWQRQHYn1neTi0pWM=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8=