Skip to content
Merged
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
18 changes: 11 additions & 7 deletions scripts/merge-train/squash-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ cd "$worktree_dir"
git config user.name "$pr_author"
git config user.email "$author_email"

# Save our current branch commit
# Save our current branch commits
original_head=$(git rev-parse HEAD)

# Deepen our history for comparisons
git fetch --depth=200 origin "$base_sha"
git fetch --depth=200 origin "$base_sha"
git fetch --depth=200 origin "$base_branch"
# Deepen by 50 to ensure we have the base commit
git fetch --deepen=50

# Fetch the base commit with depth
git fetch --depth=50 origin "$base_sha"

# Fetch the base branch to ensure we have it
git fetch origin "$base_branch"

# Find the merge-base between our branch and the base branch
merge_base=$(git merge-base "$original_head" "origin/$base_branch")
Expand Down Expand Up @@ -89,10 +93,10 @@ git commit -m "$commit_message" --no-verify
if [[ "$is_fork" == "true" ]]; then
# It's a fork - need to push to the fork repository
echo "Detected fork: pushing to $head_repo"

# Add the fork as a remote (assumes GITHUB_TOKEN env var is set from workflow)
git remote add fork "https://x-access-token:${GITHUB_TOKEN}@github.com/${head_repo}.git"

# Push to the fork
git push --force fork "HEAD:refs/heads/$branch"
else
Expand Down
Loading