wtfutil / wtf

The personal information dashboard for your terminal
http://wtfutil.com
Mozilla Public License 2.0
15.89k stars 805 forks source link

Make GitHub module `repositories` setting optional #1312

Open pcrockett opened 2 years ago

pcrockett commented 2 years ago

What should it do?

I have access to a lot of repositories, and I want to use my dashboard to display all relevant GitHub information. I want a list of open pull requests, issues, etc. for any of my dozens of repositories.

I got this working with the customQueries setting. I use filter to control what I see in my dashboard rather than specifying a huge list of repos. So that means I really don't need the repositories setting at all.

I tried excluding the repositories setting from my config, however that causes wtfutil to crash:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0xcd7056]

goroutine 1 [running]:
github.com/rivo/tview.(*Application).Run.func1()
        /Users/chris/go/pkg/mod/github.com/rivo/tview@v0.0.0-20200108161608-1316ea7a4b35/application.go:149 +0x4d
panic({0x18b08e0, 0x302e4c0})
        /opt/homebrew/opt/go/libexec/src/runtime/panic.go:1038 +0x215
github.com/wtfutil/wtf/modules/github.(*Repo).myReviewRequests(0xc00011b8c0, {0xc0006a1da0, 0x9})
        /Users/chris/Projects/wtf/modules/github/github_repo.go:176 +0x36
github.com/wtfutil/wtf/modules/github.(*Widget).content(0xc000020900)
        /Users/chris/Projects/wtf/modules/github/display.go:26 +0x17d
github.com/wtfutil/wtf/view.(*TextWidget).Redraw.func1()
        /Users/chris/Projects/wtf/view/text_widget.go:49 +0x2a
github.com/rivo/tview.(*Application).QueueUpdateDraw.func1()
        /Users/chris/go/pkg/mod/github.com/rivo/tview@v0.0.0-20200108161608-1316ea7a4b35/application.go:493 +0x26
github.com/rivo/tview.(*Application).Run(0xc00079f500)
        /Users/chris/go/pkg/mod/github.com/rivo/tview@v0.0.0-20200108161608-1316ea7a4b35/application.go:253 +0x5e8
github.com/wtfutil/wtf/app.(*WtfApp).Run(0xc00084ff08)
        /Users/chris/Projects/wtf/app/wtf_app.go:80 +0x2e
main.main()
        /Users/chris/Projects/wtf/main.go:64 +0x42a

As a workaround, I added a single repository that I don't care about to my repositories list, and everything works correctly... except that repository name shows up in my dashboard title. Which is not terribly ideal.

Is there a reason we need to specify a list of repos? Can we make it optional?

pcrockett commented 2 years ago

Here's the relevant portion of my config that shows what I'm doing:

    github:
      # apiKey: "Use WTF_GITHUB_TOKEN env variable instead"
      title: "GitHub"
      showStats: false
      showMyPullRequests: false
      showOpenReviewRequests: false
      customQueries:
        myPRs:
          title: "My PRs"
          filter: "is:open is:pr author:pcrockett archived:false user:my-org"
        assignedPRs:
          title: "Assigned PRs"
          filter: "is:open is:pr archived:false user:my-org assignee:pcrockett"
        reviewRequests:
          title: "Review Requests"
          filter: "is:open is:pr archived:false user:my-org review-requested:pcrockett"
      enabled: true
      enableStatus: true
      repositories:
        - "pcrockett/some-private-repo-i-dont-care-about"
      position:
        top: 3
        left: 2
        height: 1
        width: 1
      refreshInterval: 5m
      username: "pcrockett"
senorprogrammer commented 2 years ago

Yep, should be possible to create it so that ‘repositories’ is optional.

Seanstoppable commented 2 years ago

Definately an interesting idea. There is some refactoring work we'd have to do, because the github client is actually initialized within a repo object. I'm going to start by decomposing that first, which should make only custom queries a bit easier.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Seanstoppable commented 1 year ago

I wonder if the best thing would be to just write a new module for a number of these modules which take ad-hoc queries They were originally written in a less flexible way, and it is probably faster to write a new module for advanced users than trying to force backwards compatibility.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.