Repository navigation
Description
Description
The "Detect merge conflicts" step in sync-main-to-dev.yml always reports conflict=true, even when dev is a strict ancestor of main and conflicts are mathematically impossible. This causes every sync PR to be mislabeled as merge-conflict and auto-merge is never enabled.
Steps to Reproduce
- Push to
main(triggers sync-main-to-dev workflow) - Workflow runs "Detect merge conflicts" step
git merge --no-commit --no-ff origin/main 2>/dev/nullreturns non-zero- PR is created with
(conflicts)title andmerge-conflictlabel - "Enable auto-merge" step is skipped
Expected Behavior
When dev is behind main with no divergent commits, the conflict check should report conflict=false, the PR should have a clean title, no merge-conflict label, and auto-merge should be enabled.
Actual Behavior
Every run reports false conflicts. Verified across 5 consecutive runs in downstream (vig-os/devcontainer-smoke-test) and 1 run in upstream (vig-os/devcontainer). Evidence from PR #59: GitHub API confirms mergeStateStatus: CLEAN and mergeable: MERGEABLE, branch compare shows dev is 0 ahead / 3 behind main.
Environment
- Upstream:
ubuntu-22.04runner, git 2.53.0 - Downstream:
ghcr.io/vig-os/devcontainercontainer onubuntu-22.04, git 2.39.5 - Bug reproduces in both environments
Additional Context
The exact cause of the git merge non-zero exit is unknown because 2>/dev/null suppresses all error output. The step does not distinguish between actual conflicts (exit 1) and other failures (exit 128+).
Affected workflow runs (downstream): 23402800270, 23382600708, 23382437352, 23381148959, 23339310830. Upstream: 23060324149.
Both .github/workflows/sync-main-to-dev.yml (upstream) and the downstream copy are affected.
Possible Solution
- Remove or replace
2>/dev/null— capture stderr for logging - Distinguish exit codes: 1 = conflict, other = unexpected error
- Add a fast-path:
git merge-base --is-ancestor origin/dev origin/main→ skip conflict check (conflicts impossible when dev is an ancestor) - Consider
git merge-tree --write-tree(git 2.38+) for in-memory merge without working-tree side effects
Changelog Category
Fixed
- TDD compliance (see .cursor/rules/tdd.mdc)
Activity
c-vigo commentedon Mar 22, 2026
Implementation Plan
Analysis
The
Detect merge conflictsstep (L172-183) usesgit merge --no-commit --no-ff origin/main 2>/dev/nullto trial-merge main into the local dev checkout. Two problems:2>/dev/nullswallows ALL errors — any non-zero exit (permissions, ownership, config) is misinterpreted as a merge conflict.The false positive cascades into three downstream effects in the same job:
(conflicts)title/body path and adds themerge-conflictlabel.steps.merge-check.outputs.conflict != 'true'evaluates false → step is skipped.Approach: replace trial merge with
git merge-treegit merge-tree --write-tree <branch1> <branch2>(git ≥ 2.38) performs a purely in-memory three-way merge — no working tree, no index, no config dependencies. Exit 0 = clean, exit 1 = conflicts.Both environments meet the prerequisite: container has git 2.39.5, runner has git 2.53.0.
Changes
File 1 —
.github/workflows/sync-main-to-dev.ymlReplace the
Detect merge conflictsstep body (L175-183):Key differences from current code:
git merge-treeoperates in-memory — nogit merge --abortcleanup needed.mainanddevto ensure refs are fresh (current code only fetchesmain).::warning::annotation for visibility in the Actions UI.No changes to the "Create PR" or "Enable auto-merge" steps — they already key off
steps.merge-check.outputs.conflictcorrectly.File 2 — downstream smoke-test copy (out of scope)
The downstream
vig-os/devcontainer-smoke-testmaintains its own copy of this workflow (per its header comment: "intentionally decoupled"). The same fix should be applied there separately after verifying it works upstream.Test strategy
This is a CI workflow change — no unit-testable code. Verification:
workflow_dispatchon that branch.Detect merge conflictsstep logs "Trial merge clean" and setsconflict=false.Scope
.github/workflows/sync-main-to-dev.ymlDetect merge conflictsstepfix(ci): detect sync-main-to-dev conflicts with merge-tree
fix: sync-main-to-dev conflict detection with merge-tree (#412)
chore: release 0.3.1 (#342)