diff --git a/.github/bb-logo.png b/.github/bb-logo.png
new file mode 100644
index 0000000..afdef69
Binary files /dev/null and b/.github/bb-logo.png differ
diff --git a/.github/bb-logo.svg b/.github/bb-logo.svg
new file mode 100644
index 0000000..37c22e9
--- /dev/null
+++ b/.github/bb-logo.svg
@@ -0,0 +1,96 @@
+
+
diff --git a/.github/screenshot_create_pr.png b/.github/screenshot_create_pr.png
new file mode 100644
index 0000000..7a3f241
Binary files /dev/null and b/.github/screenshot_create_pr.png differ
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..f1a1ef2
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,29 @@
+name: build
+on: [push, pull_request]
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ go-version: [~1.13, ^1]
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ runs-on: ${{ matrix.os }}
+ env:
+ GO111MODULE: "on"
+ steps:
+ - name: Install Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ matrix.go-version }}
+
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Download Go modules
+ run: go mod download
+
+ - name: Build
+ run: go build -v ./...
+
+ - name: Test
+ run: go test ./...
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 0000000..da69d9b
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,22 @@
+name: lint
+on:
+ push:
+ pull_request:
+
+jobs:
+ golangci:
+ name: lint
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: golangci-lint
+ uses: golangci/golangci-lint-action@v2
+ with:
+ # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
+ version: v1.30
+ # Optional: golangci-lint command line arguments.
+ args: --issues-exit-code=0
+ # Optional: working directory, useful for monorepos
+ # working-directory: somedir
+ # Optional: show only new issues if it's a pull request. The default value is `false`.
+ only-new-issues: true
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b521bd6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,18 @@
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+# vendor/ rootCmd.PersistentFlags
+
+bb
+dist/
diff --git a/.goreleaser.yml b/.goreleaser.yml
new file mode 100644
index 0000000..ef0fbf7
--- /dev/null
+++ b/.goreleaser.yml
@@ -0,0 +1,44 @@
+# This is an example goreleaser.yaml file with some sane defaults.
+# Make sure to check the documentation at http://goreleaser.com
+before:
+ hooks:
+ # You may remove this if you don't use go modules.
+ - go mod download
+ # you may remove this if you don't need go generate
+ - go generate ./...
+builds:
+ - env:
+ - CGO_ENABLED=0
+ goos:
+ - linux
+ - windows
+ - darwin
+archives:
+ - replacements:
+ darwin: Darwin
+ linux: Linux
+ windows: Windows
+ 386: i386
+ amd64: x86_64
+
+nfpms:
+ -
+ vendor: craftamap
+ maintainer: "Fabian Siegel "
+ description: "inoffical Bitbucket.org command line tool"
+ license: MIT
+ formats:
+ - deb
+ - rpm
+ bindir: /usr/bin
+
+checksum:
+ name_template: 'checksums.txt'
+snapshot:
+ name_template: "{{ .Tag }}-next"
+changelog:
+ sort: asc
+ filters:
+ exclude:
+ - '^docs:'
+ - '^test:'
diff --git a/README.md b/README.md
index 9c4f3ac..5e6b0d2 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,69 @@
-# bb
\ No newline at end of file
+# bb
+
+![bb logo](.github/bb-logo.png)
+
+---
+
+`bb` is an inoffical bitbucket.org command line tool deeply inspired by the
+official [GitHub CLI](https://github.com/cli/cli/). It brings pull requests,
+downloads, and other bitbucket concepts to you the terminal.
+
+![screenshot showing ](.github/screenshot_create_pr.png)
+
+# Installation
+
+Currently, the only option to install bb is by compiling it from source.
+
+Make sure you have a working Go environment. Follow the
+[Go install instructions](https://golang.org/doc/install).
+
+## Using `go get`
+
+```bash
+go get github.com/craftamap/bb
+```
+
+## Building from source
+
+```bash
+git clone https://github.com/craftamap/bb.git
+go build
+```
+
+# Set-Up
+
+You need to authenticate with your credentials first. You should generate a
+[app password](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/)
+for that. Make sure to grant read and write access to the features you want to use.
+(**Recommended**:Repositories: Read/Write, Pull Requests: Read/Write, Pipelines: Read/Write)
+
+Run the following command to enter your username and password:
+
+```bash
+bb auth login
+```
+
+Your credentials will be stored to `~/.config/bb/configuration.toml`.
+
+# Usage
+
+To see all available commands, use `bb` without any subcommand.
+
+## Pull Requests
+
+You can use `bb pr` to list, view and merge existing pull requests and see how
+their pipelines run. You can also use `bb pr create` to create new ones.
+
+## Downloads
+
+Manage downloads by listing, downloading or uploading them.
+
+# Development
+## Used Libraries
+
+We use two multiple different bitbucket libaries:
+
+ - https://github.com/ktrysmt/go-bitbucket
+ - https://github.com/jsdidierlaurent/go-bitbucket
+
+Thanks to both of these!
diff --git a/cmd/commands/api/api.go b/cmd/commands/api/api.go
new file mode 100644
index 0000000..65aaa5b
--- /dev/null
+++ b/cmd/commands/api/api.go
@@ -0,0 +1,84 @@
+package api
+
+import (
+ "bytes"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "strings"
+
+ "github.com/craftamap/bb/cmd/options"
+ "github.com/logrusorgru/aurora"
+ "github.com/spf13/cobra"
+ "github.com/tidwall/pretty"
+)
+
+var (
+ Method string
+ Headers []string
+)
+
+func Add(rootCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ apiCmd := &cobra.Command{
+ Use: "api []",
+ Short: "Make an authenticated api.bitbucket.org request to the rest 2.0 api",
+ Long: "Make an authenticated api.bitbucket.org request to the rest 2.0 api",
+ Run: func(cmd *cobra.Command, args []string) {
+ fmt.Println(Headers)
+
+ client := http.Client{}
+
+ url := ""
+ if len(args) > 0 {
+ url = args[0]
+ }
+ url = "https://api.bitbucket.org/2.0/" + url
+
+ reqBody := ""
+ if len(args) == 2 {
+ reqBody = args[1]
+ }
+
+ req, err := http.NewRequest(Method, url, bytes.NewBufferString(reqBody))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ req.SetBasicAuth(globalOpts.Username, globalOpts.Password)
+
+ for _, header := range Headers {
+ splitted := strings.SplitN(header, "=", 2)
+ if len(splitted) == 2 {
+ req.Header.Add(splitted[0], splitted[1])
+ }
+ }
+
+ response, err := client.Do(req)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ defer response.Body.Close()
+
+ resBody, err := ioutil.ReadAll(response.Body)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if response.StatusCode <= 200 || response.StatusCode > 299 {
+ fmt.Printf("%s%s%d\n", aurora.Yellow(":: "), aurora.Bold("Status Code: "), response.StatusCode)
+ }
+
+ if strings.Contains(response.Header["Content-Type"][0], "json") {
+ fmt.Println(string(pretty.Color(pretty.Pretty(resBody), nil)))
+ } else {
+ fmt.Println(string(resBody))
+ }
+ },
+ }
+
+ apiCmd.Flags().StringVarP(&Method, "method", "X", "GET", "The HTTP method for the request")
+ apiCmd.Flags().StringArrayVarP(&Headers, "header", "H", []string{}, "Add an additional HTTP request header")
+ rootCmd.AddCommand(apiCmd)
+}
diff --git a/cmd/commands/auth/auth.go b/cmd/commands/auth/auth.go
new file mode 100644
index 0000000..e1b53ed
--- /dev/null
+++ b/cmd/commands/auth/auth.go
@@ -0,0 +1,16 @@
+package auth
+
+import (
+ "github.com/craftamap/bb/cmd/commands/auth/login"
+ "github.com/craftamap/bb/cmd/options"
+ "github.com/spf13/cobra"
+)
+
+func Add(rootCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ authCmd := &cobra.Command{
+ Use: "auth",
+ Short: "Manage bb authentification state",
+ }
+ login.Add(authCmd, globalOpts)
+ rootCmd.AddCommand(authCmd)
+}
diff --git a/cmd/commands/auth/login/login.go b/cmd/commands/auth/login/login.go
new file mode 100644
index 0000000..ea1070e
--- /dev/null
+++ b/cmd/commands/auth/login/login.go
@@ -0,0 +1,76 @@
+package login
+
+import (
+ "fmt"
+
+ "github.com/AlecAivazis/survey/v2"
+ "github.com/craftamap/bb/cmd/options"
+ "github.com/logrusorgru/aurora"
+ "github.com/spf13/cobra"
+ "github.com/spf13/viper"
+)
+
+func Add(authCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ loginCmd := &cobra.Command{
+ Use: "login",
+ Run: func(cmd *cobra.Command, args []string) {
+ oldPw := viper.GetString("password")
+
+ if oldPw != "" {
+ fmt.Println(aurora.Yellow("::"), aurora.Bold("Warning:"), "You are already logged in as", viper.GetString("username"))
+ cont := false
+ err := survey.AskOne(&survey.Confirm{Message: "Do you want to overwrite this?"}, &cont)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ if !cont {
+ return
+ }
+ }
+
+ fmt.Println(aurora.Green("::"), "In order to use bb, you need to create an app password for bitbucket.org. Navigate to")
+ fmt.Println(aurora.Green("::"), aurora.Index(242, "https://bitbucket.org/account/settings/app-passwords/"))
+ fmt.Println(aurora.Green("::"), "And create an app password for your account with the required permissions.")
+
+ answers := struct {
+ Username string
+ Password string
+ }{}
+
+ err := survey.Ask([]*survey.Question{
+ {
+ Name: "username",
+ Prompt: &survey.Input{
+ Message: "Please enter your username:",
+ },
+ },
+ {
+ Name: "password",
+ Prompt: &survey.Password{
+ Message: "Please enter the app password you just created:",
+ },
+ },
+ }, &answers)
+
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ viper.Set("username", answers.Username)
+ viper.Set("password", answers.Password)
+
+ err = viper.WriteConfig()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ fmt.Println(aurora.Green("::"), "Stored credentials successfully to", viper.ConfigFileUsed())
+ },
+ }
+
+ authCmd.AddCommand(loginCmd)
+}
diff --git a/cmd/commands/downloads/download/download.go b/cmd/commands/downloads/download/download.go
new file mode 100644
index 0000000..3a675c5
--- /dev/null
+++ b/cmd/commands/downloads/download/download.go
@@ -0,0 +1,65 @@
+package download
+
+import (
+ "fmt"
+
+ "github.com/craftamap/bb/cmd/options"
+ bbgit "github.com/craftamap/bb/git"
+ "github.com/craftamap/bb/internal"
+ "github.com/logrusorgru/aurora"
+ "github.com/spf13/cobra"
+)
+
+var (
+ Web bool
+)
+
+func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ downloadCmd := &cobra.Command{
+ Use: "download []",
+ Short: "download files from bitbucket",
+ Run: func(cmd *cobra.Command, args []string) {
+ // TODO: Get rid of this "list" workaround
+ c := internal.Client{
+ Username: globalOpts.Username,
+ Password: globalOpts.Password,
+ }
+
+ bbrepo, err := bbgit.GetBitbucketRepo()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if !bbrepo.IsBitbucketOrg() {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Are you sure this is a bitbucket repo?")
+ return
+ }
+ downloads, err := c.GetDownloads(bbrepo.RepoOrga, bbrepo.RepoSlug)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ downloadMap := downloadsToMap(downloads)
+
+ dwnld, ok := downloadMap[args[0]]
+ if !ok {
+ fmt.Println("Zu hülfe!!")
+ return
+ }
+
+ fmt.Println(dwnld.Links)
+ },
+ }
+
+ downloadCmd.Flags().BoolVar(&Web, "web", false, "view the pull request in your browser")
+ prCmd.AddCommand(downloadCmd)
+}
+
+func downloadsToMap(downloads *internal.Downloads) map[string]*internal.Download {
+ downloadMap := map[string]*internal.Download{}
+ for _, dwnld := range downloads.Values {
+ downloadMap[dwnld.Name] = &dwnld
+ }
+ return downloadMap
+}
diff --git a/cmd/commands/downloads/downloads.go b/cmd/commands/downloads/downloads.go
new file mode 100644
index 0000000..115f15f
--- /dev/null
+++ b/cmd/commands/downloads/downloads.go
@@ -0,0 +1,23 @@
+package downloads
+
+import (
+ "github.com/craftamap/bb/cmd/commands/downloads/download"
+ "github.com/craftamap/bb/cmd/commands/downloads/list"
+ "github.com/craftamap/bb/cmd/commands/downloads/upload"
+ "github.com/craftamap/bb/cmd/options"
+ "github.com/spf13/cobra"
+)
+
+func Add(rootCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ downloadsCmd := &cobra.Command{
+ Use: "downloads",
+ Short: "Manage repository downloads",
+ Long: "Manage repository downloads on Bitbucket.org",
+ }
+
+ list.Add(downloadsCmd, globalOpts)
+ upload.Add(downloadsCmd, globalOpts)
+ download.Add(downloadsCmd, globalOpts)
+
+ rootCmd.AddCommand(downloadsCmd)
+}
diff --git a/cmd/commands/downloads/list/list.go b/cmd/commands/downloads/list/list.go
new file mode 100644
index 0000000..cd68745
--- /dev/null
+++ b/cmd/commands/downloads/list/list.go
@@ -0,0 +1,68 @@
+package list
+
+import (
+ "fmt"
+
+ "github.com/craftamap/bb/cmd/options"
+ bbgit "github.com/craftamap/bb/git"
+ "github.com/craftamap/bb/internal"
+ "github.com/dustin/go-humanize"
+ "github.com/logrusorgru/aurora"
+ "github.com/pkg/browser"
+ "github.com/spf13/cobra"
+)
+
+var (
+ Web bool
+)
+
+func Add(downloadsCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ listCmd := &cobra.Command{
+ Use: "list",
+ Run: func(cmd *cobra.Command, args []string) {
+ c := internal.Client{
+ Username: globalOpts.Username,
+ Password: globalOpts.Password,
+ }
+
+ bbrepo, err := bbgit.GetBitbucketRepo()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if !bbrepo.IsBitbucketOrg() {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Are you sure this is a bitbucket repo?")
+ return
+ }
+ if Web {
+ err := browser.OpenURL(fmt.Sprintf("https://bitbucket.org/%s/%s/downloads", bbrepo.RepoOrga, bbrepo.RepoSlug))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ return
+ }
+ downloads, err := c.GetDownloads(bbrepo.RepoOrga, bbrepo.RepoSlug)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ for i := len(downloads.Values) - 1; i >= 0; i-- {
+ download := downloads.Values[i]
+ fmt.Printf(
+ "• %s - %s - %s - %s - %s\n",
+ download.Name,
+ aurora.Index(242, humanize.IBytes(uint64(download.Size))),
+ aurora.Index(242, download.User.DisplayName),
+ aurora.Index(242, fmt.Sprintf("%d Downloads", download.Downloads)),
+ aurora.Index(242, download.CreatedOn),
+ )
+ }
+ },
+ }
+
+ listCmd.Flags().BoolVar(&Web, "web", false, "show the downloads in your browsers")
+
+ downloadsCmd.AddCommand(listCmd)
+}
diff --git a/cmd/commands/downloads/upload/upload.go b/cmd/commands/downloads/upload/upload.go
new file mode 100644
index 0000000..6707ecf
--- /dev/null
+++ b/cmd/commands/downloads/upload/upload.go
@@ -0,0 +1,64 @@
+package upload
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+
+ "github.com/craftamap/bb/cmd/options"
+ bbgit "github.com/craftamap/bb/git"
+ "github.com/craftamap/bb/internal"
+ "github.com/logrusorgru/aurora"
+ "github.com/spf13/cobra"
+)
+
+func Add(downloadsCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ uploadCmd := &cobra.Command{
+ Use: "upload",
+ Run: func(cmd *cobra.Command, args []string) {
+ c := internal.Client{
+ Username: globalOpts.Username,
+ Password: globalOpts.Password,
+ }
+
+ bbrepo, err := bbgit.GetBitbucketRepo()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if !bbrepo.IsBitbucketOrg() {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Are you sure this is a bitbucket repo?")
+ return
+ }
+
+ if len(args) == 0 {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "No file specified")
+ return
+ }
+
+ fpath := args[0]
+ fmt.Println(fpath)
+
+ if _, err := os.Stat(fpath); os.IsNotExist(err) {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ fmt.Printf("%s Uploading file %s\n", aurora.Green(":: "), filepath.Base(fpath))
+
+ _, err = c.UploadDownload(bbrepo.RepoOrga, bbrepo.RepoSlug, fpath)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ //if err != nil {
+ // fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ // return
+ //}
+
+ fmt.Printf("%s Uploaded file %s\n", aurora.Green(":: "), filepath.Base(fpath))
+ },
+ }
+
+ downloadsCmd.AddCommand(uploadCmd)
+}
diff --git a/cmd/commands/pr/create/create.go b/cmd/commands/pr/create/create.go
new file mode 100644
index 0000000..c253ca5
--- /dev/null
+++ b/cmd/commands/pr/create/create.go
@@ -0,0 +1,210 @@
+package create
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/AlecAivazis/survey/v2"
+ "github.com/charmbracelet/glamour"
+ "github.com/cli/cli/git"
+ "github.com/cli/cli/pkg/surveyext"
+ "github.com/craftamap/bb/cmd/options"
+ bbgit "github.com/craftamap/bb/git"
+ "github.com/craftamap/bb/internal"
+ "github.com/logrusorgru/aurora"
+ "github.com/spf13/cobra"
+)
+
+var (
+ Title string
+ Body string
+ Force bool
+)
+
+func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ createCmd := &cobra.Command{
+ Use: "create",
+ Short: "Create a pull request",
+ Run: func(cmd *cobra.Command, args []string) {
+ var (
+ sourceBranch string
+ )
+ // Initialisation
+ c := internal.Client{
+ Username: globalOpts.Username,
+ Password: globalOpts.Password,
+ }
+
+ bbrepo, err := bbgit.GetBitbucketRepo()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if !bbrepo.IsBitbucketOrg() {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Are you sure this is a bitbucket repo?")
+ return
+ }
+
+ // Get Current Branch
+ sourceBranch, err = git.CurrentBranch()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ // Prepare required data
+ var (
+ targetBranch string
+ title string
+ body string
+ defaultBody string
+ reviewers []string
+ )
+ // First, init default data
+ repo, err := c.RepositoryGet(bbrepo.RepoOrga, bbrepo.RepoSlug)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ targetBranch = repo.MainBranch.Name
+
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ title, body, err = c.PrDefaultTitleAndBody(bbrepo.RepoOrga, bbrepo.RepoSlug, sourceBranch, targetBranch)
+ defaultBody = body
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ defaultReviewers, err := c.GetDefaultReviewers(bbrepo.RepoOrga, bbrepo.RepoSlug)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ for _, rev := range defaultReviewers.Values {
+ reviewers = append(reviewers, rev.UUID)
+ }
+
+ // Then, check if a pr is already existing. If force is True, take that data
+ possiblePrs, err := c.GetPrIDBySourceBranch(bbrepo.RepoOrga, bbrepo.RepoSlug, sourceBranch)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ if !Force {
+ if len(possiblePrs.Values) != 0 {
+ id := possiblePrs.Values[0].ID
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), fmt.Sprintf("Pull request %d already exists for this branch. Use --force to ignore this.", id))
+ return
+ }
+ } else {
+ if len(possiblePrs.Values) > 0 {
+ existingPr := possiblePrs.Values[0]
+ title = existingPr.Title
+ body = existingPr.Description
+ reviewers = []string{}
+ for _, reviewer := range existingPr.Reviewers {
+ // TODO: make this memory efficient
+ reviewers = append(reviewers, reviewer.UUID)
+ }
+ }
+ }
+ verb := "Creating"
+ if Force {
+ verb = "Re-Creating"
+ }
+
+ fmt.Printf("%s pull request for %s into %s in %s\n", verb, sourceBranch, targetBranch, fmt.Sprintf("%s/%s", bbrepo.RepoOrga, bbrepo.RepoSlug))
+ fmt.Println()
+
+ if Title == "" {
+ questionTitle := &survey.Input{
+ Message: "Title",
+ Default: title,
+ }
+ err = survey.AskOne(questionTitle, &title)
+ }
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ fmt.Println(aurora.Bold(aurora.Green("!").String() + " Body:"))
+
+ out, _ := glamour.Render(body, "dark")
+ fmt.Print(out)
+
+ for {
+ selectNext := &survey.Select{
+ Message: "What's next?",
+ Options: []string{"create", "modify body", "change destination branch", "cancel"},
+ Default: "create",
+ }
+ var doNext string
+ err = survey.AskOne(selectNext, &doNext)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ if doNext == "cancel" {
+ return
+ } else if doNext == "create" {
+ break
+ }
+
+ if doNext == "modify body" {
+ body, err = surveyext.Edit("vim", "", body, os.Stdin, os.Stdout, os.Stderr, nil)
+ if err != nil {
+ fmt.Printf("%s%s%#v\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ continue
+ }
+
+ if doNext == "change destination branch" {
+ err := survey.AskOne(&survey.Input{
+ Message: "type your destination branch",
+ Default: targetBranch,
+ }, &targetBranch)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ // We need to re-generate the body, if the destination branch is changed
+ // but only if the body was not modified in before
+
+ _, tempBody, err := c.PrDefaultTitleAndBody(bbrepo.RepoOrga, bbrepo.RepoSlug, sourceBranch, targetBranch)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if body == defaultBody {
+ body = tempBody
+ }
+
+ }
+
+ }
+
+ response, err := c.PrCreate(bbrepo.RepoOrga, bbrepo.RepoSlug, sourceBranch, targetBranch, title, body, reviewers)
+ if err != nil {
+ fmt.Printf("%s%s%#v\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ fmt.Printf("Take a look at your pull request here: %s\n", aurora.Index(242, response.Links["html"].Href))
+ },
+ }
+ createCmd.Flags().StringVarP(&Body, "body", "b", "", "Supply a body.")
+ createCmd.Flags().StringVarP(&Title, "title", "t", "", "Supply a title.")
+ createCmd.Flags().BoolVar(&Force, "force", false, "force creation")
+ prCmd.AddCommand(createCmd)
+}
diff --git a/cmd/commands/pr/list/list.go b/cmd/commands/pr/list/list.go
new file mode 100644
index 0000000..2488aac
--- /dev/null
+++ b/cmd/commands/pr/list/list.go
@@ -0,0 +1,76 @@
+package list
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/craftamap/bb/cmd/options"
+ bbgit "github.com/craftamap/bb/git"
+ "github.com/craftamap/bb/internal"
+ "github.com/logrusorgru/aurora"
+ "github.com/pkg/browser"
+ "github.com/spf13/cobra"
+ "github.com/wbrefvem/go-bitbucket"
+)
+
+var (
+ Web bool
+ State string
+)
+
+func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ listCmd := &cobra.Command{
+ Use: "list",
+ Short: "List and filter pull requests in this repository",
+ Long: "List and filter pull requests in this repository",
+ Run: func(cmd *cobra.Command, args []string) {
+ c := internal.Client{
+ Username: globalOpts.Username,
+ Password: globalOpts.Password,
+ }
+ bbrepo, err := bbgit.GetBitbucketRepo()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if !bbrepo.IsBitbucketOrg() {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Are you sure this is a bitbucket repo?")
+ return
+ }
+
+ if Web {
+ repo, err := c.RepositoryGet(bbrepo.RepoOrga, bbrepo.RepoSlug)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ }
+
+ linkWrapper := repo.Links["Html"].(*bitbucket.SubjectTypesRepositoryEvents)
+ link := linkWrapper.Href + "/pull-requests"
+ err = browser.OpenURL(link)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ return
+ }
+
+ state := strings.ToUpper(State)
+
+ prs, err := c.PrList(bbrepo.RepoOrga, bbrepo.RepoSlug, []string{state})
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ }
+
+ fmt.Println()
+ fmt.Printf("%sShowing %d of %d open pull requests in %s/%s\n", aurora.Blue(" :: "), len(prs.Values), prs.Size, bbrepo.RepoOrga, bbrepo.RepoSlug)
+ fmt.Println()
+ for _, pr := range prs.Values {
+ fmt.Printf("#%03d %s %s -> %s\n", aurora.Green(pr.ID), pr.Title, pr.Source.Branch.Name, pr.Destination.Branch.Name)
+ }
+ },
+ }
+ listCmd.Flags().StringVar(&State, "state", "open", "Filter by state: {open|merged|declined|superseded}")
+ listCmd.Flags().BoolVar(&Web, "web", false, "view pull requests in your browser")
+ prCmd.AddCommand(listCmd)
+}
diff --git a/cmd/commands/pr/merge/merge.go b/cmd/commands/pr/merge/merge.go
new file mode 100644
index 0000000..b6a8a24
--- /dev/null
+++ b/cmd/commands/pr/merge/merge.go
@@ -0,0 +1,82 @@
+package merge
+
+import (
+ "fmt"
+ "strconv"
+
+ "github.com/cli/cli/git"
+ "github.com/craftamap/bb/cmd/commands/pr/view"
+ "github.com/craftamap/bb/cmd/options"
+ bbgit "github.com/craftamap/bb/git"
+ "github.com/craftamap/bb/internal"
+ "github.com/logrusorgru/aurora"
+ "github.com/spf13/cobra"
+)
+
+func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ mergeCmd := &cobra.Command{
+ Use: "merge",
+ Long: "Merge a pull request on Bitbucket.org",
+ Short: "Merge a pull request",
+ Run: func(cmd *cobra.Command, args []string) {
+ var id int
+ var err error
+
+ c := internal.Client{
+ Username: globalOpts.Username,
+ Password: globalOpts.Password,
+ }
+
+ bbrepo, err := bbgit.GetBitbucketRepo()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if !bbrepo.IsBitbucketOrg() {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Are you sure this is a bitbucket repo?")
+ return
+ }
+
+ if len(args) > 0 {
+ id, err = strconv.Atoi(args[0])
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ } else {
+ branchName, err := git.CurrentBranch()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ prs, err := c.GetPrIDBySourceBranch(bbrepo.RepoOrga, bbrepo.RepoSlug, branchName)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if len(prs.Values) == 0 {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Nothing on this branch")
+ return
+ }
+
+ id = prs.Values[0].ID
+ }
+ pr, err := c.PrMerge(bbrepo.RepoOrga, bbrepo.RepoSlug, fmt.Sprintf("%d", id))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ commits, err := c.PrCommits(bbrepo.RepoOrga, bbrepo.RepoSlug, fmt.Sprintf("%d", id))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ view.PrintSummary(pr, commits)
+
+ },
+ }
+
+ prCmd.AddCommand(mergeCmd)
+}
diff --git a/cmd/commands/pr/pr.go b/cmd/commands/pr/pr.go
new file mode 100644
index 0000000..a35acf5
--- /dev/null
+++ b/cmd/commands/pr/pr.go
@@ -0,0 +1,28 @@
+package pr
+
+import (
+ "github.com/spf13/cobra"
+
+ "github.com/craftamap/bb/cmd/commands/pr/create"
+ "github.com/craftamap/bb/cmd/commands/pr/list"
+ "github.com/craftamap/bb/cmd/commands/pr/merge"
+ "github.com/craftamap/bb/cmd/commands/pr/statuses"
+ "github.com/craftamap/bb/cmd/commands/pr/view"
+ "github.com/craftamap/bb/cmd/options"
+)
+
+func Add(rootCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ prCommand := cobra.Command{
+ Use: "pr",
+ Long: "Work with pull requests",
+ Short: "Manage pull requests",
+ }
+
+ list.Add(&prCommand, globalOpts)
+ view.Add(&prCommand, globalOpts)
+ create.Add(&prCommand, globalOpts)
+ statuses.Add(&prCommand, globalOpts)
+ merge.Add(&prCommand, globalOpts)
+
+ rootCmd.AddCommand(&prCommand)
+}
diff --git a/cmd/commands/pr/statuses/statuses.go b/cmd/commands/pr/statuses/statuses.go
new file mode 100644
index 0000000..7e29a1e
--- /dev/null
+++ b/cmd/commands/pr/statuses/statuses.go
@@ -0,0 +1,123 @@
+package statuses
+
+import (
+ "fmt"
+ "strconv"
+
+ "github.com/cli/cli/git"
+ "github.com/craftamap/bb/cmd/options"
+ bbgit "github.com/craftamap/bb/git"
+ "github.com/craftamap/bb/internal"
+ "github.com/logrusorgru/aurora"
+ "github.com/spf13/cobra"
+)
+
+func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ statusesCmd := &cobra.Command{
+ Use: "statuses",
+ Short: "Show CI status for a single pull request",
+ Long: "Show CI status for a single pull request",
+ Run: func(cmd *cobra.Command, args []string) {
+ var id int
+ var err error
+
+ c := internal.Client{
+ Username: globalOpts.Username,
+ Password: globalOpts.Password,
+ }
+
+ bbrepo, err := bbgit.GetBitbucketRepo()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if !bbrepo.IsBitbucketOrg() {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Are you sure this is a bitbucket repo?")
+ return
+ }
+
+ if len(args) > 0 {
+ id, err = strconv.Atoi(args[0])
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ } else {
+ branchName, err := git.CurrentBranch()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ prs, err := c.GetPrIDBySourceBranch(bbrepo.RepoOrga, bbrepo.RepoSlug, branchName)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if len(prs.Values) == 0 {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Nothing on this branch")
+ return
+ }
+
+ id = prs.Values[0].ID
+ }
+ statuses, err := c.PrStatuses(bbrepo.RepoOrga, bbrepo.RepoSlug, fmt.Sprintf("%d", id))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ if len(statuses.Values) == 0 {
+ fmt.Println("No builds/statuses found for this pull request")
+ } else {
+ var (
+ allChecksSuccessful = true
+ successfulCount = 0
+ failedCount = 0
+ inProgressCount = 0
+ stoppedCount = 0
+ )
+
+ for _, status := range statuses.Values {
+ if status.State != "SUCCESSFUL" {
+ allChecksSuccessful = false
+ }
+
+ switch status.State {
+ case "SUCCESSFUL":
+ successfulCount++
+ case "FAILED":
+ failedCount++
+ case "INPROGRESS":
+ inProgressCount++
+ case "STOPPED":
+ stoppedCount++
+ }
+ }
+ if allChecksSuccessful {
+ fmt.Println(aurora.Bold("All checks were successful").String())
+ }
+ fmt.Printf("%d failed, %d successful, %d in progress and %d stopped\n", failedCount, successfulCount, inProgressCount, stoppedCount)
+ fmt.Println()
+
+ for _, status := range statuses.Values {
+ var statusIcon string
+ switch status.State {
+ case "SUCCESSFUL":
+ statusIcon = aurora.Green("✓").String()
+ case "FAILED", "STOPPED":
+ statusIcon = aurora.Red("X").String()
+ case "INPROGRESS":
+ statusIcon = aurora.Yellow("⏱️").String()
+ }
+
+ fmt.Printf("%s %s %s %s\n", statusIcon, aurora.Index(242, status.Type), status.Name, aurora.Index(242, status.URL))
+ }
+
+ }
+
+ },
+ }
+
+ prCmd.AddCommand(statusesCmd)
+}
diff --git a/cmd/commands/pr/view/view.go b/cmd/commands/pr/view/view.go
new file mode 100644
index 0000000..86faf54
--- /dev/null
+++ b/cmd/commands/pr/view/view.go
@@ -0,0 +1,131 @@
+package view
+
+import (
+ "fmt"
+ "strconv"
+
+ "github.com/charmbracelet/glamour"
+ "github.com/cli/cli/git"
+ "github.com/craftamap/bb/cmd/options"
+ bbgit "github.com/craftamap/bb/git"
+ "github.com/craftamap/bb/internal"
+ "github.com/logrusorgru/aurora"
+ "github.com/pkg/browser"
+ "github.com/spf13/cobra"
+)
+
+var (
+ Web bool
+)
+
+func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
+ viewCmd := &cobra.Command{
+ Use: "view",
+ Short: "View a pull request",
+ Long: "Display the title, body, and other information about a pull request.",
+ Run: func(cmd *cobra.Command, args []string) {
+ var id int
+ var err error
+ c := internal.Client{
+ Username: globalOpts.Username,
+ Password: globalOpts.Password,
+ }
+
+ bbrepo, err := bbgit.GetBitbucketRepo()
+
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if !bbrepo.IsBitbucketOrg() {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Are you sure this is a bitbucket repo?")
+ return
+ }
+
+ if len(args) > 0 {
+ id, err = strconv.Atoi(args[0])
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ } else {
+ branchName, err := git.CurrentBranch()
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ prs, err := c.GetPrIDBySourceBranch(bbrepo.RepoOrga, bbrepo.RepoSlug, branchName)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if len(prs.Values) == 0 {
+ fmt.Printf("%s%s%s\n", aurora.Yellow(":: "), aurora.Bold("Warning: "), "Nothing on this branch")
+ return
+ }
+
+ id = prs.Values[0].ID
+
+ }
+
+ pr, err := c.PrView(bbrepo.RepoOrga, bbrepo.RepoSlug, fmt.Sprintf("%d", id))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ if Web {
+ err := browser.OpenURL(pr.Links["html"].Href)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ return
+ }
+
+ commits, err := c.PrCommits(bbrepo.RepoOrga, bbrepo.RepoSlug, fmt.Sprintf("%d", id))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ PrintSummary(pr, commits)
+ },
+ }
+ viewCmd.Flags().BoolVar(&Web, "web", false, "view the pull request in your browser")
+ prCmd.AddCommand(viewCmd)
+}
+
+func PrintSummary(pr *internal.PullRequest, commits *internal.Commits) {
+ fmt.Println(aurora.Bold(pr.Title))
+ var state string
+ if pr.State == "OPEN" {
+ state = aurora.Green("Open").String()
+ } else if pr.State == "DECLINED" {
+ state = aurora.Red("Declined").String()
+ } else {
+ state = pr.State
+ }
+
+ nrOfCommits := len(commits.Values)
+ nrOfCommitsStr := fmt.Sprintf("%d", nrOfCommits)
+ if nrOfCommits == 10 {
+ nrOfCommitsStr = nrOfCommitsStr + "+"
+ }
+
+ infoText := aurora.Index(242, fmt.Sprintf("%s wants to merge %s commits into %s from %s\n", pr.Author.Nickname, nrOfCommitsStr, pr.Destination.Branch.Name, pr.Source.Branch.Name))
+ fmt.Printf("%s • %s\n", state, infoText)
+ if pr.Description != "" {
+ out, err := glamour.Render(pr.Description, "dark")
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ fmt.Println(out)
+ }
+
+ footer := aurora.Index(242, fmt.Sprintf("View this pull request on Bitbucket.org: %s", pr.Links["html"].Href)).String()
+ fmt.Println(footer)
+ // fmt.Println(pr, err)
+
+}
diff --git a/cmd/options/global_options.go b/cmd/options/global_options.go
new file mode 100644
index 0000000..97f8d0f
--- /dev/null
+++ b/cmd/options/global_options.go
@@ -0,0 +1,6 @@
+package options
+
+type GlobalOptions struct {
+ Username string `mapstructure:"username"`
+ Password string `mapstructure:"password"`
+}
diff --git a/cmd/root.go b/cmd/root.go
new file mode 100644
index 0000000..cddba9c
--- /dev/null
+++ b/cmd/root.go
@@ -0,0 +1,103 @@
+package cmd
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+
+ "github.com/craftamap/bb/cmd/commands/api"
+ "github.com/craftamap/bb/cmd/commands/auth"
+ "github.com/craftamap/bb/cmd/commands/downloads"
+ "github.com/craftamap/bb/cmd/commands/pr"
+ "github.com/craftamap/bb/cmd/options"
+ "github.com/kirsle/configdir"
+ "github.com/logrusorgru/aurora"
+ "github.com/spf13/cobra"
+ "github.com/spf13/viper"
+)
+
+var (
+ rootCmd = &cobra.Command{
+ Use: "bb",
+ Short: "Bitbucket.org CLI",
+ Long: "Work seamlessly with Bitbucket.org from the command line.",
+ Example: `$ bb pr list`,
+ PersistentPreRun: func(cmd *cobra.Command, args []string) {
+ err := viper.Unmarshal(&globalOpts)
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ if cmd.Name() != "login" {
+ if globalOpts.Password == "" {
+ fmt.Println(aurora.Yellow("::"), aurora.Bold("Warning:"), "Look's like you have not set up bb yet.")
+ fmt.Println(aurora.Yellow("::"), aurora.Bold("Warning:"), "Run", aurora.BgWhite(aurora.Black(" bb auth login ")), "to set up bb.")
+ }
+ }
+
+ },
+ }
+
+ cfgFile string
+ globalOpts = options.GlobalOptions{}
+
+ username string
+ password string
+)
+
+func Execute() error {
+ return rootCmd.Execute()
+}
+
+func init() {
+ cobra.OnInitialize(initConfig)
+
+ rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.config/bb)")
+ rootCmd.PersistentFlags().StringVar(&username, "username", "", "username")
+ rootCmd.PersistentFlags().StringVar(&password, "password", "", "app password")
+
+ err := viper.BindPFlag("username", rootCmd.PersistentFlags().Lookup("username"))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+ err = viper.BindPFlag("password", rootCmd.PersistentFlags().Lookup("password"))
+ if err != nil {
+ fmt.Printf("%s%s%s\n", aurora.Red(":: "), aurora.Bold("An error occured: "), err)
+ return
+ }
+
+ pr.Add(rootCmd, &globalOpts)
+ api.Add(rootCmd, &globalOpts)
+ downloads.Add(rootCmd, &globalOpts)
+ auth.Add(rootCmd, &globalOpts)
+}
+
+func initConfig() {
+ if cfgFile == "" {
+ configDir := configdir.LocalConfig("bb")
+ err := configdir.MakePath(configDir)
+ if err != nil {
+ panic(err)
+ }
+ cfgFile = filepath.Join(configDir, "configuration.toml")
+ if _, err = os.Stat(cfgFile); os.IsNotExist(err) {
+ fh, err := os.Create(cfgFile)
+ if err != nil {
+ panic(err)
+ }
+ defer fh.Close()
+ }
+ }
+
+ viper.SetConfigFile(cfgFile)
+
+ viper.AutomaticEnv()
+
+ err := viper.ReadInConfig()
+
+ if err != nil { // Handle errors reading the config file
+ panic(fmt.Errorf("fatal error config file: %s", err))
+ }
+}
diff --git a/git/bb.go b/git/bb.go
new file mode 100644
index 0000000..ba0b29e
--- /dev/null
+++ b/git/bb.go
@@ -0,0 +1,48 @@
+package git
+
+import (
+ "strings"
+
+ "github.com/cli/cli/git"
+)
+
+type BitbucketRepo struct {
+ RepoOrga string
+ RepoSlug string
+ Remote git.Remote
+}
+
+func GetBitbucketRepo() (*BitbucketRepo, error) {
+ remotes, err := git.Remotes()
+ if err != nil {
+ return nil, err
+ }
+
+ var origin git.Remote
+ for _, remote := range remotes {
+ if remote.Name == "origin" {
+ origin = *remote
+ }
+ }
+
+ path := strings.Split(origin.FetchURL.Path, "/")[1:]
+
+ repoOrga := path[0]
+ repoSlug := path[1]
+
+ if origin.FetchURL.Scheme == "ssh" && strings.HasSuffix(repoSlug, ".git") {
+ repoSlug = strings.TrimSuffix(repoSlug, ".git")
+ }
+
+ bbrepo := BitbucketRepo{
+ Remote: origin,
+ RepoOrga: repoOrga,
+ RepoSlug: repoSlug,
+ }
+
+ return &bbrepo, nil
+}
+
+func (b *BitbucketRepo) IsBitbucketOrg() bool {
+ return strings.Contains(b.Remote.FetchURL.String(), "bitbucket")
+}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..2b0579d
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,23 @@
+module github.com/craftamap/bb
+
+go 1.15
+
+require (
+ github.com/AlecAivazis/survey/v2 v2.1.1
+ github.com/charmbracelet/glamour v0.2.1-0.20200724174618-1246d13c1684
+ github.com/cli/cli v1.1.0
+ github.com/coreos/etcd v3.3.13+incompatible
+ github.com/dustin/go-humanize v1.0.0
+ github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
+ github.com/ktrysmt/go-bitbucket v0.6.6
+ github.com/logrusorgru/aurora v2.0.3+incompatible
+ github.com/logrusorgru/aurora/v3 v3.0.0 // indirect
+ github.com/mitchellh/mapstructure v1.3.3
+ github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
+ github.com/spance/go-callprivate v0.0.0-20151213012958-d8b9b5523668 // indirect
+ github.com/spf13/cobra v1.1.0
+ github.com/spf13/viper v1.7.0
+ github.com/thoas/go-funk v0.7.0 // indirect
+ github.com/tidwall/pretty v1.0.2
+ github.com/wbrefvem/go-bitbucket v0.0.0-20190128183802-fc08fd046abb
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..b96a8d4
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,442 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
+cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
+cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
+cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
+cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
+cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
+cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
+cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
+cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
+cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
+dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
+github.com/AlecAivazis/survey v1.8.8 h1:Y4yypp763E8cbqb5RBqZhGgkCFLRFnbRBHrxnpMMsgQ=
+github.com/AlecAivazis/survey/v2 v2.1.1 h1:LEMbHE0pLj75faaVEKClEX1TM4AJmmnOh9eimREzLWI=
+github.com/AlecAivazis/survey/v2 v2.1.1/go.mod h1:9FJRdMdDm8rnT+zHVbvQT2RTSTLq0Ttd6q3Vl2fahjk=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
+github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
+github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
+github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
+github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
+github.com/alecthomas/chroma v0.7.3 h1:NfdAERMy+esYQs8OXk0I868/qDxxCEo7FMz1WIqMAeI=
+github.com/alecthomas/chroma v0.7.3/go.mod h1:sko8vR34/90zvl5QdcUdvzL3J8NKjAUx9va9jPuFNoM=
+github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
+github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
+github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
+github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
+github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
+github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
+github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
+github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
+github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
+github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
+github.com/briandowns/spinner v1.11.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
+github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
+github.com/charmbracelet/glamour v0.2.0 h1:mTgaiNiumpqTZp3qVM6DH9UB0NlbY17wejoMf1kM8Pg=
+github.com/charmbracelet/glamour v0.2.0/go.mod h1:UA27Kwj3QHialP74iU6C+Gpc8Y7IOAKupeKMLLBURWM=
+github.com/charmbracelet/glamour v0.2.1-0.20200724174618-1246d13c1684 h1:YMyvXRstOQc7n6eneHfudVMbARSCmZ7EZGjtTkkeB3A=
+github.com/charmbracelet/glamour v0.2.1-0.20200724174618-1246d13c1684/go.mod h1:UA27Kwj3QHialP74iU6C+Gpc8Y7IOAKupeKMLLBURWM=
+github.com/cli/cli v1.1.0 h1:Ynfk6q+1ozX/3YhY5J4QMf9J6rekO7rDpwYgc2DtEkc=
+github.com/cli/cli v1.1.0/go.mod h1:9W9naQhz5tAJCqlvkp962EQE7jiEUuRW83oqk71yYsc=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
+github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/etcd v3.3.13+incompatible h1:8F3hqu9fGYLBifCmRCJsicFqDx/D68Rt3q1JMazcgBQ=
+github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
+github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
+github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
+github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk=
+github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
+github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
+github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
+github.com/enescakir/emoji v1.0.0/go.mod h1:Bt1EKuLnKDTYpLALApstIkAjdDrS/8IAgTkKp+WKFD0=
+github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
+github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
+github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
+github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
+github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f h1:5CjVwnuUcp5adK4gmY6i72gpVFVnZDP2h5TmPScB6u4=
+github.com/google/goterm v0.0.0-20190703233501-fc88cf888a3f/go.mod h1:nOFQdrUlIlx6M6ODdSpBj1NVA+VgLC6kmw60mkw34H4=
+github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
+github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
+github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
+github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
+github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
+github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
+github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
+github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
+github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
+github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
+github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
+github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
+github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
+github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
+github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
+github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
+github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
+github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
+github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
+github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
+github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
+github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
+github.com/henvic/httpretty v0.0.6/go.mod h1:X38wLjWXHkXT7r2+uK8LjCMne9rsuNaBLJ+5cU2/Pmo=
+github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
+github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
+github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
+github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
+github.com/k0kubun/pp v2.3.0+incompatible h1:EKhKbi34VQDWJtq+zpsKSEhkHHs9w2P8Izbq8IhLVSo=
+github.com/k0kubun/pp v2.3.0+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=
+github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
+github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
+github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f h1:dKccXx7xA56UNqOcFIbuqFjAWPVtP688j5QMgmo6OHU=
+github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f/go.mod h1:4rEELDSfUAlBSyUjPG0JnaNGjf13JySHFeRdD/3dLP0=
+github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/ktrysmt/go-bitbucket v0.6.4 h1:C8dUGp0qkwncKtAnozHCbbqhptefzEd1I0sfnuy9rYQ=
+github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4=
+github.com/ktrysmt/go-bitbucket v0.6.5 h1:+M4oFRZbzKH+Jt/eY3rKDPwyA5uvjY0KSJQwePGvvzQ=
+github.com/ktrysmt/go-bitbucket v0.6.5/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4=
+github.com/ktrysmt/go-bitbucket v0.6.6 h1:78sCjU8xMUvNGIBCRLSrNAjtbCk6ayVSwEr9n5LLp0U=
+github.com/ktrysmt/go-bitbucket v0.6.6/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4=
+github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8=
+github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
+github.com/logrusorgru/aurora/v3 v3.0.0 h1:R6zcoZZbvVcGMvDCKo45A9U/lzYyzl5NfYIvznmDfE4=
+github.com/logrusorgru/aurora/v3 v3.0.0/go.mod h1:vsR12bk5grlLvLXAYrBsb5Oc/N+LxAlxggSjiwMnCUc=
+github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
+github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
+github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
+github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
+github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
+github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
+github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
+github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
+github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
+github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
+github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
+github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
+github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
+github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
+github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
+github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
+github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
+github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
+github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
+github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
+github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s=
+github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
+github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
+github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
+github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
+github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
+github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
+github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
+github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
+github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/muesli/reflow v0.1.0 h1:oQdpLfO56lr5pgLvqD0TcjW85rDjSYSBVdiG1Ch1ddM=
+github.com/muesli/reflow v0.1.0/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
+github.com/muesli/termenv v0.6.0 h1:zxvzTBmo4ZcxhNGGWeMz+Tttm51eF5bmPjfy4MCRYlk=
+github.com/muesli/termenv v0.6.0/go.mod h1:SohX91w6swWA4AYU+QmPx+aSgXhWO0juiyID9UZmbpA=
+github.com/muesli/termenv v0.7.2 h1:r1raklL3uKE7rOvWgSenmEm2px+dnc33OTisZ8YR1fw=
+github.com/muesli/termenv v0.7.2/go.mod h1:ct2L5N2lmix82RaY3bMWwVu/jUFc9Ule0KGDCiKYPh8=
+github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
+github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
+github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
+github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
+github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
+github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
+github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
+github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
+github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
+github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
+github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
+github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
+github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
+github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
+github.com/shurcooL/githubv4 v0.0.0-20200802174311-f27d2ca7f6d5/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo=
+github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
+github.com/spance/go-callprivate v0.0.0-20151213012958-d8b9b5523668 h1:wSXAJdKyzJNaIvTDkThQd13R+3DiVKttdi1iOUa/6xw=
+github.com/spance/go-callprivate v0.0.0-20151213012958-d8b9b5523668/go.mod h1:YAHXixP6/M2dnkeoKo4MG9cK8i7OjSn0AFS0SmcBgFA=
+github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
+github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
+github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
+github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
+github.com/spf13/cobra v1.1.0 h1:aq3wCKjTPmzcNWLVGnsFVN4rflK7Uzn10F8/aw8MhdQ=
+github.com/spf13/cobra v1.1.0/go.mod h1:yk5b0mALVusDL5fMM6Rd1wgnoO5jUPhwsQ6LQAJTidQ=
+github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
+github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
+github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
+github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
+github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
+github.com/thoas/go-funk v0.7.0 h1:GmirKrs6j6zJbhJIficOsz2aAI7700KsU/5YrdHRM1Y=
+github.com/thoas/go-funk v0.7.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
+github.com/tidwall/pretty v1.0.2 h1:Z7S3cePv9Jwm1KwS0513MRaoUe3S01WPbLNV40pwWZU=
+github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
+github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
+github.com/wbrefvem/go-bitbucket v0.0.0-20190128183802-fc08fd046abb h1:KrmaSo+FHWBt1H652w/uerwzKvQqh4H7Jgyxm4hz2BQ=
+github.com/wbrefvem/go-bitbucket v0.0.0-20190128183802-fc08fd046abb/go.mod h1:Z91j2jYBApRjJ0zlXDCxPrrZR8ohkkd4g0n+Hqs1w0Q=
+github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
+github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
+github.com/yuin/goldmark v1.2.0 h1:WOOcyaJPlzb8fZ8TloxFe8QZkhOOJx87leDa9MIT9dc=
+github.com/yuin/goldmark v1.2.0/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
+go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
+go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
+go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
+go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmVhcMLU6v5fEb/ok4wyqtNU=
+golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
+golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
+golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
+golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
+golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
+golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
+golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
+golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
+golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
+golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180224232135-f6cff0780e54/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc=
+golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY=
+golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
+google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
+google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/appengine v1.0.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I=
+google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
+google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
+google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
+gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
+gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
+rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
diff --git a/internal/client.go b/internal/client.go
new file mode 100644
index 0000000..4bb4208
--- /dev/null
+++ b/internal/client.go
@@ -0,0 +1,6 @@
+package internal
+
+type Client struct {
+ Username string
+ Password string
+}
diff --git a/internal/commits.go b/internal/commits.go
new file mode 100644
index 0000000..9f80ef1
--- /dev/null
+++ b/internal/commits.go
@@ -0,0 +1,42 @@
+package internal
+
+import (
+ "github.com/ktrysmt/go-bitbucket"
+ "github.com/mitchellh/mapstructure"
+)
+
+type Commit struct {
+ Hash string `mapstructure:"hash"`
+ Type string `mapstructure:"type"`
+ Message string `mapstructure:"message"`
+ Parents []*Commit `mapstructure:"parents"`
+ Repository *Repository `mapstructure:"repository"`
+ Author map[string]interface{} `mapstructure:"author"`
+}
+
+type Commits struct {
+ Values []*Commit `mapstructure:"values"`
+}
+
+func (c Client) GetCommits(repoOrga string, repoSlug string, branchOrTag string, include string, exclude string) (*Commits, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opts := bitbucket.CommitsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ Branchortag: branchOrTag,
+ Exclude: exclude,
+ Include: include,
+ }
+
+ var commits Commits
+ response, err := client.Repositories.Commits.GetCommits(&opts)
+ if err != nil {
+ return nil, err
+ }
+ err = mapstructure.Decode(response, &commits)
+ if err != nil {
+ return nil, err
+ }
+ return &commits, nil
+}
diff --git a/internal/downloads.go b/internal/downloads.go
new file mode 100644
index 0000000..127fe82
--- /dev/null
+++ b/internal/downloads.go
@@ -0,0 +1,69 @@
+package internal
+
+import (
+ "path/filepath"
+
+ "github.com/ktrysmt/go-bitbucket"
+ "github.com/mitchellh/mapstructure"
+)
+
+type Downloads struct {
+ Values []Download `mapstructure:"values"`
+}
+
+type Download struct {
+ Name string `mapstructure:"name"`
+ Links map[string]Link `mapstructure:"links"`
+ Downloads int `mapstructure:"downloads"`
+ CreatedOn string `mapstructure:"created_on"`
+ User Account `mapstructure:"user"`
+ Type string `mapstructure:"type"`
+ Size int `mapstructure:"size"`
+}
+
+func (c Client) GetDownloads(repoOrga string, repoSlug string) (*Downloads, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opt := &bitbucket.DownloadsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ }
+
+ res, err := client.Repositories.Downloads.List(opt)
+ if err != nil {
+ return nil, err
+ }
+
+ downloads := &Downloads{}
+ err = mapstructure.Decode(res, downloads)
+ if err != nil {
+ return nil, err
+ }
+
+ return downloads, nil
+}
+
+func (c Client) UploadDownload(repoOrga string, repoSlug string, fpath string) (*Download, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opt := &bitbucket.DownloadsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ FilePath: fpath,
+ FileName: filepath.Base(fpath),
+ }
+
+ res, err := client.Repositories.Downloads.Create(opt)
+
+ if err != nil {
+ return nil, err
+ }
+
+ download := &Download{}
+ err = mapstructure.Decode(res, download)
+ if err != nil {
+ return nil, err
+ }
+
+ return download, nil
+}
diff --git a/internal/pr.go b/internal/pr.go
new file mode 100644
index 0000000..b321a48
--- /dev/null
+++ b/internal/pr.go
@@ -0,0 +1,254 @@
+package internal
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/ktrysmt/go-bitbucket"
+ "github.com/mitchellh/mapstructure"
+)
+
+type ListPullRequests struct {
+ Size int `mapstructure:"size"`
+ Page int `mapstructure:"page"`
+ PageLen int `mapstructure:"pagelen"`
+ Next string `mapstructure:"next"`
+ Previous string `mapstructure:"previous"`
+ Values []PullRequest `mapstructure:"values"`
+}
+
+type PullRequest struct {
+ ID int `mapstructure:"id"`
+ Title string `mapstructure:"title"`
+ State string `mapstructure:"state"`
+ Source Resource `mapstructure:"source"`
+ Destination Resource `mapstructure:"destination"`
+ Type string `mapstructure:"type"`
+ TaskCount int `mapstructure:"task_count"`
+ Description string `mapstructure:"description"`
+ Author Account `mapstructure:"author"`
+ CloseSourceBranch bool `mapstructure:"close_source_branch"`
+ CommentCount int `mapstructure:"comment_count"`
+ CreatedOn string `mapstructure:"created_on"`
+ MergeCommit Commit `mapstructure:"merge_commit"`
+ Reviewers []Account `mapstructure:"reviewers"`
+ Links map[string]Link `mapstructure:"links"`
+}
+
+type Resource struct {
+ Branch Branch `mapstructure:"branch"`
+ Commit Commit `mapstructure:"commit"`
+ Repository Repository `mapstructure:"repository"`
+}
+
+type Status struct {
+ Type string `mapstructure:"type"`
+ Links map[string]interface{} `mapstructure:"links"`
+ UUID string `mapstructure:"uuid"`
+ Key string `mapstructure:"key"`
+ Refname string `mapstructure:"refname"`
+ URL string `mapstructure:"url"`
+ State string `mapstructure:"state"`
+ Name string `mapstructure:"name"`
+ Description string `mapstructure:"description"`
+ CreatedOn string `mapstructure:"created_on"`
+ UpdatedOn string `mapstructure:"updated_on"`
+}
+
+type Statuses struct {
+ Size int `mapstructure:"size"`
+ Page int `mapstructure:"page"`
+ PageLen int `mapstructure:"pagelen"`
+ Next string `mapstructure:"next"`
+ Previous string `mapstructure:"previous"`
+ Values []Status `mapstructure:"values"`
+}
+
+func (c Client) PrList(repoOrga string, repoSlug string, states []string) (*ListPullRequests, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opt := &bitbucket.PullRequestsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ States: states,
+ }
+
+ response, err := client.Repositories.PullRequests.Gets(opt)
+ if err != nil {
+ return nil, err
+ }
+
+ var pullRequests ListPullRequests
+ err = mapstructure.Decode(response, &pullRequests)
+ if err != nil {
+ return nil, err
+ }
+
+ return &pullRequests, nil
+}
+
+func (c Client) GetPrIDBySourceBranch(repoOrga string, repoSlug string, sourceBranch string) (*ListPullRequests, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opt := &bitbucket.PullRequestsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ Query: fmt.Sprintf("source.branch.name = \"%s\"", sourceBranch),
+ }
+
+ response, err := client.Repositories.PullRequests.Gets(opt)
+ if err != nil {
+ return nil, err
+ }
+
+ var pullRequests ListPullRequests
+ err = mapstructure.Decode(response, &pullRequests)
+ if err != nil {
+ return nil, err
+ }
+
+ return &pullRequests, nil
+}
+
+func (c Client) PrView(repoOrga string, repoSlug string, id string) (*PullRequest, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opt := &bitbucket.PullRequestsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ ID: id,
+ }
+
+ response, err := client.Repositories.PullRequests.Get(opt)
+ if err != nil {
+ return nil, err
+ }
+
+ var pullRequest PullRequest
+ err = mapstructure.Decode(response, &pullRequest)
+ if err != nil {
+ return nil, err
+ }
+ return &pullRequest, nil
+}
+
+func (c Client) PrCreate(repoOrga string, repoSlug string, sourceBranch string, destinationBranch string, title string, body string, reviewers []string) (*PullRequest, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opt := &bitbucket.PullRequestsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ SourceBranch: sourceBranch,
+ DestinationBranch: destinationBranch,
+ Title: title,
+ Description: body,
+ Reviewers: reviewers,
+ }
+
+ response, err := client.Repositories.PullRequests.Create(opt)
+
+ if err != nil {
+ return nil, err
+ }
+
+ var pullRequest PullRequest
+ err = mapstructure.Decode(response, &pullRequest)
+ if err != nil {
+ return nil, err
+ }
+ return &pullRequest, nil
+}
+
+func (c Client) PrStatuses(repoOrga string, repoSlug string, id string) (*Statuses, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+ opt := &bitbucket.PullRequestsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ ID: id,
+ }
+
+ response, err := client.Repositories.PullRequests.Statuses(opt)
+ if err != nil {
+ return nil, err
+ }
+
+ var statuses Statuses
+ err = mapstructure.Decode(response, &statuses)
+ if err != nil {
+ return nil, err
+ }
+
+ return &statuses, nil
+
+}
+
+func (c Client) PrDefaultTitleAndBody(repoOrga string, repoSlug string, sourceBranch string, destinationBranch string) (string, string, error) {
+ commits, err := c.GetCommits(repoOrga, repoSlug, sourceBranch, "", destinationBranch)
+ if err != nil {
+ return "", "", err
+ }
+ if len(commits.Values) == 0 {
+ return sourceBranch, "", nil
+ } else if len(commits.Values) == 1 {
+ commit := commits.Values[0]
+
+ split := strings.SplitN(commit.Message, "\n", 2)
+ if len(split) == 2 {
+ return split[0], strings.TrimSpace(split[1]), nil
+ } else if len(split) == 1 {
+ return split[0], "", nil
+ }
+
+ return sourceBranch, "", nil
+ } else {
+ var sb strings.Builder
+ for _, commit := range commits.Values {
+ sb.WriteString("- " + strings.Split(commit.Message, "\n")[0] + "\n")
+ }
+
+ return sourceBranch, sb.String(), nil
+ }
+}
+
+func (c Client) PrCommits(repoOrga string, repoSlug string, id string) (*Commits, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opt := &bitbucket.PullRequestsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ ID: id,
+ }
+ response, err := client.Repositories.PullRequests.Commits(opt)
+ if err != nil {
+ return nil, err
+ }
+
+ var commits Commits
+ err = mapstructure.Decode(response, &commits)
+ if err != nil {
+ return nil, err
+ }
+ return &commits, nil
+}
+
+func (c Client) PrMerge(repoOrga string, repoSlug string, id string) (*PullRequest, error) {
+ client := bitbucket.NewBasicAuth(c.Username, c.Password)
+
+ opt := &bitbucket.PullRequestsOptions{
+ Owner: repoOrga,
+ RepoSlug: repoSlug,
+ ID: id,
+ }
+
+ response, err := client.Repositories.PullRequests.Merge(opt)
+ if err != nil {
+ return nil, err
+ }
+
+ var pullRequest PullRequest
+ err = mapstructure.Decode(response, &pullRequest)
+ if err != nil {
+ return nil, err
+ }
+ return &pullRequest, nil
+}
diff --git a/internal/repository.go b/internal/repository.go
new file mode 100644
index 0000000..3550f85
--- /dev/null
+++ b/internal/repository.go
@@ -0,0 +1,81 @@
+package internal
+
+import (
+ "context"
+ "encoding/json"
+ "time"
+
+ "github.com/mitchellh/mapstructure"
+ "github.com/wbrefvem/go-bitbucket"
+)
+
+type Repository struct {
+ Links map[string]interface{} `mapstructure:"Links"`
+ UUID string `mapstructure:"Uuid"`
+ FullName string `mapstructure:"FullName"`
+ IsPrivate bool `mapstructure:"IsPrivate"`
+ Parent *Repository `mapstructure:"Parent"`
+ Owner *Account `mapstructure:"Owner"`
+ Name string `mapstructure:"Name"`
+ Description string `mapstructure:"Description"`
+ CreatedOn time.Time `mapstructure:"CreatedOn"`
+ UpdatedOn time.Time `mapstructure:"UpdatedOn"`
+ Size int `mapstructure:"Size"`
+ Language string `mapstructure:"Language"`
+ HasIssues bool `mapstructure:"HasIssues"`
+ HasWiki bool `mapstructure:"HasWiki"`
+ ForkPolicy string `mapstructure:"ForkPolicy"`
+ MainBranch *Branch `mapstructure:"Mainbranch"`
+ // Project Project `mapstructure:"project"`
+}
+
+type DefaultReviewers struct {
+ PageLen int `json:"pagelen"`
+ Values []*Account `json:"values"`
+ Page int `json:"page"`
+ Size int `json:"size"`
+ Next string `json:"next"`
+}
+
+func (c Client) RepositoryGet(repoOrga string, repoSlug string) (*Repository, error) {
+ client := bitbucket.NewAPIClient(bitbucket.NewConfiguration())
+ response, _, err := client.RepositoriesApi.RepositoriesUsernameRepoSlugGet(
+ context.WithValue(context.Background(), bitbucket.ContextBasicAuth, bitbucket.BasicAuth{
+ UserName: c.Username,
+ Password: c.Password,
+ }), repoOrga, repoSlug)
+
+ if err != nil {
+ return nil, err
+ }
+
+ var repo Repository
+ err = mapstructure.Decode(response, &repo)
+ if err != nil {
+ return nil, err
+ }
+ return &repo, nil
+}
+
+func (c Client) GetDefaultReviewers(repoOrga string, repoSlug string) (*DefaultReviewers, error) {
+ client := bitbucket.NewAPIClient(bitbucket.NewConfiguration())
+
+ response, err := client.PullrequestsApi.RepositoriesUsernameRepoSlugDefaultReviewersGet(
+ context.WithValue(context.Background(), bitbucket.ContextBasicAuth, bitbucket.BasicAuth{
+ UserName: c.Username,
+ Password: c.Password,
+ }), repoOrga, repoSlug)
+
+ if err != nil {
+ return nil, err
+ }
+ defer response.Body.Close()
+
+ defaultReviewers := DefaultReviewers{}
+ err = json.NewDecoder(response.Body).Decode(&defaultReviewers)
+ if err != nil {
+ return nil, err
+ }
+
+ return &defaultReviewers, nil
+}
diff --git a/internal/shared.go b/internal/shared.go
new file mode 100644
index 0000000..060126f
--- /dev/null
+++ b/internal/shared.go
@@ -0,0 +1,17 @@
+package internal
+
+type Link struct {
+ Href string `mapstructure:"href"`
+}
+
+type Branch struct {
+ Name string `mapstructure:"name"`
+}
+
+type Account struct {
+ AccountID string `mapstructure:"account_id"`
+ DisplayName string `mapstructure:"display_name"`
+ Nickname string `mapstructure:"nickname"`
+ Type string `mapstructure:"user"`
+ UUID string `mapstructure:"uuid"`
+}
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..1977116
--- /dev/null
+++ b/main.go
@@ -0,0 +1,15 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/craftamap/bb/cmd"
+)
+
+func main() {
+ if err := cmd.Execute(); err != nil {
+ fmt.Println(err)
+ os.Exit(-1)
+ }
+}