Skip to content

Commit

Permalink
fix: skip "untracked repository" warning for git submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Nov 11, 2024
1 parent b86e55f commit d2980de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/commands/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,16 @@ async function cloneMissingRepos(cfg: RootConfig, skipOptional?: boolean) {

async function findUnknownRepos(cfg: RootConfig, packages: PackageMap) {
const gitRoots = git.findRoots(cfg, Object.values(packages))
const gitSubmodules = git.loadSubmodules(cfg.root)

let changed = false
for (let rootId of Array.from(gitRoots)) {
if (cfg.repos[rootId] || rootId.startsWith('..')) {
continue
}
if (gitSubmodules.includes(rootId)) {
continue
}
const cwd = join(cfg.root, rootId)
if (fs.isDir(join(cwd, '.git'))) {
warn(`Found an untracked repository: ${rootId}`)
Expand Down
3 changes: 3 additions & 0 deletions src/core/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export const git = {
}
return gitRoots
},
loadSubmodules(cwd: string) {
return exec.sync(`git submodule --quiet foreach 'echo $path'`, { cwd })
},
}

function parseGitString(
Expand Down

0 comments on commit d2980de

Please sign in to comment.