sip/cmd/repo.go
John Olheiser 5ecbcde518
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Change to vanity URL (#37)
Fix YAML

New changes, generate docs, and add Drone for main

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

Merge branch 'master' of gitea.com:jolheiser/sip into vanity

Change to vanity URL

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

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Reviewed-on: #37
2020-09-21 19:21:07 +00:00

62 lines
1.4 KiB
Go

package cmd
import (
"strconv"
"go.jolheiser.com/sip/flag"
"go.jolheiser.com/sip/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(_ *cli.Context) error {
client, err := getClient(false)
if err != nil {
return err
}
repo, _, err := client.GetRepo(flag.Owner, flag.Repo)
if err != nil {
return err
}
issues, err := sdk.GetIssues(client, flag.Owner, flag.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++
}
yellow := color.New(color.FgYellow)
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(repo.Forks)))
beaver.Infof("Stars: %s", yellow.Format(strconv.Itoa(repo.Stars)))
beaver.Infof("Watchers: %s", yellow.Format(strconv.Itoa(repo.Watchers)))
return nil
}