diff --git a/cmd/repo.go b/cmd/repo.go index a6da644..0cd8759 100644 --- a/cmd/repo.go +++ b/cmd/repo.go @@ -26,6 +26,11 @@ func doRepo(ctx *cli.Context) error { return err } + repo, _, err := client.GetRepo(ctx.String("owner"), ctx.String("repo")) + if err != nil { + return err + } + issues, err := sdk.GetIssues(client, ctx.String("owner"), ctx.String("repo"), gitea.ListIssueOption{State: "open"}) if err != nil { return err @@ -40,19 +45,16 @@ func doRepo(ctx *cli.Context) error { issueCount++ } - forks, err := sdk.GetForks(client, ctx.String("owner"), ctx.String("repo")) - if err != nil { - return err - } - yellow := color.New(color.FgYellow) - beaver.Infof("Repository: %s", yellow.Format(ctx.String("owner")+"/"+ctx.String("repo"))) - beaver.Infof("URL: %s", yellow.Format(ctx.String("url")+"/"+ctx.String("owner")+"/"+ctx.String("repo"))) + beaver.Infof("Repository: %s", yellow.Format(repo.FullName)) + beaver.Infof("URL: %s", yellow.Format(repo.HTMLURL)) beaver.Info() beaver.Infof("Open Issues: %s", yellow.Format(strconv.Itoa(issueCount))) beaver.Infof("Open Pulls: %s", yellow.Format(strconv.Itoa(pullCount))) beaver.Info() - beaver.Infof("Forks: %s", yellow.Format(strconv.Itoa(len(forks)))) + beaver.Infof("Forks: %s", yellow.Format(strconv.Itoa(repo.Forks))) + beaver.Infof("Stars: %s", yellow.Format(strconv.Itoa(repo.Stars))) + beaver.Infof("Watchers: %s", yellow.Format(strconv.Itoa(repo.Watchers))) return nil } diff --git a/modules/sdk/repo.go b/modules/sdk/repo.go deleted file mode 100644 index 471ac67..0000000 --- a/modules/sdk/repo.go +++ /dev/null @@ -1,30 +0,0 @@ -package sdk - -import "code.gitea.io/sdk/gitea" - -// GetForks returns all of a repository's forks -func GetForks(client *gitea.Client, owner, repo string) ([]*gitea.Repository, error) { - forks := make([]*gitea.Repository, 0) - p := 1 - for { - list, _, err := client.ListForks(owner, repo, gitea.ListForksOptions{ - ListOptions: gitea.ListOptions{ - Page: p, - PageSize: 100, - }, - }) - if err != nil { - return forks, err - } - p++ - forks = append(forks, list...) - - if len(list) == 0 { - break - } - } - return forks, nil -} - -// TODO List Stargazers when SDK supports -// TODO List Watchers when SDK supports