Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default value for --fetch-depth #1246

Merged
merged 6 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions bin/cml/repo/prepare.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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: \\"[email protected]\\"]
--user-name Git user name [string] [default: \\"Olivaw[bot]\\"]"
`);
Expand Down
16 changes: 8 additions & 8 deletions src/cml.js
Original file line number Diff line number Diff line change
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) {
dacbd marked this conversation as resolved.
Show resolved Hide resolved
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