Skip to content

#2366: support variables and expressions in repository properties - #2398

Draft
quando632 wants to merge 3 commits into
devonfw:mainfrom
quando632:feature/2366-variables-in-repository-url
Draft

#2366: support variables and expressions in repository properties#2398
quando632 wants to merge 3 commits into
devonfw:mainfrom
quando632:feature/2366-variables-in-repository-url

Conversation

@quando632

@quando632 quando632 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #2366

Implemented changes:

  • 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 every other property.
  • Resolution is done centrally in RepositoryProperties.doGetProperty(..) and happens before any validation, so it also works for validated properties such as path (whose PATH_PATTERN would otherwise reject the [ and ] of an unresolved $[VAR]).
  • Legacy support is disabled on purpose (legacySupport=false), so the ${...} syntax of e.g. maven properties in a 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. For this, RepositoryConfig.loadProperties(RepositoryProperties) was added as an overload; the existing loadProperties(Path, IdeContext) is kept and delegates to it.
  • Documented the new capability in documentation/repository.adoc and 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:

path=IDEasy
git_url=https://github.com/@ask-variable("GIT_USER", "Please enter your github login:", "home", "$[USERNAME]")/IDEasy.git
git_remote=upstream:https://github.com/devonfw/IDEasy.git
git_branch=main
import=eclipse
active=true

Note

#989 / PR #2282 is merged, main has been merged into this branch, and the @ask-variable example above was verified end-to-end (see testing instructions). This PR needs no expression specific code itself: #2282 registers the ExpressionParser inside AbstractEnvironmentVariables.resolveRecursive, i.e. below EnvironmentVariables.resolve(..), which is what this PR calls.

Testing instructions

  1. Create or edit a repository properties file in your settings, e.g. settings/repositories/test.properties:
    path=repos/$[GIT_USER]
    git_url=https://github.com/$[GIT_USER]/IDEasy.git
    git_remote=upstream:https://github.com/devonfw/IDEasy.git
    active=true
  2. Define the variable, e.g. in $IDE_HOME/conf/ide.properties: GIT_USER=«your-github-login»
  3. Run ide repository setup test (or ide update). The repository is cloned from https://github.com/«your-github-login»/IDEasy.git into workspaces/main/repos/«your-github-login», and git remote -v inside the clone shows the additional upstream remote.
  4. Now remove GIT_USER from ide.properties and run again: a warning Undefined variable $[GIT_USER] in '«...»/test.properties' is logged and the placeholder is kept, so the subsequent git clone fails 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.
  5. Set active=false and run ide repository (without --force-repositories): only Skipping repository test because it is not active, ... is logged - no resolution and thus no question is triggered for a repository that is skipped.
  6. Verify that ${...} is untouched: add build_cmd=mvn -Dversion=${project.version} clean install and confirm the command is executed verbatim.
  7. Replace the git_url with the @ask-variable(..) example above and remove GIT_USER everywhere. On the first run you are asked Please 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.

  • When running mvn clean test locally all tests pass and build is successful (mvn verify -pl '!documentation' → BUILD SUCCESS, ide-cli: 959 tests, 0 failures, 0 errors)
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat and not feature/921 fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summaries 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 (mvn spotless:apply and mvn checkstyle:check are clean for all changed files)
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labelled with internal
  • You have not changed any dependency in pom.xml files or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

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.
@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Sep 1, 2026
@quando632 quando632 added enhancement New feature or request configuration should be configurable or configuration change repository Commandlet to clone, build or import git repositories labels Sep 1, 2026
@coveralls

coveralls commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 33762970399

Coverage increased (+0.03%) to 73.833%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 32 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

32 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/git/repository/RepositoryCommandlet.java 21 72.92%
com/devonfw/tools/ide/git/repository/RepositoryProperties.java 9 90.14%
com/devonfw/tools/ide/git/repository/RepositoryConfig.java 2 73.33%

Coverage Stats

Coverage Status
Relevant Lines: 18590
Covered Lines: 14343
Line Coverage: 77.15%
Relevant Branches: 8280
Covered Branches: 5496
Branch Coverage: 66.38%
Branches in Coverage %: Yes
Coverage Strength: 3.29 hits per line

💛 - 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.
@hohwille hohwille added this to the release:2026.09.002 milestone Sep 3, 2026
@hohwille hohwille moved this from 🆕 New to 🏗 In progress in IDEasy board Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration should be configurable or configuration change enhancement New feature or request repository Commandlet to clone, build or import git repositories

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

Support for variables and expressions in repository URL

3 participants