Issue #2402 : Support ~ (tilde) at start of path to resolve ${user.home} - #8256
Merged
Conversation
…ser.home}
- HopVfs: Add resolveHomeDirectory(path, variables) and resolveHomeDirectory(path)
to resolve ~ (bare ~), ~/... and ~\... (Windows backslash) as well as file://~...
to ${user.home}, while preserving non-start occurrences and non-separator suffixes.
- HopVfs: Update resolveWith() to expand leading tildes before scheme checking,
and update isAbsolutePath() to recognize tilde paths.
- hop-misc-projects: Recognize tilde paths in PathVariableReplacer.isCandidatePathValue()
and ProjectsMetadataExporter.resolveExportFilename().
- hop-misc-git: Delegate CaseInsensitiveIgnores.replaceUserHome() to HopVfs.resolveHomeDirectory().
- Documentation: Update vfs.adoc, variables.adoc, and projects-environments.adoc with
tilde home directory path usage and platform examples.
- Unit tests: Add test coverage in HopVfsTest and PathVariableReplacerTest.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2402
Description
In Apache Hop, specifying a path starting with
~(e.g.~/testenvor~\testenvon Windows) resulted in a folder literally named~created inside the Hop installation base directory (user.dir), because neither standard Java nor Apache Commons VFS expands tilde to the user's home directory.This PR adds system-wide support for
~(tilde) at the start of paths to mean${user.home}across Apache Hop on all platforms (including Windows with backslash\separators).Changes
hop-core):HopVfs.resolveHomeDirectory(String path, IVariables variables)andHopVfs.resolveHomeDirectory(String path).~,~/...,~\..., as well asfile://~...andfile:~...to${user.home}./opt/hop/~,foo~bar,s3://bucket/~/key) and non-separator suffixes (e.g.~username,~temp).${user.home}fromIVariableswhen provided, falling back toSystem.getProperty("user.home").resolveHomeDirectoryintoHopVfs.resolveWith()so that all file operations (getFileObject,fileExists,getInputStream, etc.) resolve tilde paths transparently.HopVfs.isAbsolutePath()to recognize tilde paths as absolute so they are not treated as relative to the working directory.hop-misc-projects):PathVariableReplacer.isCandidatePathValue()to accept tilde paths (~,~/...,~\...) for project variable rewriting.ProjectsMetadataExporter.resolveExportFilename()to useHopVfs.isAbsolutePath().hop-misc-git):CaseInsensitiveIgnores.replaceUserHome()toHopVfs.resolveHomeDirectory().vfs.adocdocumenting~under theFileprovider with POSIX and Windows syntax rules and examples.variables.adocwith a dedicated section on the~user home shortcut.projects-environments.adocdocumenting that~can be used in the project Home folder and environment variables.HopVfsTestandPathVariableReplacerTest.