-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
WIP: Show pull requests against branches #2781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
8357475 to
cd8cfbd
Compare
|
Oooh, very nice! A few thoughts after trying it (very briefly though, so I might be missing a lot of things):
|
It needs remotes to map from PRs back to branches i.e. the PR has an owner e.g. 'jesseduffield') and the remote has a URL (e.g.
No need to apologise, I've been thinking the same thing. I wish there was a way to pass multiple branch heads to gh or to the graphql endpoint (gh is just a way of talking to graphql) but from what I've seen and tried, there's not. We could try a parallelised approach of shelling out to a bunch of gh processes at once but it would probably be rate limited.
I agree, and it shouldn't be hard to support that.
Yep currently it's just for display but I like your idea. |
cd8cfbd to
39bd87d
Compare
134a144 to
319ca04
Compare
319ca04 to
bcb7011
Compare
|
|
||
| func fetchPullRequestsQuery(branches []string, owner string, repo string) string { | ||
| var queries []string | ||
| for i, branch := range branches { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do this in one request (not sure about the length limits for the query) with:
query {
search(first:3, query:"head:gh-integration-3 head:integration-tests-on-windows repo:jesseduffield/lazygit", type: ISSUE) {
nodes {
... on PullRequest {
url
}
}
}
}which returns:
{
"data": {
"search": {
"nodes": [
{
"url": "https://github.com/jesseduffield/lazygit/pull/2781"
},
{
"url": "https://github.com/jesseduffield/lazygit/pull/2648"
}
]
}
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dlvhdr Interesting, playing with this now. I'm new to GraphQL and all this stuff.
May I ask a few questions?
- What are some criteria for which is better? When I tried both versions using a list of 10 branches, they both took roughly the same time (a bit over 500ms).
- When you say "one request", then the original version is also just one request (i.e. one http call). It just has a bunch of subqueries, and I couldn't find a lot of information about what these even are or how they work. (But I didn't try hard.) Ok, so this wasn't a question. 😄
- Why does this even work? The github documentation says that when you put multiple things into a search query, it ANDs them together by default, so I would have expected that you need
query:"(head:gh-integration-3 OR head:integration-tests-on-windows) repo:jesseduffield/lazygit". Does github have the DWIM logic to synthesize the right boolean operator based on what field types you search for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh then I must have been mistaken.. Seems pretty much identical.
Regarding the 3rd point I couldn't find the documentation for it, but I swear it exists.
Anyway if you use https://docs.github.com/en/graphql/overview/explorer and provide this query, it works:
query FetchSponsors {
search(query:"is:pr repo:dlvhdr/gh-dash repo:jesseduffield/lazygit", type:ISSUE, first: 10) {
nodes {
... on PullRequest {
title
repository {
nameWithOwner
}
}
}
}
}Maybe github does an implicit OR if an AND doesn't make sense.
|
Is there a plan to make gh pr usable in LG, or only the external view? I would love to see it allow us to use 'gh pr create/edit/etc'.. if lg could add in support for the gh command for prs... it would be amazing and make it so i dont even have to leave my nvim/lg setup xD |
|
@Daemoen You can easily do this as a customCommand. For example, for creating a PR on the current branch: |
|
Could we show a list of pull requests and their titles? I would actually use this instead of the branch view most of the time. This way I wouldn't need to remember the name of the branch or the PR number. I just need the (human readable) title. This would also be useful for code review. Currently I have to go to GitHub, copy the branch name, and checkout the branch, whereas with this workflow I could just directly checkout the PR inside of lazygit. The branch name is an implementation detail. |
a8edf26 to
843d19a
Compare
4ced74b to
dfc47fb
Compare
I don't know what I'm doing here, but this seems to be needed to make it work for me.
dfc47fb to
335cbf7
Compare
If the user has
ghinstalled and it's on version 2 or greater, we'll refresh pull requests at the same time we run a backgroundgit fetch.There are a lot of touch points here:
ghis written in Go and we could avoid an external dependency by using theghcode directly, however doing so would mean taking on the burden of handling things like authentication, which would increase the scope quite a bit. Given that pulling pull requests takes a while (3.5s for me), the extra cost of shelling out toghis negligible in comparisongithub.com. Gh itself looks at the configured hosts file to see if there is an authentication setup for any host. We should do the same.go run scripts/cheatsheet/main.go generate)docs/Config.md) have been updated if necessary