ejoffe / spr

Stacked Pull Requests on GitHub
MIT License
714 stars 65 forks source link

prompt to star the repo leads to crash (possibly because of GHE?) #376

Closed jonathanloske closed 5 months ago

jonathanloske commented 6 months ago

When I ran spr, it prompted me to star the repo. I agreed to do so but then it crashed because it Could not resolve to a Repository with the name 'ejoffe/spr'.. This might possibly be related to me having set it up with GitHub Enterprise (GHE) for the repository I was working in.

Full log:

enjoying git spr? add a GitHub star? [Y/n]:y
panic: repository: Could not resolve to a Repository with the name 'ejoffe/spr'.

goroutine 1 [running]:
github.com/ejoffe/spr/github/githubclient.check({0x104c99e38, 0x1400000cba0})
        /Users/runner/work/spr/spr/github/githubclient/client.go:696 +0xe8
github.com/ejoffe/spr/github/githubclient.(*client).addStar(0x14000200270, {0x104c9d5f0, 0x104fb9460})
        /Users/runner/work/spr/spr/github/githubclient/star.go:83 +0x60
github.com/ejoffe/spr/github/githubclient.(*client).MaybeStar(0x14000218600?, {0x104c9d5f0, 0x104fb9460}, 0x14000200018)
        /Users/runner/work/spr/spr/github/githubclient/star.go:38 +0x2ec
main.main.func1(0x14000228580?)
        /Users/runner/work/spr/spr/cmd/spr/main.go:119 +0x198
github.com/urfave/cli/v2.(*App).RunContext(0x1400021e9c0, {0x104c9d5f0?, 0x104fb9460}, {0x1400001e040, 0x2, 0x2})
        /Users/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.8.1/app.go:328 +0x554
github.com/urfave/cli/v2.(*App).Run(...)
        /Users/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.8.1/app.go:247
main.main()
        /Users/runner/work/spr/spr/cmd/spr/main.go:224 +0x11bc
ejoffe commented 5 months ago

Yes, I believe this is related to the use of GHE. A fix is needed to not crash in this case. I believe that after you star the repo, you should not get this message anymore, so it's a one time crash. Correct me if that's not the case.

jonathanloske commented 5 months ago

I think it might still happen because SPR can't know whether I starred the repo and seems to crash before it saves that I had the intent to do so. I had to manually edit ~/.spr.state.