Skip to content

chore(all): sort repo metadata by key#15529

Merged
jskeet merged 2 commits intogoogleapis:mainfrom
jskeet:sort-repometadata
Feb 5, 2026
Merged

chore(all): sort repo metadata by key#15529
jskeet merged 2 commits intogoogleapis:mainfrom
jskeet:sort-repometadata

Conversation

@jskeet
Copy link
Contributor

@jskeet jskeet commented Feb 5, 2026

  • The CLI used by legacy librarian is modified to emit the metadata in key order
  • jq was used to sort all existing files

@jskeet jskeet requested review from a team as code owners February 5, 2026 10:48
@jskeet jskeet requested a review from chalmerlowe February 5, 2026 10:48
@jskeet
Copy link
Contributor Author

jskeet commented Feb 5, 2026

Note for reviewers:

  • The first commit was created by hand; review accordingly
  • The second commit was created just by running the command specified in the commit message, so the commit message is the bit to review

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jskeet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request aims to improve the consistency and maintainability of repository metadata by enforcing a standardized alphabetical ordering of keys within .repo-metadata.json files. This change proactively aligns the current metadata structure with upcoming updates in the Librarian tool, streamlining future metadata generation and management processes.

Highlights

  • Standardized Metadata Key Ordering: The pull request enforces alphabetical sorting of keys within repository metadata files (.repo-metadata.json).
  • CLI Tool Update: The .generator/cli.py script has been updated to automatically emit metadata with keys sorted alphabetically, anticipating future changes in the Librarian tool.
  • Bulk Metadata Reformatting: Numerous existing .repo-metadata.json files across various packages have been reordered using jq to conform to the new alphabetical key sorting standard.
Changelog
  • .generator/cli.py
    • Updated the _create_repo_metadata_from_service_config function to ensure generated repository metadata dictionary keys are sorted alphabetically.
    • Added a comment explaining the new alphabetical sorting requirement for metadata keys.
  • .librarian/generator-input/packages/*/repo-metadata.json
    • Alphabetically sorted keys within the JSON object for all affected repository metadata files.
  • packages/*/repo-metadata.json
    • Alphabetically sorted keys within the JSON object for all affected repository metadata files.
Activity
  • The pull request was created by jskeet.
  • The changes involve updating a Python script to enforce metadata key ordering and reformatting numerous existing JSON metadata files to comply with this new standard.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request sorts the keys in repository metadata files, which improves consistency. The change to .generator/cli.py ensures that newly generated metadata will also have sorted keys. I've added one suggestion to programmatically sort the keys in the generator script to make it more maintainable. Otherwise, the changes look good.

@jskeet
Copy link
Contributor Author

jskeet commented Feb 5, 2026

Not sure why the mypy and docs warnings tests failed...

This was automated with the following command:

```sh
for i in $(find . -name .repo-metadata.json); do jq --sort-keys . $i > tmp.json; mv tmp.json $i; truncate -s -1 $i; done
```

The "truncate" call is to remove the trailing linebreak from the file, which jq always emits.
@jskeet jskeet force-pushed the sort-repometadata branch from 9d35f45 to 4dee6dc Compare February 5, 2026 13:58
@jskeet jskeet enabled auto-merge (squash) February 5, 2026 14:34
Copy link
Contributor

@chalmerlowe chalmerlowe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jskeet jskeet merged commit 7da7768 into googleapis:main Feb 5, 2026
24 of 27 checks passed
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