Skip to content

Commit bb8bca1

Browse files
clydinKeen Yee Liau
authored andcommitted
fix(@angular/cli): allow update when git is unclean outside the workspace
1 parent 3af6bb9 commit bb8bca1

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/angular/cli/commands/update-impl.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,24 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
346346
checkCleanGit() {
347347
try {
348348
const result = execSync('git status --porcelain', { encoding: 'utf8', stdio: 'pipe' });
349+
if (result.trim().length === 0) {
350+
return true;
351+
}
349352

350-
return result.trim().length === 0;
351-
} catch {
352-
return true;
353-
}
353+
// Only files inside the workspace root are relevant
354+
for (const entry of result.split('\n')) {
355+
const relativeEntry = path.relative(
356+
path.resolve(this.workspace.root),
357+
path.resolve(entry.slice(3).trim()),
358+
);
359+
360+
if (!relativeEntry.startsWith('..') && !path.isAbsolute(relativeEntry)) {
361+
return false;
362+
}
363+
}
364+
365+
} catch { }
366+
367+
return true;
354368
}
355369
}

0 commit comments

Comments
 (0)