Skip to content

fix(sync): stay on default branch after sync#56

Merged
rios0rios0 merged 3 commits intomainfrom
fix/sync-stay-on-default-branch
Apr 2, 2026
Merged

fix(sync): stay on default branch after sync#56
rios0rios0 merged 3 commits intomainfrom
fix/sync-stay-on-default-branch

Conversation

@rios0rios0
Copy link
Copy Markdown
Owner

Summary

  • Fixed RestoreAfterSync to leave repos on the default branch instead of the original branch after syncing
  • Prevents dev repo prune from failing with "cannot delete branch used by worktree" when the merged branch is currently checked out
  • WIP branches are still preserved for dirty repos; only the final checkout target changed

Test plan

  • make build compiles successfully
  • All sync-related unit tests pass with updated assertions
  • Run dev repo sync followed by dev repo prune and verify no "used by worktree" errors

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 2, 2026 03:53
Copy link
Copy Markdown
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

Updates DevForge’s repo sync finalization so that, after a successful dev repo sync, repositories end on their default branch (not the originally-checked-out branch), preventing subsequent operations like dev repo prune from failing due to a non-default worktree branch being in use.

Changes:

  • Change RestoreAfterSync to checkout defaultBranch after syncing (including after WIP handling for dirty repos).
  • Remove the “restore original branch when clean” behavior.
  • Update sync unit tests to match the new final-checkout expectations.

Reviewed changes

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

File Description
internal/repo/sync.go Adjusts post-sync checkout behavior to leave repos on the default branch.
internal/repo/sync_test.go Updates/extends assertions to reflect the new post-sync branch state.

@claude
Copy link
Copy Markdown

claude bot commented Apr 2, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

- changed `RestoreAfterSync` to checkout the default branch instead of the
  original branch after rebasing the WIP branch
- removed the `else if` block that checked out the original branch for clean
  repos on non-default branches (already on default from the sync step)
- this prevents `prune` from failing with "cannot delete branch used by
  worktree" when the merged branch is currently checked out

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rios0rios0 rios0rios0 force-pushed the fix/sync-stay-on-default-branch branch from fedfb15 to e20c2c0 Compare April 2, 2026 17:56
…rSync` and added changelog entry

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
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

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

- renamed `RestoreAfterSync` to `FinalizeSync` and updated doc comment
- handled checkout error in `FinalizeSync` instead of ignoring it
- added `SyncAndRestore` test for non-default branch stay behavior
- moved changelog entry from Changed to Fixed section

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
4.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@rios0rios0 rios0rios0 merged commit 34826a3 into main Apr 2, 2026
29 of 30 checks passed
@rios0rios0 rios0rios0 deleted the fix/sync-stay-on-default-branch branch April 2, 2026 18:25
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