Skip to content

Conversation

@vilsonrodrigues
Copy link
Contributor

Summary

This PR fixes several critical issues with the /update command in the mergebot workflow that were causing checkout failures when trying to update PR branches.

Problems Fixed

  1. Checkout was fetching from wrong repository

    • actions/checkout@v4 didn't specify the repository parameter
    • For PRs from the same repo with deleted branches, checkout would fail with "branch not found"
    • Error: A branch or tag with the name 'xxx' could not be found
  2. Branch comparison used incorrect reference format

    • Used ${context.repo.owner}/${context.repo.repo}:${headBranch} format unnecessarily
    • Simpler branch reference works better for same-repo PRs
  3. Fork validation happened too late

    • Fork PRs would go through validation steps before being rejected
    • Caused unnecessary operations and confusing error messages

Changes Made

1. Early Exit for Fork PRs (lines 407-430)

  • Moved fork detection to "Get PR info" step
  • Immediately exits with clear error message for fork PRs
  • Prevents unnecessary validation and checkout attempts

2. Explicit Repository in Checkout (line 553)

uses: actions/checkout@v4
with:
  repository: ${{ steps.pr_info.outputs.head_repo }}  # ✅ Now explicit
  ref: ${{ steps.pr_info.outputs.head_branch }}

3. Simplified Branch Comparison (line 515)

// Simple reference for same-repo PRs (forks exit early)
head: headBranch

4. Optimized Validation Conditions

if: steps.check_perms.outputs.has_permission == 'true' && steps.pr_info.outputs.is_fork != 'true'

Benefits

Better error handling: Fork PRs get immediate, clear feedback
Fixes checkout errors: Same-repo PRs can now be updated correctly
Better performance: Skips unnecessary operations for fork PRs
Cleaner code: Simplified flow and reduced redundancy

Testing

To test this PR:

  1. Test same-repo update: Comment /update on PR #[test-pr-number]
  2. Verify fork handling: Comment /update on a fork PR to see the clear error message

Related Issues

Fixes the issue where /update command would fail with:

Error: A branch or tag with the name 'fix/logo-rendering-and-readme' could not be found

🤖 Generated with Claude Code

vilsonrodrigues and others added 7 commits November 27, 2025 02:18
- Complete project structure overview
- Common commands and workflows
- Release process (always use ./scripts/release.sh)
- Architecture details and optimizations
- Linting, testing, and CI/CD guides
- Troubleshooting tips

This file provides context for Claude Code to work more effectively
with the project without repeating instructions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add field name to env name mapping cache for faster lookups
- Add absolute path cache to avoid repeated pathlib operations
- Add type introspection cache for complex types (Union/Optional)
- Optimize _preprocess_env_value with fast paths for primitive types
- Optimize _get_env_name with fast path for no transformations
- Optimize _decode_from_dict with atomic encoder/decoder cache
- Add comprehensive benchmark suite with cold vs warm analysis
- Move profile_settings.py to benchmark/ directory
- All tests passing (22/22) and lint/format checks clean

Performance improvements:
- Main benchmark: 0.023ms per load (excellent consistency)
- Cold start: 1.489ms (1.3x faster than pydantic)
- Warm cached: 0.011ms (117.5x faster than pydantic)
- 129.6x speedup from cold to warm caching
- Update benchmark results: 0.023ms per load (down from 2.271ms)
- Add cold vs warm performance comparison: 117.5x faster when cached
- Document advanced caching strategies implemented
- Update comparison table with new performance metrics
- Reflect 129.6x internal speedup from cold to warm caching
…ork support

- Add branch existence validation before attempting checkout
- Add proper handling for PRs from forks with clear messaging
- Add detailed error messages for branch deletion, permission issues
- Add branch comparison logic to check if update is actually needed
- Add comprehensive debug logging for troubleshooting
- Handle edge cases where branch was deleted after merge
- Provide helpful instructions for manual updates when automation fails
…heckout

This commit fixes several issues with the `/update` command in the mergebot workflow:

