#2133: add repository navigation option to icd command#2153
#2133: add repository navigation option to icd command#2153Ali-Shariati-Najafabadi wants to merge 8 commits into
Conversation
Coverage Report for CI Build 29602468709Coverage remained the same at 72.506%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
maybeec
left a comment
There was a problem hiding this comment.
Thanks for this contribution — the implementation covers the issue requirements well. I verified all scenarios from #2133 hands-on: sourced the functions file from this PR against a synthetic IDE_ROOT (with a stubbed ideasy) and exercised every path in bash and in zsh 5.9. zsh matters here because IdeasyCommandlet wires source "$IDE_ROOT/_ide/installation/functions" into .zshrc as well, and zsh is the default shell on macOS.
Verification against issue #2133
| Requirement (#2133) | Result |
|---|---|
1: icd -p X -r falls back to the project name |
✅ verified |
| 1: no project-name folder, but exactly one non-hidden folder in the workspace → enter it | ✅ verified |
| 1: otherwise cd into the workspace and log a warning | ✅ bash — ❌ zsh aborts when the workspace is empty (see inline comment) |
2: explicit icd -p X -r «repo», incl. nested paths like -r backend/core (example B) |
✅ verified |
2/3: resolved in the given workspace, or searched main first, then all other workspaces |
✅ verified |
| 4: clear error message when not found | ✅ bash — ❌ zsh aborts when workspaces is missing/empty; wording misleading with explicit -w (see inline comments) |
Help text + documentation/cli.adoc updated |
✅ |
Must-fix
-
zsh: the new workspace-scan globs abort
icd— see the inline comment infunctions(includes a verified one-click fix). -
Missing CHANGELOG.adoc entry. #2133 is not labeled
internal, so per the PR checklist and the DoD the issue must be added to CHANGELOG.adoc under the next open release (currently the== 2026.07.002section):* https://github.com/devonfw/IDEasy/issues/2133[#2133]: Add repository navigation option (-r) to icd command
Should-address
- No automated tests, although a test harness for this exact file exists and runs in CI:
cli/src/test/functions-test.shunit-tests thefunctionsfile and is executed on every PR build (see.github/workflows/build-pr.yml). TDD is our standard for features (seeAGENTS.md), and your manual testing instructions map 1:1 to automatable checks using the existing pattern there (freshbash --noprofile --norc, stubideasyonPATH, temporaryIDE_ROOTtree). Suggested minimum cases: repo found inmain; repo found in another workspace; explicit-wrestricting the search; not found → exit code 1 + error message; implicit-rresolving the project-name folder; single-folder fallback; warning + cd into the workspace for an empty/ambiguous workspace. Is this planned as a follow-up, or can it land in this PR? - Misleading error message when
-wis given explicitly — see inline suggestion infunctions.
Minor
- Testing instructions step 5 is outdated since the fallback behavior was added: with the tree from step 1 (
mainonly containscli),icd -p IDEasy -rnow lands inworkspaces/main/clivia the single-folder fallback — not inworkspaces/main/IDEasy(that folder is never created in step 1). Verified in bash. Please update the PR description (e.g. createworkspaces/main/IDEasyfor step 5 and add a separate step for the single-folder fallback). - Docs: nested repository paths are supported but not documented — see inline suggestion on
cli.adoc.
Everything else looks good: the option parsing is consistent with the existing -w handling, the search order matches the issue, existing icd invocations without -r are unaffected, --help and the docs are updated, CI is green, and the branch is up to date with main.
|
One design concern about the implicit When I would find it more intuitive to drop the auto-descend and always cd into the workspace with the existing warning when the project-name folder is not found — i.e. treat the "exactly one folder" case the same as the ambiguous case. Then @vivu001 was there a specific use case behind the single-folder shortcut in #2133? If we agree to change this, the issue should be updated accordingly and this PR would actually get simpler (the fallback block shrinks to warning + cd into the workspace). |
|
Hi @maybeec , thanks for the suggestion. I think the concern about implicit behavior is well-founded. To make the behavior explicit, I would summarize your suggestion as follows:
About the single-folder shortcut: there does not seem to be a strong functional use case behind it. It mainly acts as a convenience shortcut, but introduces implicit behavior. A hybrid approach (strict default behavior with optional convenience) could work. I even considered something along these lines:
Overall, keeping repository selection explicit aligns better with the goal of making behavior clear and unambiguous. |
Co-authored-by: Malte Brunnlieb <maybeec@users.noreply.github.com>
Co-authored-by: Malte Brunnlieb <maybeec@users.noreply.github.com>
Co-authored-by: Malte Brunnlieb <maybeec@users.noreply.github.com>
This PR fixes #2133
Implemented changes:
-r | --repository [<repository>]option to theicdshell function incli/src/main/package/functions<repository>is omitted, the project name is used as the repository name (fallback)-wis not given, workspacemainis searched first, then all other workspaces;icdnavigates into the first workspace containing the repository-wis given explicitly, only that workspace is searched (no fallback)icdfails withError: Repository '<name>' not found in any workspace.icd --helpusage/options textdocumentation/cli.adocwith a description and example of the new optionTesting instructions
Run the automated test suite, which covers all scenarios from #2133 in both bash and zsh:
bash cli/src/test/functions-test.sh
Checklist for this PR
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»In Progressand assigned to you or there is no issueinternal