1
0
mirror of https://github.com/Luzifer/repo-template.git synced 2024-09-20 09:32:58 +00:00

Add option to expand repo to contain all infos

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-02-07 23:45:35 +01:00
parent 7cdda8bec3
commit 6d09db7032
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E

18
main.go
View File

@ -20,6 +20,7 @@ import (
var (
cfg = struct {
ExpandMatches bool `flag:"expand-matches" default:"false" description:"Replace matched repos with their full version"`
Filters []string `flag:"filter,f" default:"" description:"Filters to match the repos against"`
GithubToken string `flag:"token" default:"" env:"GITHUB_TOKEN" description:"Token to access Github API"`
LogLevel string `flag:"log-level" default:"info" description:"Log level for output (debug, info, warn, error, fatal)"`
@ -100,6 +101,12 @@ func main() {
continue
}
if cfg.ExpandMatches {
if err := expandRepo(repo); err != nil {
log.WithError(err).Error("Unable to expand repo")
}
}
log.WithFields(log.Fields{
"repo": *repo.FullName,
"private": *repo.Private,
@ -113,6 +120,17 @@ func main() {
}
}
func expandRepo(repo *github.Repository) error {
ctx := context.Background()
r, _, err := client.Repositories.Get(ctx, *repo.Owner.Login, *repo.Name)
if err != nil {
return err
}
repo = r
return nil
}
func fetchRepos() ([]*github.Repository, error) {
var (
ctx = context.Background()