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:
parent
55937c4c40
commit
ccaca4f1c0
@ -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++
|
||||
}
|
||||
@ -84,18 +79,24 @@ func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPag
|
||||
return str
|
||||
}
|
||||
|
||||
func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string) string {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user