Skip to content

itdove/devaiflow#324: Branch sync on session reopen: commits_behind() ignores branch parameter causing incorrect update suggestions#328

Merged
itdove merged 1 commit intomainfrom
324
Mar 27, 2026
Merged

itdove/devaiflow#324: Branch sync on session reopen: commits_behind() ignores branch parameter causing incorrect update suggestions#328
itdove merged 1 commit intomainfrom
324

Conversation

@itdove
Copy link
Copy Markdown
Owner

@itdove itdove commented Mar 27, 2026

Related Issue: #324

Description

This PR fixes a bug in the branch sync logic where the commits_behind() function ignores its branch parameter, causing incorrect update suggestions when reopening sessions. The fix adds safety checks for branch checkout and sync operations to ensure the correct branch is used when determining if a branch is behind its remote.

The changes include:

  • Updated commits_behind() in devflow/git/utils.py to properly respect the branch parameter
  • Added safety checks in devflow/cli/commands/open_command.py for branch checkout and sync operations
  • Added comprehensive test coverage in tests/test_branch_sync_fixes.py to prevent regression

Assisted-by: Claude

Testing

Steps to test

  1. Pull down the PR
  2. Create a test branch that is behind its remote counterpart
  3. Run daf open to reopen a session on that branch
  4. Verify that the commits_behind calculation correctly uses the specified branch parameter
  5. Confirm that update suggestions are accurate and not based on the wrong branch
  6. Run the new test suite: pytest tests/test_branch_sync_fixes.py -v

Scenarios tested

  • Session reopen with branch behind remote (commits_behind correctly identifies the gap)
  • Session reopen with branch up to date (no false positive update suggestions)
  • Branch checkout safety checks prevent incorrect branch operations
  • Unit tests verify branch parameter is properly passed and used in git operations

Deployment considerations

  • This code change is ready for deployment on its own
  • This code change requires the following considerations before being deployed:

- Make _handle_branch_checkout return boolean to indicate success/failure
- Add early return when checkout fails before attempting sync
- Add safety check to verify current branch before syncing with base
- Prevent sync operations when not on the expected branch

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

Co-Authored-By: Claude <noreply@anthropic.com>
@itdove itdove marked this pull request as ready for review March 27, 2026 15:20
@itdove itdove merged commit b337f4b into main Mar 27, 2026
7 checks passed
@itdove itdove deleted the 324 branch March 27, 2026 15:20
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