Skip to content

feat: add failOnConflicts and conflictLabel options for better conflict handling#550

Open
kapral18 wants to merge 1 commit intosorenlouv:mainfrom
kapral18:fail-on-commit-conflicts
Open

feat: add failOnConflicts and conflictLabel options for better conflict handling#550
kapral18 wants to merge 1 commit intosorenlouv:mainfrom
kapral18:fail-on-commit-conflicts

Conversation

@kapral18
Copy link
Contributor

Summary

Adds two new configuration options to improve conflict visibility when using commitConflicts: true:

  • failOnConflicts (default: true): Controls exit code behavior when PRs are created with conflicts
  • conflictLabel (default: "merge-conflict"): Customizable label automatically added to PRs with conflicts

Motivation

When commitConflicts: true, backport creates PRs even with merge conflicts. However, the process exits with code 0, causing GitHub Actions to show as SUCCESS (green). This makes it easy to overlook PRs that need manual conflict resolution.

Partially addresses: #447 (comment)

Changes

  • Added failOnConflicts option that causes the process to exit with code 1 when conflicts are detected (only in non-interactive mode with commitConflicts: true)
  • Added conflictLabel option to customize the label added to conflicted PRs
  • Modified backport response to include hasConflicts flag for each result
  • Updated logic to automatically label PRs that have merge conflicts
  • Added comprehensive tests for conflict scenarios including new E2E test helpers
  • Updated documentation for both CLI and config file options

Behavior

With commitConflicts: true AND failOnConflicts: true (default):

  • Conflicts encountered → Conflicts committed → PR created with conflict markers → Exit code 1 ✅
  • Result: GitHub Action shows as FAILED (red), making conflicts visible

With commitConflicts: true AND failOnConflicts: false:

  • Conflicts encountered → Conflicts committed → PR created with conflict markers → Exit code 0 ⚠️
  • Result: GitHub Action shows as SUCCESS (green), conflicts may be overlooked

Test plan

…ct handling

Adds two new options to improve handling of merge conflicts when using commitConflicts mode:

- failOnConflicts (default: true): Exit with code 1 when PRs are created with conflicts in non-interactive mode, making conflicts visible in CI
- conflictLabel (default: "merge-conflict"): Customizable label to automatically add to PRs with conflicts

This ensures GitHub Actions show as FAILED (red) when conflicts occur, even though a PR is successfully created, preventing conflicts from being overlooked.

Partially addresses: sorenlouv#447 (comment)
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