Skip to content
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

Only fetch pull request refs from the server if the ones we have aren't up to date #21

Merged
merged 4 commits into from
Dec 12, 2018

Conversation

davidwengier
Copy link
Collaborator

@davidwengier davidwengier commented Dec 10, 2018

Fixes #19. Hopefully I've interpreted the idea correctly.

The sun never sets on the GitPullRequest empire 😁

@jcansdale
Copy link
Owner

jcansdale commented Dec 10, 2018

Thanks for taking this on!

That could work. I didn't bother with any kind of optimisation because I assumed git itself would be doing something similar when doing the fetch.

Thinking about what you said here, I think we could simplify things by taking advantage of what what a git fetch does. Instead of manually comparing local and remote refs, we could do a fetch and use the fetched refs at the definitive state. This would mean we would only ever hit the network once.

It would look something like this:

  1. Copy all remote pull and heads refs to our own local cache (I'm using refs/git-pr as the base so people would know which tool is creating the refs).
git fetch {remoteName} +refs/pull/*/merge:refs/git-pr/{remoteName}/pull/*/merge +refs/heads/*:refs/git-pr/{remoteName}/heads/* --prune
  1. Populate our ref dictionary using all of the refs under refs/git-pr/{remoteName}.

  2. Fix up our pull refs using the commit at HEAD^1 trick

Further down the line we could give the user the option to skip the fetch completely and simply use the cached refs (this would be useful on large/active repositories).

What do you think? What is the sun doing where you are? 😉

jcansdale and others added 3 commits December 11, 2018 00:09
This will be necessary if we decide to copy all remote heads/pull refs
locally and use local copy in place of git ls-remote.
@davidwengier
Copy link
Collaborator Author

Thanks for fixing the merge, it was a painful one. I'm going to merge this PR so it doesn't drift any further because I have a busy couple of days. I've opened your comment as an issue: #32

@davidwengier davidwengier merged commit a5972d2 into jcansdale:master Dec 12, 2018
@davidwengier davidwengier deleted the FetchOnlyWhenNecessary branch December 12, 2018 21:10
@jcansdale
Copy link
Owner

I'm going to merge this PR so it doesn't drift any further because I have a busy couple of days.

Sounds like a plan. It's no fun tracking a moving target. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants