fix: open the child repository PR when Copier leaves conflicts - #41
Merged
Merged
Conversation
- Stage files Copier could not merge; it writes them with inline conflict markers and leaves them unmerged, which made the pull request action fail on git checkout -B and dropped the whole update - Name the conflicting files in the pull request title, body and job log so the markers are resolved before the update is merged - Detect changes with git status instead of git diff, so an update that only adds files is no longer reported as no change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview and Background
The
v2.0.1tag got past the interactive-prompt failure fixed in #40, and then failed one step later:copier updatesucceeded, butREADME.mdin the child repository could not be merged automatically. Copier writes such files with inline conflict markers and leaves them unmerged in the index, then exits 0.peter-evans/create-pull-requeststarts by creating its branch withgit checkout -B, which refuses to run while the index has unmerged entries, so no pull request was opened and the whole update was lost.While reproducing this I also found that the change-detection step used
git diff --quiet, which does not see untracked files. An update that only adds files (this release adds.agents/,.claude/and.codex/) would have been reported as "no changes" and skipped.Related Issues
None. Follow-up to #40, same workflow.
Implementation Approach
--conflict rej. I tested both against the real child repository: withrejthe index stays clean, but the merged file silently loses the rejected hunk and aREADME.md.rejfile is committed alongside it. Inline markers keep both versions visible in the diff and cannot be merged by accident without someone noticing.git diff --name-only --diff-filter=Uandgit add -Aso the branch can be created. The conflict markers travel into the pull request, where a person resolves them.::warning::annotations, the pull request title gains a(resolve conflicts)suffix, and the body gains a section naming each conflicting file. The body text is built as a multi-line step output, because GitHub expression string literals cannot contain newlines.git status --porcelaininstead ofgit diff --quiet.Changes
.github/workflows/trigger-template-update.yml: stage and report conflicts in the update step; conditional title suffix and conflict section in the pull request; change detection viagit status.Impact
Validation Results
Extracted both
runscripts from the workflow with a YAML parser and ran them against a real clone ofmjun0812/python-project-templateupdated tov2.0.1, which reproduces the conflict.Conflict case:
No-conflict and no-change cases, after committing the update:
Add-only case, with a single untracked file present: