From 55ae12d8c45ba84ddc30493090f5fb4e48aed7ec Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Fri, 27 Aug 2021 10:06:54 +0100 Subject: [PATCH 1/2] provide update and get info values for repo --- drone/repo/repo_info.go | 3 +++ drone/repo/repo_update.go | 32 ++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/drone/repo/repo_info.go b/drone/repo/repo_info.go index b78eded..db1a42c 100644 --- a/drone/repo/repo_info.go +++ b/drone/repo/repo_info.go @@ -56,4 +56,7 @@ Private: {{ .Private }} Trusted: {{ .Trusted }} Protected: {{ .Protected }} Remote: {{ .HTTPURL }} +CancelRunning: {{ .CancelRunning }} +CancelPulls: {{ .CancelPulls }} +CancelPush: {{ .CancelPush }} ` diff --git a/drone/repo/repo_update.go b/drone/repo/repo_update.go index 5374f09..4ff1fd3 100644 --- a/drone/repo/repo_update.go +++ b/drone/repo/repo_update.go @@ -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": From a2ab5c50a028734ee4052e0fd075213bbcb68c48 Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Fri, 27 Aug 2021 10:54:31 +0100 Subject: [PATCH 2/2] bump drone-go --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2056111..2a49864 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index d376ec6..611cfc6 100644 --- a/go.sum +++ b/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=