diff --git a/cloner/cloner_test.go b/cloner/cloner_test.go index 4632ab7..4f5b9d5 100644 --- a/cloner/cloner_test.go +++ b/cloner/cloner_test.go @@ -1,16 +1,16 @@ package cloner import ( - "testing" - "github.com/stretchr/testify/assert" "github.com/steinfletcher/github-org-clone/github" + "github.com/stretchr/testify/assert" + "testing" ) func TestGetTeamId(t *testing.T) { teams := []github.Team{ - {Name:"team1", Id:1}, - {Name:"team2", Id:51}, - {Name:"team3", Id:101}, + {Name: "team1", Id: 1}, + {Name: "team2", Id: 51}, + {Name: "team3", Id: 101}, } _, id := teamId(teams, "team3") @@ -20,7 +20,7 @@ func TestGetTeamId(t *testing.T) { func TestGetTeamIdErrorsIfNotFound(t *testing.T) { teams := []github.Team{ - {Name:"team1", Id:1}, + {Name: "team1", Id: 1}, } err, _ := teamId(teams, "team3") diff --git a/github/github.go b/github/github.go index 9905792..70c1390 100644 --- a/github/github.go +++ b/github/github.go @@ -1,13 +1,13 @@ package github import ( - "net/http" + "encoding/json" + "errors" "fmt" "io/ioutil" - "time" - "encoding/json" + "net/http" "strings" - "errors" + "time" ) func NewGithub(username string, apiToken string) Github { diff --git a/github/github_test.go b/github/github_test.go index ae2296b..45728b5 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -1,9 +1,9 @@ package github import ( - "testing" "github.com/stretchr/testify/assert" "gopkg.in/h2non/gock.v1" + "testing" ) func TestFetchTeams(t *testing.T) { @@ -52,4 +52,4 @@ func teamReposResp(page string, linkHeader string, file string) { Reply(200). SetHeader("Link", linkHeader). File("../testdata/" + file) -} \ No newline at end of file +} diff --git a/main.go b/main.go index ac674fc..0eadb7e 100644 --- a/main.go +++ b/main.go @@ -1,13 +1,13 @@ package main import ( - "os" - "github.com/urfave/cli" + "fmt" + "github.com/steinfletcher/github-org-clone/cloner" "github.com/steinfletcher/github-org-clone/github" "github.com/steinfletcher/github-org-clone/shell" - "github.com/steinfletcher/github-org-clone/cloner" + "github.com/urfave/cli" "log" - "fmt" + "os" "time" ) @@ -28,30 +28,30 @@ func main() { app.Description = "A simple cli to clone all the repos managed by a github team" app.Metadata = map[string]interface{}{ "commit": commit, - "date": date, + "date": date, } - app.Flags = []cli.Flag { + app.Flags = []cli.Flag{ cli.StringFlag{ - Name: "org, o", + Name: "org, o", Usage: "github organisation", }, cli.StringFlag{ - Name: "team, t", + Name: "team, t", Usage: "github team", }, cli.StringFlag{ - Name: "username, u", - Usage: "github username", + Name: "username, u", + Usage: "github username", EnvVar: "GITHUB_USER,GITHUB_USERNAME", }, cli.StringFlag{ - Name: "token, k", - Usage: "github personal access token", + Name: "token, k", + Usage: "github personal access token", EnvVar: "GITHUB_TOKEN,GITHUB_API_KEY,GITHUB_PERSONAL_ACCESS_TOKEN", }, cli.StringFlag{ - Name: "dir, d", + Name: "dir, d", Usage: "directory to clone into. Defaults to the org name or org/team name if defined", }, } diff --git a/makefile b/makefile index 9ef9d37..d101b85 100644 --- a/makefile +++ b/makefile @@ -8,3 +8,5 @@ build: install: go install + +all: test build install diff --git a/shell/shell.go b/shell/shell.go index 5b342e1..53e1cd4 100644 --- a/shell/shell.go +++ b/shell/shell.go @@ -1,15 +1,15 @@ package shell import ( - "os/exec" "fmt" + "os/exec" ) type Shell interface { Exec(cmd string, args []string) error } -type shell struct {} +type shell struct{} func NewShell() Shell { return &shell{} @@ -24,4 +24,4 @@ func (s *shell) Exec(cmd string, args []string) error { fmt.Printf("%s", out) } return nil -} \ No newline at end of file +}