mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Simplified Github
This commit is contained in:
committed by
Chris Cummer
parent
7958b76b45
commit
e8d6d3e49b
@@ -21,13 +21,13 @@ func NewClient() *Client {
|
||||
return &client
|
||||
}
|
||||
|
||||
func (client *Client) PullRequests(orgName string, repoName string) ([]*ghb.PullRequest, error) {
|
||||
func (client *Client) PullRequests(owner string, repoName string) ([]*ghb.PullRequest, error) {
|
||||
oauthClient := client.oauthClient()
|
||||
github := ghb.NewClient(oauthClient)
|
||||
|
||||
opts := &ghb.PullRequestListOptions{}
|
||||
|
||||
prs, _, err := github.PullRequests.List(context.Background(), orgName, repoName, opts)
|
||||
prs, _, err := github.PullRequests.List(context.Background(), owner, repoName, opts)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -36,11 +36,11 @@ func (client *Client) PullRequests(orgName string, repoName string) ([]*ghb.Pull
|
||||
return prs, nil
|
||||
}
|
||||
|
||||
func (client *Client) Repository(orgName string, repoName string) (*ghb.Repository, error) {
|
||||
func (client *Client) Repository(owner string, repoName string) (*ghb.Repository, error) {
|
||||
oauthClient := client.oauthClient()
|
||||
github := ghb.NewClient(oauthClient)
|
||||
|
||||
repo, _, err := github.Repositories.Get(context.Background(), orgName, repoName)
|
||||
repo, _, err := github.Repositories.Get(context.Background(), owner, repoName)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -35,15 +35,9 @@ func (widget *Widget) Refresh() {
|
||||
}
|
||||
|
||||
client := NewClient()
|
||||
prs, _ := client.PullRequests(Config.UString("wtf.github.owner"), Config.UString("wtf.github.repo"))
|
||||
|
||||
repo, _ := client.Repository(Config.UString("wtf.github.organization"), Config.UString("wtf.github.repo"))
|
||||
org := *repo.Organization
|
||||
|
||||
prs, _ := client.PullRequests(Config.UString("wtf.github.organization"), Config.UString("wtf.github.repo"))
|
||||
|
||||
title := fmt.Sprintf("[green]%s - %s[white]", *org.Login, *repo.Name)
|
||||
|
||||
widget.View.SetTitle(fmt.Sprintf(" Github: %s ", title))
|
||||
widget.View.SetTitle(fmt.Sprintf(" Github: %s ", widget.title()))
|
||||
widget.RefreshedAt = time.Now()
|
||||
|
||||
str := " [red]Open Review Requests[white]\n"
|
||||
@@ -113,3 +107,7 @@ func (widget *Widget) openPRs(prs []*ghb.PullRequest) string {
|
||||
|
||||
return " [grey]none[white]\n"
|
||||
}
|
||||
|
||||
func (widget *Widget) title() string {
|
||||
return fmt.Sprintf("[green]%s - %s[white]", Config.UString("wtf.github.owner"), Config.UString("wtf.github.repo"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user