mirror of
https://gitea.com/jolheiser/sip
synced 2024-11-22 19:51:58 +01:00
448e12ce38
Ran imp Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: jolheiser <john.olheiser@gmail.com> Reviewed-on: https://gitea.com/jolheiser/sip/pulls/17
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"gitea.com/jolheiser/sip/modules/sdk"
|
|
|
|
"code.gitea.io/sdk/gitea"
|
|
"github.com/urfave/cli/v2"
|
|
"go.jolheiser.com/beaver"
|
|
"go.jolheiser.com/beaver/color"
|
|
)
|
|
|
|
var Repo = cli.Command{
|
|
Name: "repo",
|
|
Usage: "Commands for interacting with a Gitea repository",
|
|
Action: doRepo,
|
|
Subcommands: []*cli.Command{
|
|
&RepoCreate,
|
|
},
|
|
}
|
|
|
|
func doRepo(ctx *cli.Context) error {
|
|
client, err := getClient(ctx, false)
|
|
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
|
|
}
|
|
|
|
var issueCount, pullCount int
|
|
for _, issue := range issues {
|
|
if issue.PullRequest != nil {
|
|
pullCount++
|
|
continue
|
|
}
|
|
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.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))))
|
|
|
|
return nil
|
|
}
|