Skip to content

Commit

Permalink
add drone repo sync command
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed May 15, 2018
1 parent c313ab3 commit 800d694
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[[constraint]]
name = "github.com/drone/drone-go"
revision = "9b0e0d8b9a0e1ee7e24eb12f3d2f617501a1dcd0"
revision = "7f20e6c113d3ffa2af80401c4eba7d510c8fd875"

[[constraint]]
branch = "master"
Expand Down
1 change: 1 addition & 0 deletions drone/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ var Command = cli.Command{
repoRemoveCmd,
repoRepairCmd,
repoChownCmd,
repoSyncCmd,
},
}
49 changes: 49 additions & 0 deletions drone/repo/repo_sync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package repo

import (
"os"
"text/template"

"github.com/drone/drone-cli/drone/internal"
"github.com/urfave/cli"
)

var repoSyncCmd = cli.Command{
Name: "sync",
Usage: "synchronize the repository list",
ArgsUsage: " ",
Action: repoSync,
Flags: []cli.Flag{
cli.StringFlag{
Name: "format",
Usage: "format output",
Value: tmplRepoList,
},
},
}

func repoSync(c *cli.Context) error {
client, err := internal.NewClient(c)
if err != nil {
return err
}

repos, err := client.RepoListOpts(true, true)
if err != nil || len(repos) == 0 {
return err
}

tmpl, err := template.New("_").Parse(c.String("format") + "\n")
if err != nil {
return err
}

org := c.String("org")
for _, repo := range repos {
if org != "" && org != repo.Owner {
continue
}
tmpl.Execute(os.Stdout, repo)
}
return nil
}
9 changes: 9 additions & 0 deletions vendor/github.com/drone/drone-go/drone/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions vendor/github.com/drone/drone-go/drone/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 800d694

Please sign in to comment.