1
0
Fork 0
mirror of https://github.com/drone/drone-cli.git synced 2024-05-27 01:06:02 +02:00

Merge pull request #60 from josmo/set-build-counter

Set build counter
This commit is contained in:
Brad Rydzewski 2017-08-12 23:52:36 -05:00 committed by GitHub
commit 297de8e13c
3 changed files with 34 additions and 17 deletions

View File

@ -36,6 +36,14 @@ var repoUpdateCmd = cli.Command{
Name: "config",
Usage: "repository configuration path (e.g. .drone.yml)",
},
cli.IntFlag{
Name: "build-counter",
Usage: "repository starting build number",
},
cli.BoolFlag{
Name: "unsafe",
Usage: "validate updating the build-counter is unsafe",
},
},
}
@ -52,11 +60,13 @@ func repoUpdate(c *cli.Context) error {
}
var (
visibility = c.String("visibility")
config = c.String("config")
timeout = c.Duration("timeout")
trusted = c.Bool("trusted")
gated = c.Bool("gated")
visibility = c.String("visibility")
config = c.String("config")
timeout = c.Duration("timeout")
trusted = c.Bool("trusted")
gated = c.Bool("gated")
buildCounter = c.Int("build-counter")
unsafe = c.Bool("unsafe")
)
patch := new(drone.RepoPatch)
@ -79,6 +89,12 @@ func repoUpdate(c *cli.Context) error {
patch.Visibility = &visibility
}
}
if c.IsSet("build-counter") && !unsafe {
fmt.Printf("Setting the build counter is an unsafe operation that could put your repository in an inconsistent state. Please use --unsafe to proceed")
}
if c.IsSet("build-counter") && unsafe {
patch.BuildCounter = &buildCounter
}
if _, err := client.RepoPatch(owner, name, patch); err != nil {
return err

View File

@ -37,15 +37,16 @@ type (
// RepoPatch defines a repository patch request.
RepoPatch struct {
Config *string `json:"config_file,omitempty"`
IsTrusted *bool `json:"trusted,omitempty"`
IsGated *bool `json:"gated,omitempty"`
Timeout *int64 `json:"timeout,omitempty"`
Visibility *string `json:"visibility"`
AllowPull *bool `json:"allow_pr,omitempty"`
AllowPush *bool `json:"allow_push,omitempty"`
AllowDeploy *bool `json:"allow_deploy,omitempty"`
AllowTag *bool `json:"allow_tag,omitempty"`
Config *string `json:"config_file,omitempty"`
IsTrusted *bool `json:"trusted,omitempty"`
IsGated *bool `json:"gated,omitempty"`
Timeout *int64 `json:"timeout,omitempty"`
Visibility *string `json:"visibility"`
AllowPull *bool `json:"allow_pr,omitempty"`
AllowPush *bool `json:"allow_push,omitempty"`
AllowDeploy *bool `json:"allow_deploy,omitempty"`
AllowTag *bool `json:"allow_tag,omitempty"`
BuildCounter *int `json:"build_counter,omitempty"`
}
// Build defines a build object.

6
vendor/vendor.json vendored
View File

@ -273,10 +273,10 @@
"revisionTime": "2017-05-14T17:21:45Z"
},
{
"checksumSHA1": "qLAnM1gmgrZfYrGCNE+nKYFrJAY=",
"checksumSHA1": "b7aKujxkg1kYWPvSrHFKNRC3MWU=",
"path": "github.com/drone/drone-go/drone",
"revision": "327c9594f784216a651dbaed30731600e496dd4e",
"revisionTime": "2017-08-01T19:17:01Z"
"revision": "b78c6c108686d1fb224c3d9e44c33addd129bd8b",
"revisionTime": "2017-08-13T04:37:16Z"
},
{
"checksumSHA1": "pjMV8mwWcQ0Kk9cbLWweTGiqYPk=",