Commit f307ac39 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Fix pre_commit_runner: "fatal: no commits selected for shallow requests"

Fixes an issue that occurred when the checked branch is a direct
descendant of the comparison branch in find_lca.
parent cc19ce9d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -24,12 +24,15 @@ pre_commit_run() (
		local repo=$CI_REPOSITORY_URL current_branch=$CI_COMMIT_BRANCH
		local other_branch=$1

		git fetch -q $repo --shallow-exclude=$other_branch $current_branch
		git fetch -q $repo --shallow-exclude=$current_branch $other_branch:refs/other
		# See https://stackoverflow.com/questions/63878612/git-fatal-error-in-object-unshallow-sha-1
		# and https://stackoverflow.com/questions/4698759/converting-git-repository-to-shallow/53245223#53245223
		# for background on what `git repack -d` is doing here.
		git repack -qd

		git fetch -q $repo --shallow-exclude=$other_branch $current_branch
		git fetch -q $repo --deepen=1 $current_branch

		FROM_REF=$(git merge-base $current_branch refs/other) || unset FROM_REF
		FROM_REF=$(git rev-parse -q --revs-only --verify shallow) || unset FROM_REF
	}

	fetch_ref() {