fix: rewrite manifest commit in-place instead of blindly amending HEAD#23
Draft
Copilot wants to merge 2 commits into
Draft
fix: rewrite manifest commit in-place instead of blindly amending HEAD#23Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
- Add X-Manifest-PR: true trailer to the initial manifest commit so it can be located reliably on later workflow runs. - Synchronize step: find the manifest commit, collect any user commits stacked above it, reset to its parent, re-apply it (amend committer date for a new SHA to retrigger CI), then cherry-pick user commits. - Merged step: same discovery, then update west.yml only in the manifest commit (preserving its message), cherry-pick user commits back on top, rebase onto upstream if conflicts exist, and push. - Backwards-compatible fallback searches by 'auto-manifest PR' subject for branches created before the marker was introduced. - Add per-cherry-pick error handling with clear failure messages. Agent-Logs-Url: https://github.com/nrfconnect/action-manifest-pr/sessions/2011b57a-adad-461d-87a3-46e574e14293 Co-authored-by: thst-nordic <14976801+thst-nordic@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update action.yml to fix commit handling in auto-manifest branch
fix: rewrite manifest commit in-place instead of blindly amending HEAD
May 18, 2026
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.
git commit --amend --no-editin thesynchronizeandmergedflows always rewritesHEAD, silently destroying any user commits stacked on top of the manifest commit.Changes
Durable marker on manifest commit creation
X-Manifest-PR: truetrailer to the initial commit so it can be located reliably across rebases without depending on commit position.Targeted rewrite in
synchronizeandmergedstepsgit log --grep='X-Manifest-PR: true'; falls back to--grep='auto-manifest PR'for branches predating the marker.git rev-list --reverse "${MANIFEST_COMMIT}..HEAD".--amendto update committer timestamp (new SHA → CI retrigger) without touching content.west.ymlfrom the manifest commit, update revision tomerge_commit_sha, commit with the original message preserved viagit commit -F.rebase -X theirsfallback are preserved unchanged.Original prompt
Update
action.ymlinnrfconnect/action-manifest-prso the workflow no longer blindly amends the top commit on the auto-manifest branch. The current implementation usesgit commit --amend --no-editin the synchronize and merged flows, which rewritesHEADeven when users have added commits on top of the original manifest commit. Implement logic that instead identifies the original manifest commit in the auto-manifest PR branch, rewrites that commit with the updatedwest.yml, and reapplies any later commits on top of it.Context:
nrfconnect/action-manifest-praction.ymlaction.yml#L177auto-manifest-${{ github.event.repository.name }}-${{ github.event.pull_request.number }}Retrigger CI by changing commit sha and pushingChange commit sha and push itRequirements:
HEAD.${{ inputs.base-branch }}and pushes the updated branch correctly.action.ymlto keep the workflow understandable and maintainable.Please create a pull request with the implementation and include a concise explanation in the PR description of how the commit-rewrite logic works and why it is needed.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: sometimes a user has another commit on top of the manifest change. can you amend the first commit in the PR instead of the top commit? and rebase the other other commits on top of it? or should I tell users to put the manifest change on the bottom.
Assistant: Yes — you should amend the manifest commit, not blindly amend
HEAD.Right now this step:
will always rewrite the top commit on the branch. If users add another commit after the manifest update, your workflow mutates the wrong commit.
Best approach:
I would not rely on telling users to “keep the manifest change on the bottom” unless you want a workflow convention instead of robustness. Automation is safer if it handles stacked commits correctly.
Recommended approach
In the
synchronizeand merged-path flows, replace the simple amend with a targeted history rewrite, for example using an interactive rebase scripted viaGIT_SEQUENCE_EDITOR/git rebase --onto, or by:west.yml,Pseudo-flow:
Then rebase onto the latest base branch if needed and push with
--force-with-lease.Important caveat
Matching only by commit subject is a little fragile. Better options:
X-Manifest-PR: true,Example commit message:
Then locate it with:
or a simpler grep over bodies.
My recommendation
Do bo...
This pull request was created from Copilot chat.