Skip to content

Commit

Permalink
tidy unshallow logic checks
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Oct 31, 2022
1 parent 7201881 commit 85a87fb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,20 +501,18 @@ class CML {
userName = GIT_USER_NAME,
remote = GIT_REMOTE
} = opts;
let { fetchDepth } = opts;
const { fetchDepth = unshallow ? 0 : undefined } = opts;

const driver = this.getDriver();
await exec(await driver.updateGitConfig({ userName, userEmail, remote }));
if (unshallow) {
if ((await exec('git rev-parse --is-shallow-repository')) === 'true') {
fetchDepth = 0;
}
}
if (fetchDepth !== undefined) {
if (fetchDepth <= 0) {
return await exec('git fetch --all --unshallow');
if ((await exec('git rev-parse --is-shallow-repository')) === 'true') {
return await exec('git fetch --all --unshallow');
}
} else {
return await exec(`git fetch --all --depth=${fetchDepth}`);
}
return await exec(`git fetch --all --depth=${fetchDepth}`);
}
}

Expand Down

2 comments on commit 85a87fb

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

Please sign in to comment.