Skip to content

refactor(pm): add catalog config support and rename init_project_root#2673

Merged
elrrrrrrr merged 2 commits into
nextfrom
refactor/pm-config-catalog
Mar 10, 2026
Merged

refactor(pm): add catalog config support and rename init_project_root#2673
elrrrrrrr merged 2 commits into
nextfrom
refactor/pm-config-catalog

Conversation

@elrrrrrrr

Copy link
Copy Markdown
Contributor

Summary

  • Add [catalog] and [catalogs.*] TOML sections to Config struct via serde deserialization
  • Add Config::catalogs() method and get_catalogs() accessor in user_config
  • Rename update_cwd_to_rootinit_project_root for clarity
  • Unit tests for catalog parsing (default, named, empty, coexistence with config values)

Prerequisite for the catalog protocol feature (feat/pm-catalog-protocol).

Test plan

  • cargo test -p utoo-pm -- util::config_file — 5 tests pass
  • cargo clippy -p utoo-pm --all-targets -- -D warnings --no-deps — clean

🤖 Generated with Claude Code

- Add `[catalog]` and `[catalogs.*]` sections to Config struct via serde
- Add `Config::catalogs()` method to build merged catalogs map
- Add `get_catalogs()` accessor in user_config (used by upcoming catalog protocol)
- Rename `update_cwd_to_root` to `init_project_root` for clarity
- Add unit tests for catalog parsing (default, named, empty, coexistence)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 primarily focuses on enhancing the project's configuration management system and improving code clarity. It introduces robust support for defining package catalogs through TOML configuration files, which is a foundational step for an upcoming catalog protocol feature. Concurrently, a key function responsible for initializing the project root has been renamed to better reflect its purpose, making the codebase more intuitive and maintainable.

Highlights

  • Catalog Configuration Support: Introduced support for [catalog] and [catalogs.*] TOML sections within the Config structure, enabling more flexible catalog definitions.
  • Catalog Accessor Methods: Added a Config::catalogs() method and a get_catalogs() accessor in user_config to retrieve parsed catalog configurations.
  • Function Renaming for Clarity: Renamed the update_cwd_to_root function to init_project_root across the codebase for improved clarity and semantic accuracy.
  • Unit Test Enhancements: Implemented comprehensive unit tests to validate the correct parsing of default, named, and empty catalog configurations, as well as their coexistence with other config values.
Changelog
  • crates/pm/src/cmd/update.rs
    • Updated the import and usage of the project root initialization function.
  • crates/pm/src/helper/workspace.rs
    • Renamed the update_cwd_to_root function to init_project_root.
    • Updated the documentation for the init_project_root function.
    • Adjusted the test case name to reflect the function rename.
  • crates/pm/src/main.rs
    • Replaced all calls to update_cwd_to_root with init_project_root in the main command processing logic.
  • crates/pm/src/service/install.rs
    • Modified the install service to use the newly named init_project_root function.
  • crates/pm/src/util/config_file.rs
    • Extended the Config struct to include catalog and catalogs fields for TOML deserialization.
    • Added a catalogs() method to aggregate catalog data.
    • Refactored the load method to cache merged configurations and correctly handle local catalog merging.
    • Added new unit tests for catalog parsing, covering default, named, empty, and coexistence scenarios.
  • crates/pm/src/util/user_config.rs
    • Introduced an asynchronous get_catalogs function to provide access to the parsed catalog configurations.
Activity
  • The author confirmed that cargo test -p utoo-pm -- util::config_file passed 5 tests.
  • The author confirmed that cargo clippy -p utoo-pm --all-targets -- -D warnings --no-deps ran cleanly.
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.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request successfully refactors the update_cwd_to_root function to init_project_root, improving clarity and providing better documentation. It also introduces comprehensive support for catalog configurations, including default and named catalogs, with appropriate serde deserialization attributes and a new accessor method. While these changes contribute positively to the codebase, the implementation introduces significant security risks in the configuration management logic. Specifically, there is a potential for local project settings to pollute the global configuration file and a process-wide cache that leads to cross-directory configuration leaks. These vulnerabilities should be addressed by separating global and local configuration states and ensuring that the cache is directory-aware or avoided for merged configurations.

Comment thread crates/pm/src/util/config_file.rs
Comment thread crates/pm/src/util/config_file.rs
@elrrrrrrr elrrrrrrr added the A-Pkg Manager Area: Package Manager label Mar 10, 2026

@killagu killagu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@elrrrrrrr elrrrrrrr merged commit 394559b into next Mar 10, 2026
24 checks passed
@elrrrrrrr elrrrrrrr deleted the refactor/pm-config-catalog branch March 10, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Pkg Manager Area: Package Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants