Skip to content

feat: format package.xml dependencies into sorted blocks by tag - #31

Merged
emersonknapp merged 1 commit into
mainfrom
emerson/package-xml-format
Nov 24, 2026
Merged

emersonknapp merged 1 commit into
mainfrom
emerson/package-xml-format

Conversation

@emersonknapp

@emersonknapp emersonknapp commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Format the dependencies of ROS package.xml files in the polymath-xml hook, and release 2.8.0.
Unsorted, ungrouped dependency lists are hard to read and give noisy diffs.

  • Group dependencies into one blank-line separated block per tag, in lifecycle order: buildtool_depend, buildtool_export_depend, build_depend, build_export_depend, depend, exec_depend, test_depend, doc_depend.
  • Sort each block by package name, with condition as the tie breaker.
  • Keep a comment between dependencies as the head of a section, which stays together and sorted after the uncommented block of its tag.
    A section runs to the next blank line or comment.
  • Move a trailing comment with its dependency, and sort a commented-out dependency as a dependency.
  • Rewrite files in place like polymath-yaml, and fail with an error instead of guessing on layouts it cannot rewrite line by line.
  • Format only files named package.xml, of format 2 or 3, that pass schema validation.
    Everything outside the dependency list stays byte for byte.

Tested against an internal repository, it rewrites package.xml files, raises no errors, and is idempotent.

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp
emersonknapp marked this pull request as ready for review November 24, 2026 00:17
@emersonknapp
emersonknapp merged commit 6ec8dde into main Nov 24, 2026
4 checks passed
@emersonknapp
emersonknapp deleted the emerson/package-xml-format branch November 24, 2026 00:18
@Timple

Timple commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

So like https://github.com/tier4/pre-commit-hooks-ros#sort-package-xml ?

Do we need a new one or can we improve that one?

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.

2 participants