From 628d7c4a3d7f49e4a2c45208789f46252786f547 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 5 Apr 2025 17:06:58 +0200 Subject: [PATCH] feat(git-node): auto-unshallow shallow clones NCU expects the local clone to not be shallow, and throws arguably confusing errors when running `git node land` on a shallow clone. We might pass the correct flag if we detect unshallowness. --- lib/session.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/session.js b/lib/session.js index c6bba9a6..59025af1 100644 --- a/lib/session.js +++ b/lib/session.js @@ -347,7 +347,8 @@ export default class Session { const { cli, upstream, branch } = this; const branchName = `${upstream}/${branch}`; cli.startSpinner(`Bringing ${branchName} up to date...`); - await runAsync('git', ['fetch', upstream, branch]); + const maybeUnshallow = fs.existsSync('.git/shallow') ? ['--unshallow'] : []; + await runAsync('git', ['fetch', ...maybeUnshallow, upstream, branch]); cli.stopSpinner(`${branchName} is now up-to-date`); const stray = this.getStrayCommits(true); if (!stray.length) {