From f4df9cbc73799b14afd0db5e93f4b8fde1b7400e Mon Sep 17 00:00:00 2001 From: Patrick Jahns Date: Sun, 20 Nov 2016 21:34:06 +0100 Subject: [PATCH] add command line feature for chown api endpoint --- drone/repo.go | 1 + drone/repo_chown.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 drone/repo_chown.go diff --git a/drone/repo.go b/drone/repo.go index 68d8812a..a59433c7 100644 --- a/drone/repo.go +++ b/drone/repo.go @@ -10,5 +10,6 @@ var repoCmd = cli.Command{ repoInfoCmd, repoAddCmd, repoRemoveCmd, + repoChownCmd, }, } diff --git a/drone/repo_chown.go b/drone/repo_chown.go new file mode 100644 index 00000000..c6fd8fcf --- /dev/null +++ b/drone/repo_chown.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "log" + + "github.com/codegangsta/cli" +) + +var repoChownCmd = cli.Command{ + Name: "chown", + Usage: "assume ownership of a repository", + Action: func(c *cli.Context) { + if err := repoChown(c); err != nil { + log.Fatalln(err) + } + }, +} + +func repoChown(c *cli.Context) error { + repo := c.Args().First() + owner, name, err := parseRepo(repo) + if err != nil { + return err + } + + client, err := newClient(c) + if err != nil { + return err + } + + if _, err := client.RepoChown(owner, name); err != nil { + return err + } + fmt.Printf("Successfully assumed ownership of repository %s/%s\n", owner, name) + return nil +}