{"id":16703462,"url":"https://github.com/mtardy/renovate-submodules-repro","last_synced_at":"2025-08-20T01:04:47.817Z","repository":{"id":210018973,"uuid":"725504203","full_name":"mtardy/renovate-submodules-repro","owner":"mtardy","description":"This is a minimal reproduction repo for a submodules issue with Renovate","archived":false,"fork":false,"pushed_at":"2024-03-13T08:56:15.000Z","size":9,"stargazers_count":0,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T08:22:49.642Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/renovatebot/renovate/discussions/25689","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtardy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-30T09:31:37.000Z","updated_at":"2024-03-14T13:44:52.000Z","dependencies_parsed_at":"2024-02-08T06:23:24.111Z","dependency_job_id":"b7483288-a5b7-4472-adc5-e41f10d08518","html_url":"https://github.com/mtardy/renovate-submodules-repro","commit_stats":null,"previous_names":["mtardy/renovate-submodules-repro"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mtardy/renovate-submodules-repro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtardy%2Frenovate-submodules-repro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtardy%2Frenovate-submodules-repro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtardy%2Frenovate-submodules-repro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtardy%2Frenovate-submodules-repro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtardy","download_url":"https://codeload.github.com/mtardy/renovate-submodules-repro/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtardy%2Frenovate-submodules-repro/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271247501,"owners_count":24725915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T19:08:25.008Z","updated_at":"2025-08-20T01:04:47.771Z","avatar_url":"https://github.com/mtardy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Renovate submodules issues repro\n\nThis is a minimal setup to reproduce the issue I encountered with Renovate\nupdating stables branches on repositories having submodules with different\nversion between branches.\n\n## Explanations\n\n### Situation\n\n1. main branch has a submodule pointing to commit A.\n2. stable branch has the same submodule pointing to commit B.\n3. renovate needs to update a dependency in the stable branch.\n4. renovate checkouts the repository on the main branch using `cloneSubmodules`.\n5. renovate checkouts the repository to stable (**and it does not update the submodule!** This is unfortunately the default behavior for git.).\n6. renovate bumps the dependency.\n7. renovate performs a `postUpgradeTask` for that specific update that has `fileFilters` to `**/**`.\n8. renovate save the files as part of post-upgrade since git sees a difference (submodules points to commit A now instead of B.).\n9. the PR includes an unwanted (and wrong) submodule change.\n\n### Result\n\nThe following is the debug log we get when renovate saves this *wrong* file:\n```\nDEBUG: Post-upgrade file saved (branch=\"renovate/stable-golang.org-x-sys-0.x\")\n{\n  \"baseBranch\": \"stable\"\n  \"dep\": \"golang.org/x/sys\"\n  \"file\": \"renovate\"\n  \"pattern\": \"**/**\"\n}\n```\n\nSee the third file included in the [stable branch PR dep upgrade](https://github.com/mtardy/renovate-submodules-repro/pull/5/files):\n\u003cimg width=\"1243\" alt=\"image\" src=\"https://github.com/mtardy/renovate-submodules-repro/assets/11256051/147547be-2b5d-4adb-a2a8-2b17022b17ab\"\u003e\n\n### Configuration\n\nThe minimal configuration for this is:\n```json\n{\n  \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n  \"extends\": [\n    \"config:recommended\"\n  ],\n  \"baseBranches\": [\n    \"main\",\n    \"stable\"\n  ],\n  \"cloneSubmodules\": true,\n  \"packageRules\": [\n    {\n      \"matchManagers\": [\"gomod\"],\n      \"postUpgradeTasks\": {\n        \"commands\": [\"pwd\"],\n        \"fileFilters\": [\"**/**\"],\n        \"executionMode\": \"branch\"\n      }\n    }\n  ]\n}\n```\n\nIt seems that this is a bug created by the fact that `cloneSubmodules` and\n`packageRules[].postUpgradeTasks.fileFilters = **/**` working together are\ncreating this situation.\n\n### How to fix this\n\nI guess a simple solution would be to renovate to use the following git config\nto true:\n```\ngit config submodule.recurse true\n```\n\nThis makes sure that when you checkout to another branch you also point your\nsubmodules to the correct commit, basically automating doing `git checkout\nanother-branch --recurse-submodules`.\n\n### Workaround\n\nI just realized by writing this that I could write a workaround using a\ndifferent `fileFilters` excluding the submodule file.\n\n---\n\n## Original message\n\nI'm maintaining a project with Renovate that has a git submodule (and use this\nsubmodule in go.mod replace directive). Thanks to the option cloneSubmodules it\nworks when I'm working on the main branch.\n\nBut when renovate needs to work on a stable branch, let's say v1.0, it `git\ncheckout v1.0` but does not update the submodule along (with `git submodule\nupdate --init \u003cmodule\u003e` for example). So I end up on the `v1.0` stable branch\nwith the content of the submodule folder corresponding to the one on the main\nbranch. It then creates a PR with the changes and thus bump the submodule\nversion to the one of the main branch because it never updated it to the\ncorrect commit.\n\nI hope this a clear explanation! Is there a way to fix that behavior?\nApparently, there are ways to immediately update submodules on checkout:\n\n- https://stackoverflow.com/a/55631474/4561420\n- https://stackoverflow.com/a/49427199/4561420\n- tl;dr -\u003e git config submodule.recurse true.\n\nIs there a way to add git configs to the renovate run to pass git config\nsubmodule.recurse true?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtardy%2Frenovate-submodules-repro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtardy%2Frenovate-submodules-repro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtardy%2Frenovate-submodules-repro/lists"}