Keep minimum refs in the repository

We need to keep refs number in minimum otherwise if we have a lot of refs, in the end the repository would be very slow. The only refs we really need to keep at the moment are:

  • Branches (refs/heads/**/*)
  • Tags (refs/tags/**/*)
  • Merge requests (refs/merge-requests/[MERGE_REQUEST_IID]/head) (it's possible to replace it with refs/keep-around, but this is also a feature)
  • Commits which have notes (refs/keep-around/[SHA])
  • Commits which have pipelines/jobs (refs/keep-around/[SHA])
  • Commits for deployments (refs/environments/[NAME]) (it's possible to replace it with refs/keep-around)

Everything else is not really needed. We could keep a reserved list, i.e. %w[heads tags merge-requests keep-around environments] and remove all other refs during housekeeping, or just after importing or mirroring.

On the other hand, we could also speed up importing by not creating those refs in the first place. This could be more tricky because we need to create merge requests, notes, and so on during importing, so we still somehow need to have an access to them.

Some action items:

Other things we need to consider:

  • What if a force push happened in a branch? With or without a merge request?
  • What if a branch/tag is deleted?
  • What if a note is deleted on a particular commit?
  • Could we remove ref/sha for pipelines/jobs we don't care?
  • Could we remove ref/sha for deployments we don't care?
  • How do we deal with deleted ref/sha for those notes, pipelines, etc, we no longer care?

See related issues regarding reducing the refs.

Edited by Lin Jen-Shin