1
0
mirror of https://gitea.com/jolheiser/sip synced 2024-11-22 11:41:59 +01:00

Update repo info (#24)

Add repo info

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Reviewed-on: https://gitea.com/jolheiser/sip/pulls/24
This commit is contained in:
John Olheiser 2020-09-16 03:54:48 +00:00
parent 8db0c08253
commit 3e49adf604
2 changed files with 10 additions and 38 deletions

@ -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
}

@ -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