Skip to content

Ensure git submodules aren't interacted with if no-submodules is configured#3289

Closed
CerealBoy wants to merge 3 commits intomainfrom
fix/no-submodules-on-mirrors
Closed

Ensure git submodules aren't interacted with if no-submodules is configured#3289
CerealBoy wants to merge 3 commits intomainfrom
fix/no-submodules-on-mirrors

Conversation

@CerealBoy
Copy link
Member

Description

When git submodules have been deactivated, do not run any submodule related commands even if submodules are potentially detected. There's a specific choice here for them to not be used, so even for cleaning operations this should be respected.

Context

Fixes #3286

Changes

Validate that --no-submodules is not active when cleaning the checkout path, other locations respect this flag however this did location did not.

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go fmt ./...)

@CerealBoy CerealBoy requested a review from a team April 24, 2025 06:21
Copy link
Contributor

@patrobinson patrobinson left a comment

Choose a reason for hiding this comment

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

Some minor feedback, I think this is good to go otherwise


// Git clean prior to checkout, we do this even if submodules have been
// disabled to ensure previous submodules are cleaned up
gitSubmodules := false
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment above this is no longer true. I can see it was added in #1054 but there's no more information about why it was added.

Copy link
Member Author

Choose a reason for hiding this comment

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

🤦🏼 I just read the comment and realised why this happened in the first place now.

Now I'm wondering what circumstances lead to this being the case, and how we could possibly cater for both situations.

Copy link
Contributor

Choose a reason for hiding this comment

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

AIUI, unless it's a clean checkout (directory doesn't exist, it was empty, or the agent is configured to always do clean checkouts), the agent is running the checkout against a directory containing code that was checked out in a previous job. So it might contain submodules, that have since been removed in whatever ref is being checked out now.

So I wonder if we can harden this in some other way? Such as making hasGitSubmodules more robust, or skipping submodule cleaning if the checkout itself is clean?

Copy link
Contributor

@patrobinson patrobinson left a comment

Choose a reason for hiding this comment

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

I'm happy with this, but it'd be good to get @DrJosh9000's feedback. I can't think of any negative consequences to not cleaning up old submodules but 🤷

@DrJosh9000 DrJosh9000 self-requested a review April 27, 2025 23:50
@CerealBoy
Copy link
Member Author

There's some additional context here that we've been missing, and chatting through it a bit more this is not the best approach to take. Closing this PR for the time being.

@CerealBoy CerealBoy closed this May 6, 2025
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.

Submodules not disabled for git mirrors

3 participants