1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

using just the pr/issue number as highlighted

This commit is contained in:
Joel Valentine 2019-08-31 15:04:34 +01:00
parent 55937c4c40
commit ccaca4f1c0
3 changed files with 18 additions and 13 deletions

View File

@ -2,8 +2,6 @@ package github
import (
"fmt"
"strconv"
"net/url"
"github.com/google/go-github/v26/github"
)
@ -38,7 +36,6 @@ func (widget *Widget) content() (string, string, bool) {
func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string {
prs := repo.myPullRequests(username, widget.settings.enableStatus)
u, _ := url.Parse(*repo.RemoteRepo.HTMLURL + "/pull/")
numSelections := widget.GetSelected()
if len(prs) == 0 {
@ -47,12 +44,12 @@ func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) s
str := ""
for _, pr := range prs {
// str += fmt.Sprintf(` %s[green]%4d[white] %s\n`, widget.mergeString(pr), *pr.Number, *pr.Title)
str += fmt.Sprintf(`["%d"]%s[""]`, numSelections, u.String() + strconv.Itoa(*pr.Number))
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, numSelections, *pr.Number, *pr.Title)
str += "\n"
numSelections++
}
widget.SetItemCount(numSelections)
return str
}
@ -60,7 +57,6 @@ func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) s
func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPage int) string {
res := repo.customIssueQuery(filter, perPage)
u, _ := url.Parse(*repo.RemoteRepo.HTMLURL + "/pull/")
numSelections := widget.GetSelected()
if res == nil {
@ -73,8 +69,7 @@ func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPag
str := ""
for _, issue := range res.Issues {
// str += fmt.Sprintf(" [green]%4d[white] %s\n", *issue.Number, *issue.Title)
str += fmt.Sprintf(`["%d"]%s[""]`, numSelections, u.String() + strconv.Itoa(*issue.Number))
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, numSelections, *issue.Number, *issue.Title)
str += "\n"
numSelections++
}
@ -87,15 +82,21 @@ func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPag
func (widget *Widget) displayMyReviewRequests(repo*GithubRepo, username string) string {
prs := repo.myReviewRequests(username)
numSelections := widget.GetSelected()
if len(prs) == 0 {
return " [grey]none[white]\n"
}
str := ""
for _, pr := range prs {
str += fmt.Sprintf(" [green]%4d[white] %s\n", *pr.Number, *pr.Title)
str += fmt.Sprintf(`[green]["%d"]%4d[""][white] %s`, numSelections, *pr.Number, *pr.Title)
str += "\n"
numSelections++
}
widget.SetItemCount(numSelections)
return str
}

View File

@ -7,13 +7,16 @@ import (
func (widget *Widget) initializeKeyboardControls() {
widget.InitializeCommonControls(widget.Refresh)
widget.SetKeyboardChar("j", widget.Next, "Select next item")
widget.SetKeyboardChar("k", widget.Prev, "Select previous item")
widget.SetKeyboardChar("l", widget.NextSource, "Select next source")
widget.SetKeyboardChar("h", widget.PrevSource, "Select previous source")
widget.SetKeyboardChar("o", widget.openRepo, "Open item in browser")
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next source")
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select next source")
widget.SetKeyboardKey(tcell.KeyDown, widget.Next, "Select next item")
widget.SetKeyboardKey(tcell.KeyUp, widget.Prev, "Select previous item")
widget.SetKeyboardKey(tcell.KeyRight, widget.NextSource, "Select next source")
widget.SetKeyboardKey(tcell.KeyLeft, widget.PrevSource, "Select previous source")
widget.SetKeyboardKey(tcell.KeyEnter, widget.openPr, "Open item in browser")
widget.SetKeyboardKey(tcell.KeyBackspace, widget.openRepo, "Open item in browser")
}

View File

@ -130,7 +130,8 @@ func (widget *Widget) currentGithubRepo() *GithubRepo {
func (widget *Widget) openPr() {
currentSelection := widget.View.GetHighlights()
if widget.Selected >= 0 && currentSelection[0] != "" {
utils.OpenFile(widget.View.GetRegionText(currentSelection[0]))
url := (*widget.currentGithubRepo().RemoteRepo.HTMLURL + "/pull/" + widget.View.GetRegionText(currentSelection[0]))
utils.OpenFile(url)
}
}