Skip to content

Conversation

@Rexus
Copy link
Contributor

@Rexus Rexus commented Dec 7, 2025

No description provided.

Rexus added 2 commits December 7, 2025 22:07
- Detect squash merges by checking for PR number in commit message
- Query GitHub API to get source branch for squash merges
- Update both update-version and sync_branches jobs
- Fix version calculation to handle squash merges
- Resolves issue where beta->main squash merge didn't update VERSION
The beta->main PR merge was a squash merge, so the workflow didn't detect it
and failed to update VERSION. This commit corrects the VERSION file manually
while the workflow fix ensures future squash merges are handled properly.
@Rexus Rexus requested a review from Copilot December 7, 2025 21:08
@Rexus Rexus merged commit ce14af4 into main Dec 7, 2025
18 checks passed
@Rexus Rexus deleted the bugfix/version-not-updated-on-beta-merge branch December 7, 2025 21:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where the VERSION file was not being updated correctly when beta branches were merged to main using squash merges. The fix includes correcting the VERSION file format (removing leading whitespace) and improving the workflow's merge detection logic to properly handle both regular merge commits and squash merges.

  • Fixes VERSION file format by removing leading spaces and updating from 1.0.0-alpha to 1.0.0-beta
  • Refactors branch type detection logic to use GitHub API as a fallback for both merge commits and squash merges
  • Adds explicit squash merge detection in VERSION update and branch sync jobs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
VERSION Corrects file format by removing leading spaces and updates version from 1.0.0-alpha to 1.0.0-beta
.github/workflows/ci-cd-versioned.yml Refactors merge detection logic to properly handle squash merges; moves GitHub API fallback outside conditional blocks; adds squash merge detection to VERSION update and branch sync jobs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

echo "🔍 Detected PR #${PR_NUMBER}, querying GitHub API for source branch..."
PR_INFO=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER")
LAST_PR_BRANCH=$(echo "$PR_INFO" | grep -oP '"ref":\s*"\K[^"]+' | head -1)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The grep pattern '"ref":\s*"\K[^"]+' will match any "ref" field in the JSON response. The GitHub PR API returns multiple "ref" fields (for both head.ref and base.ref). Using | head -1 to get the first match is unreliable because JSON field ordering is not guaranteed. This could potentially extract the base (target) branch instead of the head (source) branch.

Consider using a more specific pattern or using jq to parse the JSON properly:

LAST_PR_BRANCH=$(echo "$PR_INFO" | jq -r '.head.ref')

Or with grep, be more specific:

LAST_PR_BRANCH=$(echo "$PR_INFO" | grep -oP '"head":[^}]*"ref":\s*"\K[^"]+')
Suggested change
LAST_PR_BRANCH=$(echo "$PR_INFO" | grep -oP '"ref":\s*"\K[^"]+' | head -1)
LAST_PR_BRANCH=$(echo "$PR_INFO" | jq -r '.head.ref')

Copilot uses AI. Check for mistakes.
Comment on lines +497 to +508
echo "merge_type=merge" >> $GITHUB_OUTPUT
echo "✅ This is a merge commit (2 parents)"
else
echo "is_merge=false" >> $GITHUB_OUTPUT
echo "ℹ️ This is a direct commit, skipping VERSION update"
# Check if this is a squash merge by looking for PR number
COMMIT_MSG=$(git log -1 --pretty=%B)
if [[ "$COMMIT_MSG" =~ \(#[0-9]+\) ]]; then
echo "is_merge=true" >> $GITHUB_OUTPUT
echo "merge_type=squash" >> $GITHUB_OUTPUT
echo "✅ This is a squash merge (PR found in commit message)"
else
echo "is_merge=false" >> $GITHUB_OUTPUT
echo "merge_type=none" >> $GITHUB_OUTPUT
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The merge_type output variable is set but never used by any subsequent steps or jobs. If this is intended for debugging purposes only, consider removing it or documenting its purpose. If it's intended for future use, consider adding a comment explaining the planned usage.

If not needed, you can remove these lines to reduce clutter:

echo "merge_type=merge" >> $GITHUB_OUTPUT    # line 497
echo "merge_type=squash" >> $GITHUB_OUTPUT   # line 504  
echo "merge_type=none" >> $GITHUB_OUTPUT     # line 508

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants