ejoffe / spr

Stacked Pull Requests on GitHub
MIT License
796 stars 68 forks source link

Bug? `spr` keeps prompting me to star the repo when I already manually starred it. #226

Closed yogurtearl closed 1 year ago

yogurtearl commented 2 years ago

spr keeps prompting me to star this repo when I already manually starred it.

setting stargazer: true in .spr.yml seems to be the workaround.

Maybe it needs a "no and don't ask again" response option?

ejoffe commented 2 years ago

Added logs in v0.8.4, if you can reproduce this with --debug flag, would be interesting to see what's going on.

yogurtearl commented 2 years ago

I updated to 0.8.4.

set my ~/.spr.yml to:

stargazer: false
runcount: 124

then I ran:

❯ git spr --debug version
> git rev-parse --show-toplevel
enjoying git spr? add a GitHub star? [Y/n]:n
Config : {
... omitted ...
    "CreateDraftPRs": false,
    "Stargazer": false,
    "RunCount": 125
  }
}
0.8.4 : 2022-03-30T21:26:19Z : 9197586e

all your debug logs in isStar are within if / for and it looks like it is not hitting any of them. :)

ejoffe commented 2 years ago

if you are seeing the prompt, you should see the logs

log.Debug().Bool("stargazer", false).Msg("MaybeStar") fmt.Print("enjoying git spr? add a GitHub star? [Y/n]:")

try running: git spr --debug status

yogurtearl commented 2 years ago

still not see that log message. 🤔

Does it work locally for you? :)

looks like MaybeStar gets called in main before the debug log level gets set? :)

https://github.com/ejoffe/spr/blob/ee95de7cd99907583ea61d366214379cd858a4d0/cmd/spr/main.go#L46

https://github.com/ejoffe/spr/blob/ee95de7cd99907583ea61d366214379cd858a4d0/cmd/spr/main.go#L106

❯ git spr --debug status
> git rev-parse --show-toplevel
enjoying git spr? add a GitHub star? [Y/n]:n
Config : {
  "Repo": {
.... omitted ...
    "CreateDraftPRs": false,
    "Stargazer": false,
    "RunCount": 125
  }
}
> github fetch pull requests
3:44PM DBG ../../../runner/work/spr/spr/git/realgit/realcmd.go:45 > git branch --no-color
> git branch --no-color
3:44PM DBG ../../../runner/work/spr/spr/github/githubclient/client.go:273 > GetInfo Info= <omitted> pull request stack is empty
ejoffe commented 2 years ago

You are totally right! Try again with 0.8.5

yogurtearl commented 2 years ago

with spr 0.8.5 :

2:07PM DBG ../../../runner/work/spr/spr/github/githubclient/star.go:74 > MaybeStar::isStar stargazer=false
2:07PM DBG ../../../runner/work/spr/spr/github/githubclient/star.go:30 > MaybeStar stargazer=false
enjoying git spr? add a GitHub star? [Y/n]:
ejoffe commented 2 years ago

This is the query used by spr to fetch starred repos: query { viewer { starredRepositories { nodes { nameWithOwner } edges { cursor } totalCount } } }

From the logs it looks like the returned data has an empty list for edges, the isStar function then assumes there is no more star data and returns false (no star found) You can try the query in the github explorer (https://docs.github.com/en/graphql/overview/explorer) and see what response you get.

yogurtearl commented 2 years ago

possibly a network or connection error that triggers an empty list?

a Repository is Starrable and Starrable has viewerHasStarred https://docs.github.com/en/graphql/reference/interfaces#starrable

You should be able to directly query whether this repo is starred and not have to iterate all starred repos. :)

yogurtearl commented 2 years ago

And if you use Repository.viewerHasStarred, then you don't have to assume that empty results means they haven't starred it.

Also, should add a test case for "can not contact github.com" and make sure they it doesn't prompt them to star the repo if github.com is not reachable.

ejoffe commented 1 year ago

Has not surfaced in a while, closing this issue for now. Feel free to reopen it if it's still happening.