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

Add ci --fetch-depth, deprecate ci --unshallow #1233

Merged
merged 12 commits into from
Oct 27, 2022

Conversation

deepyaman
Copy link
Contributor

@deepyaman deepyaman commented Oct 19, 2022

Close #975

Development notes

I copied some stuff from https://github.com/actions/checkout/, including the description for the --fetch-depth option and the default values/error handling. One thing I didn't copy from there is the floor logic in https://raw.githubusercontent.com/actions/checkout/main/dist/index.js:

        result.fetchDepth = Math.floor(Number(core.getInput('fetch-depth') || '1'));

...but I could?

@deepyaman deepyaman temporarily deployed to external October 19, 2022 15:09 Inactive
Copy link
Contributor

@dacbd dacbd left a comment

Choose a reason for hiding this comment

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

@deepyaman looks good so far

src/cml.js Outdated Show resolved Hide resolved
@deepyaman deepyaman temporarily deployed to external October 19, 2022 17:53 Inactive
@deepyaman deepyaman temporarily deployed to external October 19, 2022 17:59 Inactive
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to external October 19, 2022 18:35 Inactive
@deepyaman deepyaman temporarily deployed to external October 19, 2022 22:47 Inactive
@deepyaman deepyaman marked this pull request as ready for review October 19, 2022 22:47
@deepyaman deepyaman requested a review from dacbd October 22, 2022 04:16
Copy link
Contributor

@dacbd dacbd left a comment

Choose a reason for hiding this comment

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

@deepyaman sorry for the delay. I have done some testing and identified a few issues.

Additionally @iterative/cml I'm not sure what or if its because GitHub Actions way that the action/checkout clones repos but providing a non-0 value doesn't result in the expected behavior... see here: https://github.com/iterative/cml-playground/actions/runs/3315755706/jobs/5476740449#step:5:2, however, running this locally does work as expected.

src/cml.js Outdated Show resolved Hide resolved
src/cml.js Outdated Show resolved Hide resolved
@deepyaman
Copy link
Contributor Author

@deepyaman sorry for the delay. I have done some testing and identified a few issues.

No worries, and thanks for the comments! I've gone ahead and applied the requested changes.

@casperdcl casperdcl added external-request You asked, we did good-first-issue Good for newcomers (good-first-issue) enhancement New feature or request cml-ci Subcommand labels Oct 24, 2022
bin/cml/repo/prepare.js Outdated Show resolved Hide resolved
src/cml.js Outdated Show resolved Hide resolved
src/cml.js Outdated
@@ -474,10 +475,13 @@ class CML {
await exec(await driver.updateGitConfig({ userName, userEmail, remote }));
if (unshallow) {
if ((await exec('git rev-parse --is-shallow-repository')) === 'true') {
await exec('git fetch --unshallow');
return await exec('git fetch --unshallow');
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this better?

Suggested change
return await exec('git fetch --unshallow');
fetchDepth = 0;

Also do we need to add git rev-parse --is-shallow-repository below?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so, but I haven't played with this. does git rev-parse --is-shallow-repository return true if the depth was already say 3? we wouldn't want to circumvent being able to expand this out directly.

Copy link
Contributor

@casperdcl casperdcl Oct 31, 2022

Choose a reason for hiding this comment

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

Needed to prevent errors; fixed as part of #1246

Copy link
Contributor

@dacbd dacbd left a comment

Choose a reason for hiding this comment

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

@deepyaman with deepyaman#1 we should be good to merge!

@deepyaman deepyaman temporarily deployed to external October 27, 2022 19:48 Inactive
@deepyaman
Copy link
Contributor Author

@deepyaman with deepyaman#1 we should be good to merge!

Merged it in, thanks!

FWIW when I looked through the code earlier to make a similar change (I think on other PRs), I think most of them just turned the whole block into let to handle cases that included non-constant variables, but I think this is better/safer?

@dacbd dacbd self-requested a review October 27, 2022 21:03
Copy link
Contributor

@dacbd dacbd left a comment

Choose a reason for hiding this comment

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

@deepyaman the first version probably didn't re-assign anything, If the linter sees the value is never update it changes it to a const.

@dacbd dacbd enabled auto-merge (squash) October 27, 2022 21:05
@dacbd dacbd merged commit bb04076 into iterative:master Oct 27, 2022
@deepyaman deepyaman deleted the feature/ci-fetch-depth branch October 28, 2022 02:16
Copy link
Contributor

@casperdcl casperdcl left a comment

Choose a reason for hiding this comment

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

@@ -469,15 +469,19 @@ class CML {
userName = GIT_USER_NAME,
remote = GIT_REMOTE
} = opts;
let { fetchDepth = 1 } = opts;
Copy link
Contributor

Choose a reason for hiding this comment

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

wait won't this now by default truncate non-shallow clones (as per SO#46004595)?

i.e. cml ci will now undo actions/checkout.with.fetch-depth: 0?

Copy link
Contributor

Choose a reason for hiding this comment

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

it does appear so. I'll do a follow up

Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cml-ci Subcommand enhancement New feature or request external-request You asked, we did good-first-issue Good for newcomers (good-first-issue)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ci: --fetch-depth
4 participants