-
Notifications
You must be signed in to change notification settings - Fork 147
support 'west init --topdir' #854
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
base: main
Are you sure you want to change the base?
support 'west init --topdir' #854
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #854 +/- ##
==========================================
+ Coverage 84.40% 84.52% +0.12%
==========================================
Files 11 11
Lines 3385 3405 +20
==========================================
+ Hits 2857 2878 +21
+ Misses 528 527 -1
|
mbolivar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me
pdgendt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
652408c to
8a2e15e
Compare
|
I really want to review this one because I spent a lot of time on #774 and #775 but @thorsten-klein is just submitting way too much code, I can't keep up.
Can you give me a few more days? |
Sorry 🤞
Yes, sure 👍🏻 Thank you in advance for your time and input! |
a08dec0 to
99377aa
Compare
Seconded, and I'll take this opportunity to thank you for all your contributions @thorsten-klein. |
carlescufi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though I'd prefer —topdir was only compatible with -l, this is not a blocking issue for me. Thanks!
|
Let's wait for feedback from @marc-hb, as he requested some more time. |
marc-hb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is particularly useful when using --local
I downloaded this PR and tested the other, --manifest-url option and it does not seem to work for me. I ran out of time and did not try --local yet. I didn't look at the code either.
Describing directory nesting clearly and accurately is not easy - it is basically a "specification" except it has to be user-friendly too. So I will look at the code only when that "specification" is complete and unambiguous.
This help looks like the two last ones can be both used at the same time:
west init [-m URL] [--mr REVISION] [--mf FILE] [-o=GIT_CLONE_OPTION] [-t WORKSPACE_DIR] [directory]
But it's not actually possible:
FATAL ERROR: --topdir cannot be combined with positional argument [directory]
When using either separately, each one seems to have the same effect. So, there does not seem to be any new feature in the remote case, which means it's still not possible to west init a manifest two levels down or more in the remote case? Is this an oversight? The help does not seem to say. I don't see why --local would be more flexible than --manifest-url. I would hope the --manifest-url and --local options work the same immediately after the git clone operation.
|
|
Thank you for the review 🙏
Yes, exactly. Nevertheless, in remote case those arguments that do the same are mutually exclusive (see error message you got).
This has already worked before in remote case, since the positional argument Thank you 👍🏻 |
99377aa to
552f964
Compare
|
I think I have resolved all review comments in the code👍🏻 |
Has it? Please share one example of a |
Yes, you are right. I will push my changes where I have added support for this and also some test. |
552f964 to
67306db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gave the new version a try and I think I found two confirmed bugs, see below. Reproducing and describing these bugs was very time-consuming so I ran out of time again and I didn't look at the code again :-(
I love the energy but please be much more thorough in testing edge cases and addressing review comments, otherwise the limited review bandwidth cannot keep up. It's a bit counter-intuitive but in this case "slowing down" means finishing sooner.
There seems to be a large quantity of test code being added which is great! However the "quality" of the test code matters even more than its quantity. I mean being imaginative and trying hard to "break" the production code by reaching as many edge cases as possible is much more important than being repetitive. Too much test repetition only makes running the test suite longer.
Bug 1: spurious level in remote --topdir
# west init --topdir ws/ ws/manifest_dir/
$ tree -a -L 3 ws
ws
├── manifest_dir
│ └── zephyr # <=== !!
│ ├── .git
│
└── .west
└── config
I don't think this extra "zephyr" level matches the current --help text. Either way, I don't think the extra level is the correct behavior because the extra level is inconsistent with how the --local behavior treat the positional argument.
Funny enough, this rejoins my other observation that writing "workspace/manifest created 'in' X/" is ambiguous and a bad idea. Does "in" mean "X/.git" or "X/manifest/.git"? Unclear, avoid "in".
Bug 2: re-initialization is not always caught
I suspect the check that catches the re-initialization needs to be "upgraded" for the new --topdir
west init ws
cd ws
west init --local zephyr
FATAL ERROR: already initialized in ... # Good!
cd ..
west init --local --topdir ws/ ws/zephyr/
=== Initializing from existing manifest repository zephyr # What?
--- Creating ws/.west and local configuration file
=== Initialized. Now run "west update" inside ws.
Interestingly enough, .west/config does not seem to be modified - unlike what the logs pretend. So there may be more than one bug there. I mean check why the logs are lying BEFORE fixing the check.
src/west/app/project.py
Outdated
| If `-m / --manifest-url` is given, west clones the manifest repository from the | ||
| specified URL into a new workspace. Inside that workspace, the local config | ||
| option `manifest.path` will be set to point at this cloned directory (relative | ||
| path from the git clone to the workspace). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| path from the git clone to the workspace). | |
| path to the git clone from the workspace). |
src/west/app/project.py
Outdated
| West clones a remote repository (provided via `-m / --manifest-url`) into a new | ||
| workspace. The repositoy has to contain a west manifest. | ||
| Inside the new workspace, the local config option `manifest.path` is set to | ||
| point at the cloned directory (relative path to the workspace). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe that's because I'm not a native speaker (anyone?) but I still read this as "the path (that leads) to the workspace", which obviously does not sound right.
| point at the cloned directory (relative path to the workspace). | |
| point at the cloned directory (relative path from the workspace). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose naming analogue to pathlib where it also says .relative_to(other)
Ref: https://docs.python.org/3/library/pathlib.html
| --mf | ||
| The relative path to the manifest file within the manifest repository | ||
| (remote or local). Config option manifest.file will be set to this value. | ||
| Defaults to `{_WEST_YML}` if not provided. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Defaults to `{_WEST_YML}` if not provided. | |
| Defaults to '{_WEST_YML}' if not provided. |
Help texts generally don't use backquotes. I had a look and I don't think west has been so far.
Same issue below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are already some backslashes in the help of ManifestCommand (in this same file)
This is similar to `git status` for untracked files
Do you nevertheless prefer single quotes?
@marc-hb I’ve tried with the code to fail if the topdir is already initialized (when using |
You requested that west is able to create such a layout. The command for this is now: All projects will be cloned under |
ffda855 to
34985ff
Compare
467289a to
dd0e9e3
Compare
Added new argument for west init to specify the west topdir when a workspace is inizialized.
multiple combinations of arguments are tested as they can be provided to 'west init'.
dd0e9e3 to
8e07584
Compare
Fixes #774 (Successor of #775)
This PR introduces a new
--topdiroption forwest init, allowing users to explicitly specify the west workspace directory (topdir) during initialization.This is particularly useful when using
--local, as the current behavior always sets the parent of the given directory as the topdir. In addition, west is currently unable to determine bothmanifest.pathandmanifest.filefrom a singledirectoryargument as the path can be interpreted in multiple ways (e.g. it can be split at various places).With the new
--topdirargument, users can now directly control where the west workspace is created.Parameterized tests for
west init --topdirare added as well.Moreover, the help texts and descriptions are (hopefully) simplified.