Skip to content

fix: prevent squash on out-of-sync branches#579

Open
Brookke wants to merge 3 commits intoaviator-co:masterfrom
Brookke:fix/squash-sync-validation-clean
Open

fix: prevent squash on out-of-sync branches#579
Brookke wants to merge 3 commits intoaviator-co:masterfrom
Brookke:fix/squash-sync-validation-clean

Conversation

@Brookke
Copy link
Copy Markdown
Contributor

@Brookke Brookke commented Aug 13, 2025

Summary

  • Add validation to ensure branches are in sync with their parent before allowing squash operations
  • Prevent data loss when parent branches have been force-pushed or modified externally

Changes

  • Added validateBranchSync function with dual validation checks (parent head movement and merge base verification)
  • Updated squash command to validate sync before proceeding
  • Added comprehensive test cases covering force-push and out-of-sync scenarios

Add validation to ensure branches are in sync with their parent before
allowing squash operations. This prevents data loss when parent branches
have been force-pushed or modified externally.

- Add validateBranchSync function with dual validation checks
- Update squash command to validate sync before proceeding
- Add comprehensive tests for sync validation scenarios
@Brookke Brookke requested a review from a team as a code owner August 13, 2025 18:34
@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app bot commented Aug 13, 2025

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This pull request is currently open (not queued).

How to merge

To merge this PR, comment /aviator merge or add the mergequeue label.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app bot commented Aug 13, 2025

🔃 FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • 🔒 aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • 🔒 e2e_tests/squash_test.go
    • 🔒 cmd/av/helpers.go
    • 🔒 cmd/av/squash.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.

@aviator-app aviator-app bot requested a review from draftcode August 13, 2025 18:34
// Only enforces this check for non-trunk branches when we have a stored parent head.
// This validation prevents commands from operating on branches that are out of sync
// with their parent, which could lead to unexpected behavior or loss of commits.
func validateBranchSync(ctx context.Context, repo *git.Repo, branch meta.Branch) error {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure the philosophy around how much this CLI should act as a wizard. I.e. rather than throwing an error maybe the cli should prompt for "do you want to run av sync?".

Happy to update depending on what you prefer

@Brookke
Copy link
Copy Markdown
Contributor Author

Brookke commented Nov 16, 2025

/aviator refresh

@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app bot commented Nov 16, 2025

Aviator status snapshot

This pull request is currently open (not queued).

How to merge

To merge this PR, comment /aviator merge or add the mergequeue label.


You can also comment /aviator sync to update this pull request with the latest commits from the base branch.

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