Skip to content

#1788: Created a commandlet to simulate the behaviour of ln -s#1847

Open
KarimALotfy wants to merge 35 commits into
devonfw:mainfrom
KarimALotfy:feature/1788-add-ln-commandlet-to-create-links
Open

#1788: Created a commandlet to simulate the behaviour of ln -s#1847
KarimALotfy wants to merge 35 commits into
devonfw:mainfrom
KarimALotfy:feature/1788-add-ln-commandlet-to-create-links

Conversation

@KarimALotfy
Copy link
Copy Markdown
Contributor

@KarimALotfy KarimALotfy commented Apr 23, 2026

This PR fixes #1788

Implemented changes:

Added ide ln -s commandlet to create file links.


Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal

@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Apr 23, 2026
@KarimALotfy KarimALotfy self-assigned this Apr 23, 2026
@KarimALotfy KarimALotfy moved this from 🆕 New to Team Review in IDEasy board Apr 23, 2026
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 23, 2026

Coverage Report for CI Build 26288406984

Warning

No base build found for commit 22c5b14 on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 71.115%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 15598
Covered Lines: 11567
Line Coverage: 74.16%
Relevant Branches: 6950
Covered Branches: 4468
Branch Coverage: 64.29%
Branches in Coverage %: Yes
Coverage Strength: 3.14 hits per line

💛 - Coveralls

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 23, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@jakozian jakozian left a comment

Choose a reason for hiding this comment

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

Nice approach! But i requested changes because most things regarding the issue can be done with FileAccess/FileAccessImpl.

Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
@jakozian jakozian self-requested a review April 24, 2026 12:22
@jakozian jakozian moved this from Team Review to 👀 In review in IDEasy board Apr 28, 2026
@KarimALotfy KarimALotfy moved this from 👀 In review to Team Review in IDEasy board Apr 28, 2026
@KarimALotfy KarimALotfy moved this from Team Review to 🏗 In progress in IDEasy board Apr 28, 2026
@KarimALotfy KarimALotfy added commandlet ide sub-command CLI IDEasy command-line-interface (parsing args, etc.) labels Apr 28, 2026
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
@jakozian jakozian moved this from 🏗 In progress to Team Review in IDEasy board Apr 29, 2026
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java
Comment thread cli/src/main/resources/nls/Help_de.properties
Comment thread cli/src/main/resources/nls/Help.properties
@KarimALotfy KarimALotfy moved this from Team Review to 🏗 In progress in IDEasy board Apr 30, 2026
@jakozian jakozian moved this from 🏗 In progress to Team Review in IDEasy board Apr 30, 2026
@KarimALotfy KarimALotfy moved this from Team Review to 🏗 In progress in IDEasy board Apr 30, 2026
…optional

- Added -f flag to control overriding of already existing links
- Changed ln description in Help.properties
@KarimALotfy KarimALotfy moved this from 👀 In review to Team Review in IDEasy board May 8, 2026
@KarimALotfy KarimALotfy moved this from Team Review to 👀 In review in IDEasy board May 8, 2026
Copy link
Copy Markdown
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@KarimALotfy thank you for all your updates and explanations. 👍
Now all looks good to me and is ready for merge.
@jakozian you requested changes. Can you approve as well to unblock the merge?

Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java
@hohwille
Copy link
Copy Markdown
Member

hohwille commented May 8, 2026

Unfortunately a failing test is now also blocking the merge:

[ERROR] Tests run: 5, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 0.102 s <<< FAILURE! -- in com.devonfw.tools.ide.commandlet.LnCommandletTest
[ERROR] com.devonfw.tools.ide.commandlet.LnCommandletTest.testForceOverridesExistingSymbolicLink -- Time elapsed: 0.032 s <<< FAILURE!
java.lang.AssertionError: 

Expecting code to raise a throwable.
	at com.devonfw.tools.ide.commandlet.LnCommandletTest.testForceOverridesExistingSymbolicLink(LnCommandletTest.java:150)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)

Is that caused by a side-effect from a change on main?
I did not change this PR but only rebased with main to resolve the conflict in the CHANGELOG.
But I can see that before that your commit aa91650 was build green.
Sorry for the long road to get this PR merged. Hope you do not get frustrated. We are very close to the final merge and finishing line... Thanks for your patience. 👍

@KarimALotfy
Copy link
Copy Markdown
Contributor Author

@hohwille the build now is successful after removing the failing test. It was not failing on my local since it is enabled only on Linux and Mac , and was actually unnecessary, since the -f flag doesn't have an effect on the link method, to keep existing functionality

Copy link
Copy Markdown
Member

@hohwille hohwille left a comment

Choose a reason for hiding this comment

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

@KarimALotfy thanks for your improvements. 👍
Sorry, if I still was not clear enough but my vision is that we make the boolean parameters override and relative configurable via flags.
You did this but only partially and I would love to have it consistent.

Comment thread cli/src/main/java/com/devonfw/tools/ide/io/FileAccessImpl.java Outdated
void createHardLink(Path source, Path link, boolean override) {
if (override && Files.exists(link, LinkOption.NOFOLLOW_LINKS)) {
delete(link);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would still expect this to be done also for symbolic links.
If we have an override flag added to link(Path source, Path link, boolean relative, PathLinkType type, boolean override) and JavaDoc says {@code true} to override existing links, {@code false} otherwise. then this looks inconsistent to me. Will Files.createSymbolicLink be idempotent? I guess not and mklink is not for sure.
So IMHO the implementation is not doing what you specified in the JavaDoc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions, implemented the suggested changes !

Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java Outdated
- Remove override parameter and force flag  from link method and ln commandlet
- Modified deleteLinkIfExists to handle all types of links
- Modified LnCommandletTest to handle all OS's in the same tests, instead of separating them by EnabledOnOs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI IDEasy command-line-interface (parsing args, etc.) commandlet ide sub-command

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Add ln commandlet to create links

5 participants