HomePhabricator

Fetch and discover all Git ref types, not just branches

Description

Fetch and discover all Git ref types, not just branches

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)

Reviewers: chad

Reviewed By: chad

Subscribers: avivey

Maniphest Tasks: T6878, T9028

Differential Revision: https://secure.phabricator.com/D16129