Skip to content

Commit

Permalink
Remove default value for --fetch-depth (#1246)
Browse files Browse the repository at this point in the history
* temp

* no default for fetch-depth

* test update

* tidy unshallow logic checks

* slight docs update

Co-authored-by: Casper da Costa-Luis <casper.dcl@physics.org>
  • Loading branch information
dacbd and casperdcl committed Oct 31, 2022
1 parent 17a045e commit fc9e235
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 1 addition & 3 deletions bin/cml/repo/prepare.js
Expand Up @@ -22,9 +22,7 @@ exports.builder = (yargs) =>
exports.options = kebabcaseKeys({
fetchDepth: {
type: 'number',
default: 1,
description:
'Number of commits to fetch. 0 indicates all history for all branches and tags'
description: 'Number of commits to fetch (use `0` for all branches & tags)'
},
unshallow: {
type: 'boolean',
Expand Down
4 changes: 2 additions & 2 deletions bin/cml/repo/prepare.test.js
Expand Up @@ -20,8 +20,8 @@ describe('CML e2e', () => {
--help Show help [boolean]
Options:
--fetch-depth Number of commits to fetch. 0 indicates all history for all
branches and tags [number] [default: 1]
--fetch-depth Number of commits to fetch (use \`0\` for all branches & tags)
[number]
--user-email Git user email [string] [default: \\"olivaw@iterative.ai\\"]
--user-name Git user name [string] [default: \\"Olivaw[bot]\\"]"
`);
Expand Down
16 changes: 8 additions & 8 deletions src/cml.js
Expand Up @@ -501,19 +501,19 @@ class CML {
userName = GIT_USER_NAME,
remote = GIT_REMOTE
} = opts;
let { fetchDepth = 1 } = 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) {
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}`);
}
}
if (fetchDepth <= 0) {
return await exec('git fetch --all --unshallow');
}
return await exec(`git fetch --all --depth=${fetchDepth}`);
}

async prCreate(opts = {}) {
Expand Down

0 comments on commit fc9e235

Please sign in to comment.