Allow overriding hardcoded branch for git submodules #24785
Replies: 3 comments
-
This may require a refactor of our git-submodules first. |
Beta Was this translation helpful? Give feedback.
-
@rarkins I realized there's a much quicker solution that would at least solve the "non-master default branch" use case for this, if not the fully manually configurable in Something similar was already discussed in the initial PR when the submodule feature was added, but not used for some reason: git ls-remote --symref <URL> HEAD will print out the default remote branch without cloning, regardless of the platform, e.g.: $ git ls-remote --symref https://github.com/renovatebot/renovate.git HEAD
ref: refs/heads/master HEAD
2ac6c392c27c3fd423a3f88d9d9221fb581b2368 HEAD With some splitting/trimming it should be easy to get the branch from the first line. So maybe an additional function is enough, which can then be called in async function getDefaultBranch(
subModuleUrl: string
): Promise<string> {
return (
(await Git().raw([
'ls-remote',
'--symref',
subModuleUrl,
'HEAD',
]))
).trim(); // and some splitting
} GitHub will switch to |
Beta Was this translation helpful? Give feedback.
-
Hi there, Get your issue fixed faster by creating a minimal reproduction. This means a repository dedicated to reproducing this issue with the minimal dependencies and config possible. Before we start working on your issue we need to know exactly what's causing the current behavior. A minimal reproduction helps us with this. To get started, please read our guide on creating a minimal reproduction. We may close the issue if you, or someone else, haven't created a minimal reproduction within two weeks. If you need more time, or are stuck, please ask for help or more time in a comment. Good luck, The Renovate team |
Beta Was this translation helpful? Give feedback.
-
What would you like Renovate to be able to do?
Add the ability to configure a branch to update git submodules from, instead of the default master, e.g. in cases where you want to update internal dependencies from
devel
/develop
/development
etc.Currently the git submodule manager defaults to a hardcoded master if the super-repo
.gitmodules
doesn't explicitly specify a branch for the submodule:renovate/lib/manager/git-submodules/extract.ts
Lines 42 to 48 in 65839b7
This would allow updating internal projects using git flow, but in recent days there has been some development that will make this more relevant as GitHub and GitLab (and even discussions for git) are either making the default configurable or moving away from
master
as the default branch in some cases.Describe the solution you'd like
An option in
renovate.json
to configure the branch, e.g.:Bonus: it'be great if this could be combined with package rules or similar (so that e.g.
libs/internal
can havedevelopment
whilelibs/external
havemaster
)Describe alternatives you've considered
You can define tracking branches explicitly for every project in
.gitmodules
but this is not always desired and can be a pain for projects with many submodules.Beta Was this translation helpful? Give feedback.
All reactions