Skip to main content

submodules

The modules a repository ships, as .gitmodules records them.

submodules(root: string): Submodule[]
submodules('/repos/acme')
// [{ name: 'widget', configName: 'apps/widget', relativePath: 'apps/widget',
//    path: '/repos/acme/apps/widget', url: 'https://…/widget.git', pinned: '4d946e0…' }]

Returns

Field
namelast path segment, which is what you name on the command line
configNamethe section name in .gitmodules, which config reads and writes
relativePathpath as recorded, relative to the repository
pathabsolute path
urlthe url recorded in .gitmodules
pinnedthe commit checked out when this was read

name and configName usually differ: a submodule at apps/widget is named widget on the command line and apps/widget in config.

An uninitialised submodule is left out — there is nothing to inspect until it is checked out.

repositoryRoot(from) finds the repository holding a directory, which is not the same as the monolith directory. Pass its result here.