From fbde1155a877ee53205b1b77a84e58a18efb9661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Fatih=20C=C4=B1r=C4=B1t?= Date: Tue, 11 Jun 2024 16:47:39 +0300 Subject: [PATCH] fetch until sha is there MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: M. Fatih Cırıt --- get-modified-packages/get-modified-packages.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/get-modified-packages/get-modified-packages.sh b/get-modified-packages/get-modified-packages.sh index 781fda77..0324bdf7 100755 --- a/get-modified-packages/get-modified-packages.sh +++ b/get-modified-packages/get-modified-packages.sh @@ -49,6 +49,21 @@ function find_package_dir() { return 1 } +# Function to check if the base ref SHA is in the commit history +check_base_sha_in_history() { + git rev-list HEAD | grep -q "$(git rev-parse $base_sha)" +} + +# Fetch the initial shallow clone depth +depth=8 + +# Loop to deepen the fetch until the base ref SHA is included, +# deepening by a factor of 2 each time +while ! check_base_sha_in_history; do + depth=$((depth * 2)) + git fetch --deepen=$depth +done + # Find modified files from base branch modified_files=$(git diff --name-only "$base_sha"...HEAD)