Skip to content

Commit 7bf2350

Browse files
authored
feat(git-node): auto-unshallow shallow clones (#918)
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.
1 parent a88776b commit 7bf2350

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/session.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ export default class Session {
347347
const { cli, upstream, branch } = this;
348348
const branchName = `${upstream}/${branch}`;
349349
cli.startSpinner(`Bringing ${branchName} up to date...`);
350-
await runAsync('git', ['fetch', upstream, branch]);
350+
const maybeUnshallow = fs.existsSync('.git/shallow') ? ['--unshallow'] : [];
351+
await runAsync('git', ['fetch', ...maybeUnshallow, upstream, branch]);
351352
cli.stopSpinner(`${branchName} is now up-to-date`);
352353
const stray = this.getStrayCommits(true);
353354
if (!stray.length) {

0 commit comments

Comments
 (0)