# HG changeset patch # User Patrick Steinhardt <psteinhardt@gitlab.com> # Date 1675417794 -3600 # Fri Feb 03 10:49:54 2023 +0100 # Node ID 8b797ffea9d8697199ccecbcb4e7c0ba55b285ba # Parent fe209337dcda9d213e5be4b1d16726d649f02041 git: Make the Gitaly Git version override version-neutral With 89950647c (Set GIT_REPO_URL, GIT_VERSION_2_37_1, GIT_VERSION_2_38, 2022-11-11), we have introduced the logic to allow overriding the bundled Git versions that Gitaly is using. Back then we had been hard coding the specific versions that could be overridden. But as these bundled Git versions are under the control of Gitaly and change over time those are bound to become out-of-date. In fact, they already are out-of-date as Gitaly only distributes the Git v2.38 release train. Furthermore, Gitaly will soon add a second release train with Git v2.39, which would require another new variable override. Refactor the logic to be version-neutral so that we just forward all environment variables that have the `GITALY_GIT_VERSION_` prefix to the build environment. diff --git a/config/software/git.rb b/config/software/git.rb --- a/config/software/git.rb +++ b/config/software/git.rb @@ -76,13 +76,19 @@ sm_version_override_git_repo_url = Gitlab::Util.get_env('SELF_MANAGED_VERSION_REGEX_OVERRIDE_GIT_REPO_URL') git_repo_url = Gitlab::Util.get_env('GITALY_GIT_REPO_URL') if Build::Check.is_auto_deploy_tag? - git_version_2_37_1 = Gitlab::Util.get_env('GITALY_GIT_VERSION_2_37_1') - git_version_2_38 = Gitlab::Util.get_env('GITALY_GIT_VERSION_2_38') + # Gitaly potentially bundles multiple different Git distributions with it. + # It is possible to override the specific version that Gitaly compiles each + # of these distributions with by setting: + # + # `GIT_VERSION_2_38=v2.38.1` + # + # As the bundled Git versions change over time we have this generic loop to + # just accept any such override into the environment used by make. + ENV.select { |k, v| k.start_with('GITALY_GIT_VERSION_') }.each do |k, v| + env[k.delete_prefix('GITALY_')] = v unless v&.empty? + end env['GIT_REPO_URL'] = git_repo_url if git_repo_url - env['GIT_VERSION_2_37_1'] = git_version_2_37_1 if git_version_2_37_1 - env['GIT_VERSION_2_38'] = git_version_2_38 if git_version_2_38 - elsif sm_version_override_git_repo_url && Regexp.new(sm_version_override_git_repo_url).match?(Build::Info.gitlab_version) env['GIT_REPO_URL'] = git_repo_url if git_repo_url end