**Problems fixed:**
1. Checkout was trying to fetch branch from base repo instead of head repo
2. Branch comparison used incorrect reference format for same-repo PRs
3. Fork validation happened too late, causing unnecessary operations

**Changes:**
- Add early exit for fork PRs in "Get PR info" step with clear error message
- Specify repository parameter in checkout action to fetch from correct repo
- Simplify branch comparison to use simple branch reference for same-repo PRs
- Update validation conditions to skip unnecessary steps for fork PRs
- Remove redundant "Handle fork PR" step (now handled earlier)
- Add better logging for debugging

**Benefits:**
- Fork PRs now get immediate, clear feedback that update is not supported
- Same-repo PRs can now be updated correctly without checkout errors
- Better performance by skipping unnecessary operations for forks
- Cleaner code flow and easier maintenance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vilsonrodrigues vilsonrodrigues merged commit 1a39c18 into msgflux:main Dec 1, 2025
7 checks passed
vilsonrodrigues added a commit to vilsonrodrigues/msgspec-ext that referenced this pull request Dec 2, 2025
…heckout (msgflux#19)

* docs: Add CLAUDE.md with project guidelines

- Complete project structure overview
- Common commands and workflows
- Release process (always use ./scripts/release.sh)
- Architecture details and optimizations
- Linting, testing, and CI/CD guides
- Troubleshooting tips

This file provides context for Claude Code to work more effectively
with the project without repeating instructions.

* Add CHANGELOG.md for release tracking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* feat: optimize env parser latency with advanced caching

- Add field name to env name mapping cache for faster lookups
- Add absolute path cache to avoid repeated pathlib operations
- Add type introspection cache for complex types (Union/Optional)
- Optimize _preprocess_env_value with fast paths for primitive types
- Optimize _get_env_name with fast path for no transformations
- Optimize _decode_from_dict with atomic encoder/decoder cache
- Add comprehensive benchmark suite with cold vs warm analysis
- Move profile_settings.py to benchmark/ directory
- All tests passing (22/22) and lint/format checks clean

Performance improvements:
- Main benchmark: 0.023ms per load (excellent consistency)
- Cold start: 1.489ms (1.3x faster than pydantic)
- Warm cached: 0.011ms (117.5x faster than pydantic)
- 129.6x speedup from cold to warm caching

* docs: update README with new performance metrics and optimizations

- Update benchmark results: 0.023ms per load (down from 2.271ms)
- Add cold vs warm performance comparison: 117.5x faster when cached
- Document advanced caching strategies implemented
- Update comparison table with new performance metrics
- Reflect 129.6x internal speedup from cold to warm caching

* fix: improve mergebot update command with better error handling and fork support

- Add branch existence validation before attempting checkout
- Add proper handling for PRs from forks with clear messaging
- Add detailed error messages for branch deletion, permission issues
- Add branch comparison logic to check if update is actually needed
- Add comprehensive debug logging for troubleshooting
- Handle edge cases where branch was deleted after merge
- Provide helpful instructions for manual updates when automation fails

* fix: improve mergebot /update command with better fork handling and checkout

This commit fixes several issues with the `/update` command in the mergebot workflow:

**Problems fixed:**
1. Checkout was trying to fetch branch from base repo instead of head repo
2. Branch comparison used incorrect reference format for same-repo PRs
3. Fork validation happened too late, causing unnecessary operations

**Changes:**
- Add early exit for fork PRs in "Get PR info" step with clear error message
- Specify repository parameter in checkout action to fetch from correct repo
- Simplify branch comparison to use simple branch reference for same-repo PRs
- Update validation conditions to skip unnecessary steps for fork PRs
- Remove redundant "Handle fork PR" step (now handled earlier)
- Add better logging for debugging

**Benefits:**
- Fork PRs now get immediate, clear feedback that update is not supported
- Same-repo PRs can now be updated correctly without checkout errors
- Better performance by skipping unnecessary operations for forks
- Cleaner code flow and easier maintenance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

1 participant