Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(get-modified-packages): support fetching for shallow clones #298

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions get-modified-packages/get-modified-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
shift
done

# base_branch is like "origin/main"
base_branch="${args[0]}"
echo "base_branch: $base_branch"

# Check args
if [ "$base_branch" = "" ]; then
Expand Down Expand Up @@ -49,8 +51,26 @@
return 1
}

# Find modified files from base branch
modified_files=$(git diff --name-only "$base_branch"...HEAD)
# Function to check if the base ref SHA is in the commit history
check_base_ref_in_history() {
git rev-list HEAD | grep -q "$(git rev-parse "$base_branch")"
}

# Fetch the initial shallow clone depth
depth=1

# Loop to deepen the fetch until the base ref SHA is included
while ! check_base_ref_in_history; do
depth=$((depth * 2))
# NOTE: need to specify the bese_branch

Check warning on line 65 in get-modified-packages/get-modified-packages.sh

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (bese)
# NG: git fetch origin/main --deepen=1
# OK: git fetch origin main --deepen=1
# => $base_branch need to be transformed from "origin/main" to "origin main"
git fetch --deepen=$depth
done

# Get the modified files between base ref and HEAD
modified_files=$(git diff --name-only $base_branch"...HEAD)

# Find modified packages
modified_package_dirs=()
Expand Down
Loading