Repository navigation
Preserve frontmatter comments and formatting during workflow updates - #74945
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✅ Ponytail Reviewer completed successfully!
|
This comment has been minimized.
This comment has been minimized.
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills... |
🏗️ Design Decision Gate — ADR RequiredThis PR adds a lot of core business logic (348 new lines in 📄 Draft ADR committed: The draft is based on the diff. It records the decision to rewrite
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and check that the implementation matches the decision. ❓ Why ADRs Matter
ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
What this change does: This change adds a YAML-node-based in-place import path rewrite so comments, quoting, ordering, and layout survive updates, with serialization as a fallback. It also adds a compatibility path for older canonicalized installations during three-way merges.
Should fix:
-
Legacy canonicalization does a redundant full parse (`pkg/cli/update_merge.go:L154-L166)
- What this is:
canonicalImportMergeContentserializes the parsed frontmatter and then callsRemoveTopLevelFieldFromFrontmatteron that newly generated content. - Problem:
MergeWorkflowContentalready removessourcefrom all three inputs before this helper runs, so every legacy merge reparses and rebuilds the same YAML without changing it. - Fix: Return
canonical, nildirectly, or removesourcefrom the map before marshaling. - If we skip it: Legacy merges keep paying for an unnecessary parse and retain an extra transformation path.
- What this is:
Verdict: fix 1 first.
Not checked: The targeted Go tests could not run because the installed toolchain attempted a download and TLS verification failed.
Lean: -1 lines possible.
Generated by ✂️ Ponytail Reviewer for #74945 · codex · routed: gpt56 max · ~6 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again
| if err != nil { | ||
| return "", err | ||
| } | ||
| return RemoveTopLevelFieldFromFrontmatter(canonical, "source") |
There was a problem hiding this comment.
Lean: base, current, and new have already had source removed before this helper is called, so this serializes the YAML and then reparses/rebuilds it through RemoveTopLevelFieldFromFrontmatter for no work; return canonical, nil (or remove source before marshaling) to avoid the redundant full parse on every legacy merge.
There was a problem hiding this comment.
canonicalImportMergeContent now returns the already source-free canonical content directly, avoiding the redundant parse/rebuild. Included in 643ed76.
There was a problem hiding this comment.
🟡 Changes recommended
The fallback in pkg/cli/update_merge.go discards upstream frontmatter comments and authored field order during otherwise conflict-free merges, requiring formatting preservation and exact-output regression coverage.
1 open issue
What changed in this PR
This PR reduces formatting churn in gh aw update by preserving frontmatter text during import processing, while adding compatibility handling for previously canonicalized installations.
Changes:
- Return unchanged imports verbatim and edit changed import scalars in place, with serialization as a fallback.
- Add legacy-format normalization to the three-way merge flow.
- Add regression tests for formatting preservation, import rewrites, and legacy merges.
| File | Description |
|---|---|
pkg/cli/update_merge.go |
Adds legacy frontmatter normalization before merging. |
pkg/cli/update_merge_test.go |
Tests commented workflows and legacy merge scenarios. |
pkg/cli/imports.go |
Adds targeted import edits that preserve surrounding YAML. |
pkg/cli/imports_test.go |
Tests unchanged content, scalar rewrites, and serialization fallbacks. |
Review effort: Balanced (auto)
| canonicalUpstream, err := canonicalImportMergeContent(upstream) | ||
| if err != nil { | ||
| return base, current, upstream | ||
| } | ||
| return stringutil.NormalizeWhitespace(canonicalBase), current, stringutil.NormalizeWhitespace(canonicalUpstream) |
There was a problem hiding this comment.
Legacy normalization now bypasses matching base/current frontmatter and restores upstream frontmatter formatting for genuine legacy merges. Exact-output regressions cover both cases. Commit: 643ed76.
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Request changes: the legacy merge compatibility path can erase upstream frontmatter comments and authored formatting before merging.
Highlights
- Preserve the raw upstream representation when entering the legacy normalization path.
- Add regression coverage proving upstream comments and field order survive.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~8 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| if err != nil { | ||
| return base, current, upstream | ||
| } | ||
| return stringutil.NormalizeWhitespace(canonicalBase), current, stringutil.NormalizeWhitespace(canonicalUpstream) |
There was a problem hiding this comment.
This legacy compatibility path canonicalizes the upstream input and silently discards its comments, quoting, and field order before the three-way merge.
💡 Preserve authored upstream formatting
When the current file happens to match the canonical form, canonicalImportMergeContent(upstream) reserializes the upstream workflow, so comments and layout that the PR otherwise promises to preserve are lost even when the merge is conflict-free. Keep the upstream text in its authored form (normalize only the comparison/base representation as needed), and add an assertion that upstream comments survive this legacy path.
There was a problem hiding this comment.
The legacy merge path now preserves raw upstream comments and authored field order instead of retaining the serialized fallback output. Commit: 643ed76.
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 07940e4
|
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 07940e4
|
|
@copilot resolve the merge conflicts in this pull request |
Sous-chef requested-head: 07940e4
Merged latest main, resolved both Go conflicts, and committed the merge as 643ed76. |
…ate-frontmatter-again # Conflicts: # pkg/cli/imports.go # pkg/cli/update_merge.go Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
🎉 This pull request is included in a new release. Release: |

Conflict-free
gh aw updatemerges re-serialized frontmatter containing imports, dropping comments, reordering keys, and reflowing lists—even when no import changed.