mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Widget titles can now be specified in the config file via a 'title' key. Example: wtf: mods: todo: title: Tada which can include emoji. No need to force everyone to look at my emoji, now they can define their own.
76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
package github
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/senorprogrammer/wtf/wtf"
|
|
)
|
|
|
|
func (widget *Widget) display() {
|
|
|
|
repo := widget.currentGithubRepo()
|
|
if repo == nil {
|
|
fmt.Fprintf(widget.View, "%s", " Github repo data is unavailable (1)")
|
|
return
|
|
}
|
|
|
|
widget.View.SetTitle(fmt.Sprintf("%s- %s", widget.Name, widget.title(repo)))
|
|
|
|
str := wtf.SigilStr(len(widget.GithubRepos), widget.Idx, widget.View) + "\n"
|
|
str = str + " [red]Stats[white]\n"
|
|
str = str + widget.displayStats(repo)
|
|
str = str + "\n"
|
|
str = str + " [red]Open Review Requests[white]\n"
|
|
str = str + widget.displayMyReviewRequests(repo, Config.UString("wtf.mods.github.username"))
|
|
str = str + "\n"
|
|
str = str + " [red]My Pull Requests[white]\n"
|
|
str = str + widget.displayMyPullRequests(repo, Config.UString("wtf.mods.github.username"))
|
|
|
|
widget.View.SetText(str)
|
|
}
|
|
|
|
func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string {
|
|
prs := repo.myPullRequests(username)
|
|
|
|
if len(prs) == 0 {
|
|
return " [grey]none[white]\n"
|
|
}
|
|
|
|
str := ""
|
|
for _, pr := range prs {
|
|
str = str + fmt.Sprintf(" [green]%4d[white] %s\n", *pr.Number, *pr.Title)
|
|
}
|
|
|
|
return str
|
|
}
|
|
|
|
func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string) string {
|
|
prs := repo.myReviewRequests(username)
|
|
|
|
if len(prs) == 0 {
|
|
return " [grey]none[white]\n"
|
|
}
|
|
|
|
str := ""
|
|
for _, pr := range prs {
|
|
str = str + fmt.Sprintf(" [green]%4d[white] %s\n", *pr.Number, *pr.Title)
|
|
}
|
|
|
|
return str
|
|
}
|
|
|
|
func (widget *Widget) displayStats(repo *GithubRepo) string {
|
|
str := fmt.Sprintf(
|
|
" PRs: %d Issues: %d Stars: %d\n",
|
|
repo.PullRequestCount(),
|
|
repo.IssueCount(),
|
|
repo.StarCount(),
|
|
)
|
|
|
|
return str
|
|
}
|
|
|
|
func (widget *Widget) title(repo *GithubRepo) string {
|
|
return fmt.Sprintf("[green]%s - %s[white]", repo.Owner, repo.Name)
|
|
}
|