diff --git a/.gitignore b/.gitignore index 8120240..3675f62 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /vendor .idea/ +.cache.json diff --git a/main.go b/main.go index 9eeb2c6..a38ac85 100644 --- a/main.go +++ b/main.go @@ -16,11 +16,11 @@ var ( ) type Cache struct { - token string `json:token` - baseURL string `json:baseURL` - orgName string `json:orgName` - repoExclude string `json:repoExclude` - pullBaseBranch string `json:pullBaseBranch` + token string `json:"token"` + baseURL string `json:"baseURL"` + orgName string `json:"orgName"` + repoExclude string `json:"repoExclude"` + pullBaseBranch string `json:"pullBaseBranch"` } func loadCache() (cache *Cache) { @@ -49,7 +49,7 @@ func saveCache(cache *Cache) { if err != nil { fmt.Printf("ERROR: marshal cache: %v\n", err) } - err = ioutil.WriteFile(".cache.json", data, 0666) + err = ioutil.WriteFile(".cache.json", data, 0600) if err != nil { fmt.Printf("ERROR: save cache: %v\n", err) } @@ -102,8 +102,9 @@ func main() { var repoList []*gitlab.Project var page = 1 + fmt.Printf("Retrieving repository list...\n") for { - fmt.Printf("Get Repo List Page %d", page) + fmt.Printf("%d", page) repos, _, err := client.Groups.ListGroupProjects(org.ID, &gitlab.ListGroupProjectsOptions{ ListOptions: gitlab.ListOptions{PerPage: 10, Page: page}, Archived: optBool(false), @@ -121,6 +122,7 @@ func main() { page++ } + fmt.Println() for i := range repoList { if !excludeRule.Match(repoList[i].Name) { @@ -140,7 +142,12 @@ func threatRepo(baseBranchRule glob.Glob, client *gitlab.Client, repo *gitlab.Pr error(10, "Could not obtain branch list from '%s': %v\n", repo.Name, err) } - fmt.Printf(" found %d branches\n", len(branchList)) + fmt.Printf(" found %d branches:", len(branchList)) + fmt.Printf(" ") + for _, b := range branchList { + fmt.Printf("'%s' ", b.Name) + } + fmt.Println() for _, baseBranch := range branchList { if baseBranchRule.Match(baseBranch.Name) && !baseBranch.Default {