Page MenuHomePhabricator

Fetch and discover all Git ref types, not just branches
ClosedPublic

Authored by epriestley on Jun 16 2016, 12:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 11, 11:35 AM
Unknown Object (File)
Tue, Dec 10, 10:45 AM
Unknown Object (File)
Mon, Dec 9, 3:58 PM
Unknown Object (File)
Fri, Dec 6, 7:38 AM
Unknown Object (File)
Tue, Nov 26, 10:09 PM
Unknown Object (File)
Fri, Nov 22, 7:19 PM
Unknown Object (File)
Fri, Nov 22, 7:08 AM
Unknown Object (File)
Thu, Nov 21, 5:08 PM
Subscribers
Tokens
"Like" token, awarded by 20after4.

Details

Summary

Ref T9028. Fixes T6878. Currently, we only fetch and discover branches. This is fine 99% of the time but sometimes commits are pushed to just a tag, e.g.:

git checkout <some hash>
nano file.c
git commit -am '...'
git tag wild-wild-west
git push origin wild-wild-west

Through a similar process, commits can also be pushed to some arbitrary named ref (we do this for staging areas).

With the current rules, we don't fetch tag refs and won't discover these commits.

Change the rules so:

  • we fetch all refs; and
  • we discover ancestors of all refs.

Autoclose rules for tags and arbitrary refs are just hard-coded for now. We might make these more flexible in the future, or we might do forks instead, or maybe we'll have to do both.

Test Plan

Pushed a commit to a tag ONLY (vegetable1).

https://github.com/epriestley/poems/commit/cf508b8de62936ad985bdd0df86aeb206df7354a

On master, prior to the change:

  • Used update + refs + discover.
  • Verified tag was not fetched with git for-each-ref in local working copy and the web UI.
  • Verified commit was not discovered using the web UI.

With this patch applied:

  • Used update, saw a refs/* fetch instead of a refs/heads/* fetch.
  • Used git for-each-ref to verify that tag fetched.
  • Used repository refs.
  • Saw new tag appear in the tags list in the web UI.
  • Saw new refcursor appear in refcursor table.
  • Used repository discover --verbose and examine refs for sanity.
  • Saw commit row appear in database.
  • Saw commit skeleton appear in web UI.
  • Ran bin/phd debug task.
  • Saw commit fully parse.

no_branches.png (1×1 px, 196 KB)

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

epriestley retitled this revision from to Fetch and discover all Git ref types, not just branches.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.Jun 16 2016, 1:06 PM
epriestley edited edge metadata.
  • Remove one unused variable that I didn't actually need.

we only fetch and discover branches

Or, specifically, we fetch branches, and then Git fetches tags on those branches for free since we don't tell it --no-tags. So most tags do get fetched today.

But if you do the "make a commit, only tag it, push it" flow above (or stuff with raw refs like Gerrit / some flavors of Staging Areas) the tag doesn't get fetched until this change.

This revision was automatically updated to reflect the committed changes.