#2366: support variables and expressions in repository properties - #2398
Draft
quando632 wants to merge 3 commits into
Draft
#2366: support variables and expressions in repository properties#2398quando632 wants to merge 3 commits into
quando632 wants to merge 3 commits into
Conversation
Every value of a repository .properties file is now resolved via the EnvironmentVariables hierarchy, so variables ($[VAR]) and expressions (@function(...)) can be used in git_url, git_remote, path and all other properties. Resolution happens centrally before any validation, so it also works for validated properties such as path. Legacy support is disabled on purpose so that the ${...} syntax of e.g. maven properties in build_cmd is passed through untouched. The active flag is now evaluated before the remaining properties are read, so an expression like @ask-variable never asks the user for a repository that is skipped anyway.
Collaborator
Coverage Report for CI Build 33762970399Coverage increased (+0.03%) to 73.833%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions32 previously-covered lines in 3 files lost coverage.
Coverage Stats💛 - Coveralls |
The Path based loadProperties had no caller left after the active flag check moved into RepositoryCommandlet, which now loads the RepositoryProperties itself. Removed it together with the imports that became unused.
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.
This PR fixes #2366
Implemented changes:
.propertiesfile is now resolved via theEnvironmentVariableshierarchy, so variables ($[VAR]) and expressions (@function(...)) can be used ingit_url,git_remote,pathand every other property.RepositoryProperties.doGetProperty(..)and happens before any validation, so it also works for validated properties such aspath(whosePATH_PATTERNwould otherwise reject the[and]of an unresolved$[VAR]).legacySupport=false), so the${...}syntax of e.g. maven properties in abuild_cmdis passed through untouched.activeflag is now evaluated before the remaining properties are read, so an expression like@ask-variablenever asks the user for a repository that is skipped anyway. For this,RepositoryConfig.loadProperties(RepositoryProperties)was added as an overload; the existingloadProperties(Path, IdeContext)is kept and delegates to it.documentation/repository.adocand added the CHANGELOG entry.This is the last building block for the use-case described in #2366 - configuring the fork of the current user as repository:
Note
#989 / PR #2282 is merged,
mainhas been merged into this branch, and the@ask-variableexample above was verified end-to-end (see testing instructions). This PR needs no expression specific code itself: #2282 registers theExpressionParserinsideAbstractEnvironmentVariables.resolveRecursive, i.e. belowEnvironmentVariables.resolve(..), which is what this PR calls.Testing instructions
settings/repositories/test.properties:$IDE_HOME/conf/ide.properties:GIT_USER=«your-github-login»ide repository setup test(oride update). The repository is cloned fromhttps://github.com/«your-github-login»/IDEasy.gitintoworkspaces/main/repos/«your-github-login», andgit remote -vinside the clone shows the additionalupstreamremote.GIT_USERfromide.propertiesand run again: a warningUndefined variable $[GIT_USER] in '«...»/test.properties'is logged and the placeholder is kept, so the subsequentgit clonefails with the unresolved URL visible in the error. An undefined variable in a repository URL is a configuration error and is reported as such rather than being silently swallowed.active=falseand runide repository(without--force-repositories): onlySkipping repository test because it is not active, ...is logged - no resolution and thus no question is triggered for a repository that is skipped.${...}is untouched: addbuild_cmd=mvn -Dversion=${project.version} clean installand confirm the command is executed verbatim.git_urlwith the@ask-variable(..)example above and removeGIT_USEReverywhere. On the first run you are askedPlease enter your github login: [«your-os-user»](the default comes from$[USERNAME]), the answer is written to~/.ide/ide.properties, and the fork is cloned. On a second run you are not asked again.Checklist for this PR
Make sure everything is checked before merging this PR. For further info please also see
our DoD.
mvn clean testlocally all tests pass and build is successful (mvn verify -pl '!documentation'→ BUILD SUCCESS,ide-cli: 959 tests, 0 failures, 0 errors)#«issue-id»: «brief summary»(e.g.#921: fixed setup.batand notfeature/921 fixed setup.bat). If no issue ID exists, title only.In Progressand assigned to you or there is no issue (might happen for very small PRs)mvn spotless:applyandmvn checkstyle:checkare clean for all changed files)internalpom.xmlfiles or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc