Skip to content

improve to parse require#7031

Merged
waruqi merged 1 commit intodevfrom
require
Nov 17, 2025
Merged

improve to parse require#7031
waruqi merged 1 commit intodevfrom
require

Conversation

@waruqi
Copy link
Member

@waruqi waruqi commented Nov 17, 2025

@waruqi waruqi added this to the v3.0.5 milestone Nov 17, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @waruqi, 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 way Xmake handles the parsing of require strings. By extracting the parsing logic into a new, centralized utility module, the change aims to improve code organization, enhance reusability, and simplify future maintenance of the dependency resolution mechanism. This promotes a cleaner and more modular architecture for managing package requirements.

Highlights

  • Refactored require string parsing: The core logic for parsing require strings, which extracts package name, version, and repository information, has been moved from private.action.require.impl.package.lua to a new, dedicated utility function parse_requirestr within private.utils.package.lua.
  • Centralized utility adoption: Both xmake/core/project/project.lua and xmake/modules/private/action/require/impl/package.lua now import and utilize this new centralized parse_requirestr utility, ensuring consistent parsing behavior across the codebase.
  • Lazy loading for package_utils: The package_utils module is now lazily loaded in xmake/core/project/project.lua, which can contribute to optimizing resource usage by only importing the module when it's first needed.
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 refactors the parsing of require strings by moving the logic to a centralized utility function, package_utils.parse_requirestr. This is a good improvement as it centralizes the logic and fixes a bug in project.lua where a simplified and incorrect parsing implementation was used. The changes improve code organization and maintainability. I have one suggestion to make the code more concise.

Comment on lines +1141 to +1145
local package_utils = project._package_utils
if package_utils == nil then
package_utils = sandbox_module.import("private.utils.package", {anonymous = true})
project._package_utils = package_utils
end
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This block for loading and caching the package_utils module can be written more concisely. Using the or operator is a more idiomatic Lua approach, which improves readability and reduces verbosity.

            project._package_utils = project._package_utils or sandbox_module.import("private.utils.package", {anonymous = true})
            local package_utils = project._package_utils

@waruqi waruqi merged commit 1122dba into dev Nov 17, 2025
40 of 44 checks passed
@waruqi waruqi deleted the require branch November 17, 2025 07:28
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.

1 participant