package download: don't get submodules if disabled (branch version)#6907
package download: don't get submodules if disabled (branch version)#6907waruqi merged 1 commit intoxmake-io:devfrom
Conversation
Summary of ChangesHello @SirLynix, 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 introduces a conditional check for cloning Git submodules during package downloads. Previously, submodules were always cloned recursively and shallowly when downloading a package from a branch. Now, a new option Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a bug where submodules were always cloned when downloading a package from a branch, ignoring the submodules = false configuration. The change aligns the behavior with how tags and revisions are handled, improving consistency. I've added one comment regarding a maintainability improvement to prevent similar issues in the future.
| -- only shallow clone this branch | ||
| git.clone(url, {depth = 1, recursive = true, shallow_submodules = true, longpaths = longpaths, branch = branch, outputdir = packagedir}) | ||
| -- only shallow clone this branch | ||
| local clone_submodules = opt.url_submodules ~= false |
There was a problem hiding this comment.
While this change correctly fixes the issue for cloning branches, it introduces another instance of the duplicated logic opt.url_submodules ~= false. This same logic exists on line 134 and line 147.
The very bug this PR fixes was due to this logic being present in other parts of the function but missing here. To improve maintainability and prevent similar bugs in the future, it would be best to consolidate this logic.
I recommend defining clone_submodules once at the beginning of the _checkout function and reusing it in all three places.
For example:
function _checkout(package, url, sourcedir, opt)
opt = opt or {}
local clone_submodules = opt.url_submodules ~= false
-- ... other initializations
-- ...
if branch then
-- ...
git.clone(url, {depth = 1, recursive = clone_submodules, shallow_submodules = clone_submodules, ...})
else
-- ...
if tag and git.clone.can_clone_tag() then
git.clone(url, {depth = 1, recursive = clone_submodules, shallow_submodules = clone_submodules, ...})
else
-- ...
if os.isfile(path.join(packagedir, ".gitmodules")) and clone_submodules then
git.submodule.update(...)
end
end
end
-- ...
endThis refactoring would make the code more robust and easier to maintain.
gemini was right for once