diff --git a/api.go b/api.go index fb53a04..acfcab3 100644 --- a/api.go +++ b/api.go @@ -128,6 +128,16 @@ func (api *API) DisableHook(project, repository, key string) error { return err } +func (api *API) InheritHook(project, repository, key string) error { + _, err := request( + "DELETE", + api.sub(project, repository).Res("settings"). + Res("hooks").Res(key), + ) + + return err +} + func (api *API) SetHookSettings(project, repository, key string, settings *HookSettings) error { _, err := request( "PUT", diff --git a/main.go b/main.go index a91b68a..76d3b6c 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ Usage: bitbucket-external-hook [options] print -b -p [-r ] bitbucket-external-hook [options] enable -b -p [-r ] bitbucket-external-hook [options] disable -b -p [-r ] + bitbucket-external-hook [options] inherit -b -p [-r ] bitbucket-external-hook [options] set -b -p [-r ] [-e ] [-s] [...] bitbucket-external-hook count -b [--debug] [] bitbucket-external-hook -h | --help @@ -54,6 +55,7 @@ type ( Print bool Enable bool Disable bool + Inherit bool Set bool Executable string @@ -98,6 +100,8 @@ func main() { err = handleEnable(api, opts) case opts.Disable: err = handleDisable(api, opts) + case opts.Inherit: + err = handleInherit(api, opts) case opts.Set: err = handleSet(api, opts) case opts.Count: @@ -153,6 +157,18 @@ func handleDisable(api *API, opts Options) error { return nil } +func handleInherit(api *API, opts Options) error { + err := api.InheritHook(opts.Project, opts.Repository, opts.Hook) + if err != nil { + return karma.Format( + err, + "unable to enable hook", + ) + } + + return nil +} + func handlePrint(api *API, opts Options) error { hook, err := api.GetHook(opts.Project, opts.Repository, opts.Hook) if err != nil {