mirror of
https://github.com/Luzifer/repo-template.git
synced 2024-12-23 04:31:20 +00:00
Add option to expand repo to contain all infos
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
7cdda8bec3
commit
6d09db7032
1 changed files with 18 additions and 0 deletions
18
main.go
18
main.go
|
@ -20,6 +20,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cfg = struct {
|
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"`
|
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"`
|
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)"`
|
LogLevel string `flag:"log-level" default:"info" description:"Log level for output (debug, info, warn, error, fatal)"`
|
||||||
|
@ -100,6 +101,12 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.ExpandMatches {
|
||||||
|
if err := expandRepo(repo); err != nil {
|
||||||
|
log.WithError(err).Error("Unable to expand repo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"repo": *repo.FullName,
|
"repo": *repo.FullName,
|
||||||
"private": *repo.Private,
|
"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) {
|
func fetchRepos() ([]*github.Repository, error) {
|
||||||
var (
|
var (
|
||||||
ctx = context.Background()
|
ctx = context.Background()
|
||||||
|
|
Loading…
Reference in a new issue