Skip to content

chore(prepare): refactor common code into ProviderBase#8246

Merged
jdx merged 1 commit intojdx:mainfrom
halms:chore/refactor-prepare-common
Feb 18, 2026
Merged

chore(prepare): refactor common code into ProviderBase#8246
jdx merged 1 commit intojdx:mainfrom
halms:chore/refactor-prepare-common

Conversation

@halms
Copy link
Contributor

@halms halms commented Feb 18, 2026

While working on #8243, it looked like there was quite some boilerplate repeated throughout prepare providers.

This PR factors q bit out into a common ProviderBase.

It also removes the default-true-ambiguity raised by a review in #8243, by making this Option<bool> and resolving None as true in the ProviderBase.

This would now also allow having different per-provider defaults for touch_outputs.

Copilot AI review requested due to automatic review settings February 18, 2026 18:37
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @halms, 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 significantly refactors the prepare module by introducing a ProviderBase struct. This change aims to reduce code duplication across different prepare providers by centralizing common properties like project root, configuration, and provider identification. It also standardizes the handling of is_auto and touch_outputs flags, making the system more consistent and easier to extend with new providers.

Highlights

  • Introduction of ProviderBase: A new ProviderBase struct has been introduced to centralize common fields and logic shared across various PrepareProvider implementations, reducing boilerplate.
  • Refactored PrepareProvider Trait: The PrepareProvider trait now includes a base() method to access ProviderBase and provides default implementations for id(), is_auto(), and touch_outputs() that delegate to the base.
  • Standardized touch_outputs Configuration: The touch_outputs field in PrepareProviderConfig has been changed from a bool with a default true to an Option<bool>, with None now resolving to true within ProviderBase.
  • Provider Implementations Updated: All existing PrepareProvider implementations (Bun, Bundler, Composer, Custom, Go, Npm, Pip, Pnpm, Poetry, Uv, Yarn) have been updated to utilize the new ProviderBase for managing their id, project_root, config, and related methods.
Changelog
  • src/prepare/mod.rs
    • Added base() method to PrepareProvider trait to access ProviderBase.
    • Modified id(), is_auto(), and touch_outputs() methods in PrepareProvider trait to use default implementations that delegate to ProviderBase.
  • src/prepare/providers/bun.rs
    • Refactored BunPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/bundler.rs
    • Refactored BundlerPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/composer.rs
    • Refactored ComposerPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/custom.rs
    • Refactored CustomPrepareProvider to embed ProviderBase instead of id, config, and project_root directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/go.rs
    • Refactored GoPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/mod.rs
    • Added a new ProviderBase struct to encapsulate common provider data (id, project_root, config).
    • Implemented new(), is_auto(), and touch_outputs() methods for ProviderBase.
  • src/prepare/providers/npm.rs
    • Refactored NpmPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/pip.rs
    • Refactored PipPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/pnpm.rs
    • Refactored PnpmPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/poetry.rs
    • Refactored PoetryPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/uv.rs
    • Refactored UvPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/providers/yarn.rs
    • Refactored YarnPrepareProvider to embed ProviderBase instead of project_root and config directly.
    • Updated method implementations to access project_root, config, and id via the base field.
  • src/prepare/rule.rs
    • Changed touch_outputs field in PrepareProviderConfig from bool to Option<bool>.
    • Removed the default_true() helper function as Option<bool> handles the default logic within ProviderBase.
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 introduces a significant and valuable refactoring by creating a ProviderBase to consolidate common logic from the various PrepareProvider implementations. This greatly reduces boilerplate and improves maintainability. The change to use Option<bool> for touch_outputs is also a nice improvement for clarity. The overall implementation is well-done. I have a couple of minor suggestions to enhance encapsulation and API consistency.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors common boilerplate code across prepare providers into a shared ProviderBase structure. It simplifies provider implementations by centralizing the storage of id, project_root, and config fields, and provides default trait implementations for id(), is_auto(), and touch_outputs() methods. The PR also changes touch_outputs from a boolean with a default value to an Option<bool>, moving the default resolution logic to ProviderBase which enables future per-provider customization.

Changes:

  • Introduced ProviderBase struct to hold common provider state (id, project_root, config)
  • Changed touch_outputs field from bool with #[serde(default = "default_true")] to Option<bool>, resolving None as true in ProviderBase
  • Refactored all 11 prepare providers to use ProviderBase and removed duplicate id(), is_auto(), and touch_outputs() implementations

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/prepare/rule.rs Changed touch_outputs from bool with default to Option<bool>, removing the default_true() helper function
src/prepare/providers/mod.rs Added ProviderBase struct with common fields and helper methods for is_auto() and touch_outputs()
src/prepare/mod.rs Added base() method to PrepareProvider trait and provided default implementations for id(), is_auto(), and touch_outputs()
src/prepare/providers/yarn.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/uv.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/poetry.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/pnpm.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/pip.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/npm.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/go.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/custom.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/composer.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/bundler.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations
src/prepare/providers/bun.rs Refactored to use ProviderBase, replacing direct fields and removed duplicate method implementations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@halms
Copy link
Contributor Author

