diff --git a/bin/cml/ci.js b/bin/cml/ci.js index d50e0bc25..baae74343 100644 --- a/bin/cml/ci.js +++ b/bin/cml/ci.js @@ -14,6 +14,11 @@ exports.handler = async (opts) => { exports.builder = (yargs) => yargs.env('CML_CI').options( kebabcaseKeys({ + unshallow: { + type: 'boolean', + description: + 'Fetch as much as possible, converting a shallow repository to a complete one.' + }, userEmail: { type: 'string', default: GIT_USER_EMAIL, diff --git a/bin/cml/ci.test.js b/bin/cml/ci.test.js index e4ddca28c..cf29bcc26 100644 --- a/bin/cml/ci.test.js +++ b/bin/cml/ci.test.js @@ -14,6 +14,8 @@ describe('CML e2e', () => { --version Show version number [boolean] --log Maximum log level [string] [choices: \\"error\\", \\"warn\\", \\"info\\", \\"debug\\"] [default: \\"info\\"] + --unshallow Fetch as much as possible, converting a shallow repository to a + complete one. [boolean] --user-email Set Git user email. [string] [default: \\"olivaw@iterative.ai\\"] --user-name Set Git user name. [string] [default: \\"Olivaw[bot]\\"] --repo Set repository to be used. If unspecified, inferred from the diff --git a/src/cml.js b/src/cml.js index a38d73717..07f0e5b0c 100755 --- a/src/cml.js +++ b/src/cml.js @@ -330,11 +330,19 @@ class CML { } async ci(opts = {}) { - const { userEmail = GIT_USER_EMAIL, userName = GIT_USER_NAME } = opts; + const { + unshallow = false, + userEmail = GIT_USER_EMAIL, + userName = GIT_USER_NAME + } = opts; const driver = getDriver(this); - const command = await driver.updateGitConfig({ userName, userEmail }); - await exec(command); + await exec(await driver.updateGitConfig({ userName, userEmail })); + if (unshallow) { + if ((await exec('git rev-parse --is-shallow-repository')) === 'true') { + await exec('git fetch --unshallow'); + } + } await exec('git fetch --all'); }