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 option to specify git clone options like --depth for Zephyr repo clone via init #744

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

usmanimtiaz63
Copy link
Contributor

Although clone-depth is provided to use for update command, the --depth option is not provided for init without -l. It adds this option.

Copy link
Collaborator

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

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

Squash related changes into a single commit, and add tests.

src/west/app/project.py Outdated Show resolved Hide resolved
@pdgendt
Copy link
Collaborator

pdgendt commented Oct 4, 2024

My previous comment is still valid, squash all commits into a single commit, and force push to this PR.

Add test case(s) to tests/test_project.py (this should go in a separate commit)

src/west/app/project.py Outdated Show resolved Hide resolved
@marc-hb marc-hb changed the title Add option to specify clone depth for Zephyr repo clone via init Add option to specify git clone options like --depth for Zephyr repo clone via init Oct 4, 2024
@marc-hb
Copy link
Collaborator

marc-hb commented Oct 4, 2024

Mmmm... this looks a bit suspiciously "too simple" / too good to be true...

I think we had this "for free" before simplification e283d99, so now I wonder why @mbolivar didn't add this back sooner, especially considering the countless optimization discussions : performance How long things take and notably all the benchmarking performed in #496 and #319...

@marc-hb
Copy link
Collaborator

marc-hb commented Oct 4, 2024

At the risk of stating the obvious, the slightly slower alternative is to git clone manifest-repo.git and west init -l. So this PR is not adding any "new feature" but just saving one step.

@marc-hb
Copy link
Collaborator

marc-hb commented Oct 4, 2024

My previous comment is still valid, squash all commits into a single commit, and force push to this PR.

@usmanimtiaz63 , the Zephyr project does not use GitHub in the usual way. It uses it in the "traditional git", pre-GitHub way. Long story in:

zephyrproject-rtos/zephyr#39194 (comment)

@usmanimtiaz63
Copy link
Contributor Author

Local Test run:

image
image

@usmanimtiaz63 usmanimtiaz63 requested a review from pdgendt October 4, 2024 16:47
@usmanimtiaz63
Copy link
Contributor Author

My previous comment is still valid, squash all commits into a single commit, and force push to this PR.

@usmanimtiaz63 , the Zephyr project does not use GitHub in the usual way. It uses it in the "traditional git", pre-GitHub way. Long story in:

zephyrproject-rtos/zephyr#39194 (comment)

Yeah, Its my first contribution, so thank you for guiding me for the workflow.

@usmanimtiaz63
Copy link
Contributor Author

At the risk of stating the obvious, the slightly slower alternative is to git clone manifest-repo.git and west init -l. So this PR is not adding any "new feature" but just saving one step.

Yes, previously I used it with -l, But now I updated it for me, so thought to submit a PR.

@mbolivar
Copy link
Contributor

mbolivar commented Oct 4, 2024

why @mbolivar didn't add this back sooner

All the optimization work we did on west update was targeted at CI use cases where the manifest repository was already cloned, since the git forge workflows typically give you an environment where an MR is already checked out.

This looks fine to me!

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

Minor test change requested, everything else looks good, thanks!

west_tmpdir = repos_tmpdir / 'workspace'

cmd(['init', '-o=--depth=1', west_tmpdir])
west_tmpdir.chdir()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This chdir seems unnecessary because you're already using cwd= below.

chdir is a great concept in subshells and other subprocesses because it's "stateless"; does not propagate up or interferes in any way. But it's not great in programs where you need to keep track of it across functions, exceptions, break, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

tests/test_project.py Outdated Show resolved Hide resolved
@@ -186,6 +186,10 @@ def do_add_parser(self, parser_adder):
parser.add_argument('-m', '--manifest-url',
help='''manifest repository URL to clone;
cannot be combined with -l''')
parser.add_argument('-o', '--clone-opt', action='append', default=[],
help='''additional option to pass to 'git clone'
(e.g. '-o=--depth=1'); may be given more than once;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just FYI, I tested this PR and compared:

1. west init -o=--depth=1
2. west init -o=--filter=tree:0

The latter took 30% longer and 10% more disk but has a complete git log and does not break git describe. We've been using it in CI for a couple years now and it's a much better choice there.

@marc-hb
Copy link
Collaborator

marc-hb commented Oct 5, 2024

Local Test run:

Just FYI: https://docs.zephyrproject.org/latest/develop/getting_started/index.html#use-copy-paste

tests/test_project.py Outdated Show resolved Hide resolved
@marc-hb marc-hb merged commit 1007557 into zephyrproject-rtos:main Oct 8, 2024
16 checks passed
@usmanimtiaz63 usmanimtiaz63 deleted the shallow_clone branch October 8, 2024 15:24
@pdgendt pdgendt added this to the v1.3.0 milestone Oct 9, 2024
@marc-hb marc-hb added the performance How long things take label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance How long things take
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants