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

ci: add --unshallow #957

Merged
merged 6 commits into from
Apr 13, 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
5 changes: 5 additions & 0 deletions bin/cml/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions bin/cml/ci.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: \\"[email protected]\\"]
--user-name Set Git user name. [string] [default: \\"Olivaw[bot]\\"]
--repo Set repository to be used. If unspecified, inferred from the
Expand Down
14 changes: 11 additions & 3 deletions src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down