Skip to content

package download: don't get submodules if disabled (branch version)#6907

Merged
waruqi merged 1 commit intoxmake-io:devfrom
SirLynix:patch-20
Oct 8, 2025
Merged

package download: don't get submodules if disabled (branch version)#6907
waruqi merged 1 commit intoxmake-io:devfrom
SirLynix:patch-20

Conversation

@SirLynix
Copy link
Member

@SirLynix SirLynix commented Oct 8, 2025

gemini was right for once

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 opt.url_submodules can be used to disable this behavior, preventing submodules from being fetched if set to false. This change is implemented in the _checkout function within the download.lua module.

Highlights

  • Intent: This pull request aims to prevent the cloning of Git submodules during package download operations when explicitly disabled. Specifically, it addresses the 'branch version' of the download logic, ensuring that if url_submodules is set to false, submodules are not fetched.
  • Changes Highlights: The core change involves modifying the git.clone call within the package download mechanism to conditionally include submodules based on a new opt.url_submodules flag. This allows users to disable submodule fetching for specific package downloads.
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 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
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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
    -- ...
end

This refactoring would make the code more robust and easier to maintain.

@waruqi waruqi merged commit e4b2bc2 into xmake-io:dev Oct 8, 2025
18 of 22 checks passed
@SirLynix SirLynix deleted the patch-20 branch October 10, 2025 07:42
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