halms commented Feb 18, 2026

/gemini review

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 introduces a significant and well-executed refactoring of the prepare providers. By creating a common ProviderBase struct, a large amount of boilerplate code has been eliminated from each individual provider, which greatly improves maintainability and readability. The changes are consistent across all providers, and the new structure is clean and logical. The modification to touch_outputs to use Option<bool> is also a nice improvement for configuration flexibility. Overall, this is an excellent change that strengthens the codebase.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jdx jdx merged commit 0b6903b into jdx:main Feb 18, 2026
38 of 39 checks passed
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Feb 22, 2026
## [2026.2.18](https://github.com/jdx/mise/compare/v2026.2.17..v2026.2.18) - 2026-02-21

### 🚀 Features

- **(install)** auto-lock all platforms after tool installation by @jdx in [#8277](jdx/mise#8277)

### 🐛 Bug Fixes

- **(config)** respect --yes flag for config trust prompts by @jdx in [#8288](jdx/mise#8288)
- **(exec)** strip shims from PATH on Unix to prevent infinite recursion by @jdx in [#8276](jdx/mise#8276)
- **(install)** validate --locked before --dry-run short-circuit by @altendky in [#8290](jdx/mise#8290)
- **(release)** refresh PATH after mise up in release-plz by @jdx in [#8292](jdx/mise#8292)
- **(schema)** replace unevaluatedProperties with additionalProperties by @jdx in [#8285](jdx/mise#8285)
- **(task)** avoid duplicated stderr on task failure in replacing mode by @jdx in [#8275](jdx/mise#8275)
- **(task)** use process groups to kill child process trees on Unix by @jdx in [#8279](jdx/mise#8279)
- **(task)** run depends_post tasks even when parent task fails by @jdx in [#8274](jdx/mise#8274)
- **(task)** suggest similar commands when mistyping a CLI subcommand by @jdx in [#8286](jdx/mise#8286)
- **(task)** execute monorepo subdirectory prepare steps from root by @jdx in [#8291](jdx/mise#8291)
- **(upgrade)** don't force-reinstall already installed versions by @jdx in [#8282](jdx/mise#8282)
- **(watch)** restore terminal state after watchexec exits by @jdx in [#8273](jdx/mise#8273)

### 📚 Documentation

- clarify that MISE_CEILING_PATHS excludes the ceiling directory itself by @jdx in [#8283](jdx/mise#8283)

### Chore

- replace gen-release-notes script with communique by @jdx in [#8289](jdx/mise#8289)

### New Contributors

- @altendky made their first contribution in [#8290](jdx/mise#8290)

### 📦 Aqua Registry Updates

#### New Packages (4)

- [`Skarlso/crd-to-sample-yaml`](https://github.com/Skarlso/crd-to-sample-yaml)
- [`kunobi-ninja/kunobi-releases`](https://github.com/kunobi-ninja/kunobi-releases)
- [`swanysimon/markdownlint-rs`](https://github.com/swanysimon/markdownlint-rs)
- [`tmux/tmux-builds`](https://github.com/tmux/tmux-builds)

#### Updated Packages (2)

- [`firecow/gitlab-ci-local`](https://github.com/firecow/gitlab-ci-local)
- [`k1LoW/runn`](https://github.com/k1LoW/runn)

## [2026.2.17](https://github.com/jdx/mise/compare/v2026.2.16..v2026.2.17) - 2026-02-19

### 🚀 Features

- **(prepare)** update mtime of outputs after command is run by @halms in [#8243](jdx/mise#8243)

### 🐛 Bug Fixes

- **(install)** use backend bin paths for per-tool postinstall hooks by @jdx in [#8234](jdx/mise#8234)
- **(use)** write to config.toml instead of config.local.toml by @jdx in [#8240](jdx/mise#8240)
- default legacy .mise.backend installs to non-explicit by @jean-humann in [#8245](jdx/mise#8245)

### 🚜 Refactor

- **(config)** consolidate flat task_* settings into nested task.* by @jdx in [#8239](jdx/mise#8239)

### Chore

- **(prepare)** refactor common code into ProviderBase by @halms in [#8246](jdx/mise#8246)

### 📦 Aqua Registry Updates

#### Updated Packages (1)

- [`namespacelabs/foundation/nsc`](https://github.com/namespacelabs/foundation/nsc)
risu729 pushed a commit to risu729/mise that referenced this pull request Feb 27, 2026
While working on jdx#8243, it looked like there was quite some boilerplate
repeated throughout prepare providers.

This PR factors q bit out into a common `ProviderBase`.

It also removes the default-true-ambiguity raised by a review in jdx#8243,
by making this `Option<bool>` and resolving None as true in the
`ProviderBase`.

This would now also allow having different per-provider defaults for
`touch_outputs`.
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.

3 participants