lazygit
lazygit copied to clipboard
Global submodules view
Describe the solution you'd like
It would be great if submodules
tab could show all submodules of the current project recursively. Not only submodules of the current context, but also submodules of submodules, etc. As one list
I agree that this could be useful, but it's a bit tricky to do. Here's a hacky commit that provides the basics if you want to try it; no PR yet, as this is not really good enough yet.
Problems:
- showing the nested submodules only works once the submodules are checked out. The reason is that lazygit parses the
.gitmodules
file to determine which submodules exist. That's probably an acceptable limitation in practice. - entering a submodule works, and that's probably the functionality that you're expecting most (I guess). However, there are other things that you can do to a submodule (remove, update, etc), and those commands can't be done in the top-level repo, so right now they fail with an error message. It would probably be possible to make them work by cd'ing into the directory of the direct parent repo, but I haven't done that yet.
- submodules have a name and a path; constructing the nested path is straightforward, but the name needs to be synthesized somehow. In the commit referenced above I chose to do that in the same way as the path, by joining the parent name and the nested name with a
/
. I'm not sure that's good though, as it blurs the difference between name and path even more (many people have trouble understanding the difference, it seems).
@vikulikov Let me know if this is going into a direction that you find useful.
I think yes, it is. There is also a git
command that lets you run arbitrary commands on every submodule in the project recursively (git submodule foreach --recursive '<your command>'
). Can it be useful for this feature? Maybe it can let you rid of the file parsing
I know, but it's too slow for our purpose, because it spawns a shell process for every submodule; especially on Windows, where forking subprocesses is expensive.
@vikulikov Here's a PR: #3341. Can you please test it?
Great! It works perfectly