mirror of
https://gitea.com/jolheiser/sip
synced 2024-11-26 07:33:48 +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:
parent
8db0c08253
commit
3e49adf604
18
cmd/repo.go
18
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
|
||||
}
|
||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user