# HG changeset patch
# User Balasankar 'Balu' C <balasankar@gitlab.com>
# Date 1709154252 0
#      Wed Feb 28 21:04:12 2024 +0000
# Node ID 4e4c702fddf00c5f485ccd5a1535a295ec7c627f
# Parent  884884494307587739ba2699df6915a9e7d647c6
Change git-filter-repo position in build order

When git-filter-repo is a dependency of gitaly, Omnibus will
place it early in the build order and, by necessity, git.

This behavior causes cache to bust frequently.  This change
re-arranges the dependency order and keeps git builds
in the later stages.

Signed-off-by: Balasankar 'Balu' C <balasankar@gitlab.com>

diff --git a/config/projects/gitlab.rb b/config/projects/gitlab.rb
--- a/config/projects/gitlab.rb
+++ b/config/projects/gitlab.rb
@@ -163,6 +163,13 @@
 dependency 'gitlab-pages'
 dependency 'git'
 
+# `git-filter-repo` is a dependency of Gitaly. But placing it there will cause
+# it to be built early in the build list, which will in-turn cause `git` to be
+# built early. `git`, being built from `gitaly` source will bust cache often,
+# and cause unnecessary rebuilds. Hence, we are placing `git-filter-repo` as a
+# project dependency after `git`
+dependency 'git-filter-repo'
+
 # gitaly needs grpc to work correctly. These native extensions are built as part
 # of gitlab-rails build. So, gitlab-rails has to be built before gitaly. But
 # making gitaly depend on gitlab-rails will cause it to be built earlier,
diff --git a/config/software/git-filter-repo.rb b/config/software/git-filter-repo.rb
--- a/config/software/git-filter-repo.rb
+++ b/config/software/git-filter-repo.rb
@@ -27,7 +27,11 @@
 
 skip_transitive_dependency_licensing true
 
-dependency 'git'
+# Git is marked as a project dependency to be built before `git-filter-repo`.
+# Adding it as a software dependency to `git-filter-repo` will cause it to be
+# rebuilt early in the build list, bust cache, and cause everything after it to
+# be rebuilt.
+# dependency 'git'
 dependency 'python3'
 
 build do
diff --git a/config/software/gitaly.rb b/config/software/gitaly.rb
--- a/config/software/gitaly.rb
+++ b/config/software/gitaly.rb
@@ -30,7 +30,6 @@
 dependency 'ruby'
 dependency 'libicu'
 dependency 'tomlib'
-dependency 'git-filter-repo'
 
 # Technically, gitaly depends on git also. But because of how omnibus arranges
 # components to be built, this causes git to be built early in the process. But