LogoSkills

Merge Conflict Resolution Rules

Strategy for resolving merge conflicts in stale PRs (2+ weeks).

Strategy for resolving merge conflicts in stale PRs (2+ weeks).

Strategy by File Type#

File TypeStrategyReason
Generated files (.g.dart, .freezed.dart) --theirs (base branch) Need to regenerate based on latest code
Migration files--theirs (base branch)Ensure migration order
pubspec.yaml --theirs + manual dependency addition SDK version from base, only add PR's new dependencies
BLoC events/states Individual review Verify sealed class pattern migration
Xcode project files Manual review Watch for missing framework references
Business logic Individual review Both changes need to be reflected

Conflict Resolution Order#

# 1. Update development branch
git checkout development  & &   git pull

# 2. Switch to PR branch
git checkout feature/issue-XXX

# 3. Merge development (conflicts occur)
git merge development

# 4. Batch handle generated files
git checkout --theirs  ' **/*.g.dart '   ' **/*.freezed.dart '   ' **/*.module.dart ' 

 # 5. Handle pubspec.yaml
git checkout --theirs  ' **/pubspec.yaml ' 
 # Then manually re-add only the dependencies added in the PR

# 6. Review business logic files individually
# git mergetool or manual resolution in editor

# 7. Re-run code generation
melos run build

# 8. Analysis and testing
melos run analyze  & &   melos run test

BLoC Pattern Migration Note#

When BLoC event/state patterns changed in the base branch after PR was created:

// Previous pattern (used in PR)
@freezed
class MyEvent with _$MyEvent {
  const factory MyEvent.started() = _Started;
}

// New pattern (changed in base branch)
sealed class MyEvent extends Equatable {
  const MyEvent();
  const factory MyEvent.started() = _Started;
}

In this case, PR code must be updated to match the base branch pattern.

Post-Merge Verification#

# 1. Verify formatting
melos run format

# 2. Static analysis
melos run analyze

# 3. Verify code generation
melos run build

# 4. Tests
melos run test