Skip to content

gitserver: override refspecs we mirror

Administrator requested to merge core/one-branch-override into master

Created by: keegancsmith

This is an experiment for a potential customer with a large number of branches. It adds the environment variable "SRC_GITSERVER_REFSPECS" which allows an administrator to restrict the references we fetch. By default we fetch all refs on clone, and then for future refs we fetch a hardcoded whitelist. This is a temporary measure to adjust this list. It is a space seperated list of refspecs. IE the values you would put in the fetch config for a git remote. An example which fetches just the master and dev branch is

env SRC_GITSERVER_REFSPECS="+refs/heads/master:refs/heads/master +refs/heads/dev:refs/heads/dev"

Tested by setting the environment variable in local development mode and exploring which branches were cloned.

NOTE: This is not a documented approach. If we do keep this code around, we will design a clearer and consistent way for administrators to configure this. For now specify an environment variable on an insider build should be sufficient.

Part of https://github.com/sourcegraph/customer/issues/19

Merge request reports

Loading