mattcasters commented on issue #2597:
URL: https://github.com/apache/hop/issues/2597#issuecomment-5015682533

   ## Implemented: path replacement for environment / project variables
   
   Browsing for a file or directory in Hop Gui already rewrote paths under the 
project home to `${PROJECT_HOME}/…`. That behavior is expanded so **any 
path-like variable** from the active project or environment configuration can 
be used the same way.
   
   ### Behavior
   
   When a project is active and you pick a path via the file/directory browser:
   
   1. Hop looks at path-like variables in the current variable space 
(environment config files, project described variables, and built-ins such as 
`PROJECT_HOME`, `PARENT_PROJECT_HOME`, `HOP_DATASETS_FOLDER`, etc.).
   2. If the selected path is equal to, or under, one of those variable values, 
the matching prefix is rewritten to `${VAR}` / `${VAR}/remainder`.
   3. If several variables match, the **longest (most specific)** path wins.
   
   **Example (issue request):** with `SOURCE_FILES=/tmp/source/files/` in an 
environment config, selecting `/tmp/source/files/in.csv` becomes 
`${SOURCE_FILES}/in.csv`.
   
   Nested values work too: if `DATA_FOLDER=${PROJECT_HOME}/data`, a path under 
that folder becomes `${DATA_FOLDER}/…` rather than the shorter 
`${PROJECT_HOME}/data/…`.
   
   ### Safety filters
   
   To avoid false positives, candidates skip:
   
   - Internal variables (`Internal.*`)
   - System-ish names (`java.*`, `user.*`, `sun.*`, …)
   - Non-path managed names (`HOP_PROJECT_NAME`, `HOP_ENVIRONMENT_NAME`, …)
   - Empty values, unresolved `${…}` fragments, comma-lists, and filesystem 
roots (`/`, `C:\`)
   
   ### Code
   
   | Piece | Role |
   |---|---|
   | `PathVariableReplacer` | Shared matching / rewrite logic |
   | `HopGuiFileReplaceHomeVariable` | `HopGuiFileOpenedDialog` extension point 
|
   | `HopGuiDirectoryReplaceHomeVariable` | `HopGuiDirectorySelected` extension 
point |
   
   Unit tests cover `PROJECT_HOME`, env vars outside the project, 
longest-prefix wins, exact directory match, nested variable values, and 
system-property exclusion. User docs updated under projects/environments.
   
   Branch: `eil-friction` @ `16a6d7805a` (`mattcasters/hop`).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to