Skip to content

Sort files section alphabetically in template.lock#422

Merged
tschm merged 2 commits intomainfrom
copilot/fix-template-lock-order
Mar 9, 2026
Merged

Sort files section alphabetically in template.lock#422
tschm merged 2 commits intomainfrom
copilot/fix-template-lock-order

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 9, 2026

_write_lock was preserving the arbitrary insertion order of lock.files when serialising to template.lock, making diffs noisy and the output non-deterministic across syncs.

Changes

  • _sync_helpers.py: existing_files is now built with sorted(...) and lock = dataclasses.replace(lock, files=existing_files) is unconditional — previously the replace only happened when files were missing from disk, so a no-missing-files sync left the list unsorted.
  • test_sync.py: Tightened test_write_lock_preserves_all_existing_files to assert exact order rather than sorted(data["files"]). Added test_write_lock_files_sorted_alphabetically to cover the unsorted-input case directly.
# Before: order depended on input
files=["z.txt", "a.txt", "m.txt"]  →  written as ["z.txt", "a.txt", "m.txt"]

# After: always alphabetical
files=["z.txt", "a.txt", "m.txt"]  →  written as ["a.txt", "m.txt", "z.txt"]
Original prompt

This section details on the original issue you should resolve

<issue_title>When writing template.lock</issue_title>
<issue_description>Write the file section in alphabetical order</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: tschm <2046079+tschm@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix writing template.lock file in alphabetical order Sort files section alphabetically in template.lock Mar 9, 2026
Copilot finished work on behalf of tschm March 9, 2026 06:30
@tschm tschm marked this pull request as ready for review March 9, 2026 06:31
@tschm tschm merged commit 06e6c47 into main Mar 9, 2026
15 checks passed
@tschm tschm deleted the copilot/fix-template-lock-order branch March 9, 2026 06:32
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.

When writing template.lock

2 participants