wtf icon indicating copy to clipboard operation
wtf copied to clipboard

Make GitHub module `repositories` setting optional

Open pcrockett opened this issue 3 years ago • 6 comments

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/[email protected]/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/[email protected]/application.go:493 +0x26
github.com/rivo/tview.(*Application).Run(0xc00079f500)
        /Users/chris/go/pkg/mod/github.com/rivo/[email protected]/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 avatar Aug 18 '22 15:08 pcrockett

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"

pcrockett avatar Aug 18 '22 15:08 pcrockett

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

senorprogrammer avatar Aug 18 '22 16:08 senorprogrammer

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.

Seanstoppable avatar Aug 22 '22 18:08 Seanstoppable

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.

stale[bot] avatar Feb 24 '23 02:02 stale[bot]

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.

Seanstoppable avatar Feb 24 '23 04:02 Seanstoppable

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.

stale[bot] avatar Aug 23 '23 22:08 stale[bot]