Skip to content

Pull remote refs into a git-pr namespace to allow for local caching #32

@davidwengier

Description

@davidwengier

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? 😉

Originally posted by @jcansdale in #21 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions