Skip to content

#1992 improve gitcontextmock#2093

Merged
hohwille merged 17 commits into
devonfw:mainfrom
Caylipp:feature/1992-improve-gitcontextmock
Jul 23, 2026
Merged

#1992 improve gitcontextmock#2093
hohwille merged 17 commits into
devonfw:mainfrom
Caylipp:feature/1992-improve-gitcontextmock

Conversation

@Caylipp

@Caylipp Caylipp commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #1992

Implemented changes:

  • Improved GitContextMock behavior to better reflect real Git repository state.
  • Added and updated unit tests for clone, fetch, and update detection.

Testing instructions

Please add conscise, understandable instructions on how a reviewer can test/verify the functionality of your contribution here:

  1. Run GitContextMockTest.
  2. Verify all tests pass.

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
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Jun 30, 2026
@Caylipp Caylipp added enhancement New feature or request test related to testing and QA git git version management tool integration internal Nothing to be added to CHANGELOG, only internal story labels Jun 30, 2026
@Caylipp Caylipp self-assigned this Jun 30, 2026
@Caylipp Caylipp moved this from 🆕 New to Team Review in IDEasy board Jun 30, 2026
@coveralls

coveralls commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 29928632798

Coverage increased (+0.09%) to 72.586%

Details

  • Coverage increased (+0.09%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 16958
Covered Lines: 12831
Line Coverage: 75.66%
Relevant Branches: 7584
Covered Branches: 4983
Branch Coverage: 65.7%
Branches in Coverage %: Yes
Coverage Strength: 3.2 hits per line

💛 - Coveralls

@maybeec maybeec left a comment

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.

Thanks for tackling this — the mock now models the full clone → fetch → pull → update-detection lifecycle with a pending-commits queue, and CI is green. Nicely structured and the new GitContextMockTest reads well.

I have two blocking items that come straight from the issue text / project conventions, plus a scope question. Inline comments give one-click suggestions for the convention fix.

Must-fix

  1. Use the project's IniFile support for the .git/config file. #1992 explicitly asks that the config be created "with our IniFile support". Both the write (in clone) and the read (in retrieveGitUrl) are currently hand-rolled. com.devonfw.tools.ide.io.ini.IniFile / IniFileImpl already exist — using them also removes the fragile line parsing (see inline comments).
  2. Exception handling convention. coding-conventions.adoc (§"Catching and handling Exceptions") requires wrapping as throw new IllegalStateException("<meaningful message>", e) — a message and the cause. There are 8 bare throw new RuntimeException(e) sites; I've left commit-able suggestions on each.

Scope question (non-blocking, worth confirming)
The issue closes with: "Our tests using GitContextMock can then be reworked and improved… Also we can properly test features like ide upgrade or the check if update is available." This PR delivers the mock infrastructure and self-tests, but the existing consumer (UpdateCommandletTest) isn't reworked and there are no feature-level tests exercising the new capabilities. Is that intended as a follow-up, or should it land here to fully close #1992?

Minor

  • GitChange has no equals/hashCode, so GitCommit.hashCode() (which delegates to List<GitChange>.hashCode()) is identity-based — fine for a single run, just not content-stable. See inline note.
  • java.io.IOException FQN in clone/pull vs. the imported IOException elsewhere is inconsistent (cosmetic).
  • Heads-up: IdeTestContext defaults to GitContextMock, so flipping these methods from no-ops to active FS operations changes semantics for every consumer (e.g. updateUrls() now creates a .git tree under the urls path). CI is green so nothing breaks today — just noting the widened side-effect surface.

Also needs a rebase — the branch is currently behind main.

Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated

@maybeec maybeec left a comment

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.

Requesting changes — there are blocking items that should be resolved before merge (details are in the inline comments on the previous review):

Blocking

  1. Use the project's IniFile support for .git/config (write in clone, read in retrieveGitUrl). #1992 explicitly requires this, and it removes the fragile hand-rolled parsing that currently isn't scoped to the [remote "origin"] section.
  2. Exception handling convention — replace the 8 throw new RuntimeException(e) sites with IllegalStateException("<message>", e) (message + cause), per coding-conventions.adoc. One-click suggestions are provided on each line.

Please also clarify (scope of #1992)

  • The issue asks that the existing tests using GitContextMock be reworked and that features like ide upgrade / update-detection be properly tested with the new mock. That part isn't in this PR — is it a planned follow-up, or should it land here to fully close #1992?

Once the two blocking items are addressed (and the branch rebased onto main), I'm happy to re-review. Thanks again — the core lifecycle modelling is solid.

@Caylipp
Caylipp force-pushed the feature/1992-improve-gitcontextmock branch from 7fe0b65 to 0d37f75 Compare July 8, 2026 09:00
@Caylipp

Caylipp commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Requesting changes — there are blocking items that should be resolved before merge (details are in the inline comments on the previous review):

Blocking

  1. Use the project's IniFile support for .git/config (write in clone, read in retrieveGitUrl). Improve GitContextMock #1992 explicitly requires this, and it removes the fragile hand-rolled parsing that currently isn't scoped to the [remote "origin"] section.
  2. Exception handling convention — replace the 8 throw new RuntimeException(e) sites with IllegalStateException("<message>", e) (message + cause), per coding-conventions.adoc. One-click suggestions are provided on each line.

Please also clarify (scope of #1992)

  • The issue asks that the existing tests using GitContextMock be reworked and that features like ide upgrade / update-detection be properly tested with the new mock. That part isn't in this PR — is it a planned follow-up, or should it land here to fully close Improve GitContextMock #1992?

Once the two blocking items are addressed (and the branch rebased onto main), I'm happy to re-review. Thanks again — the core lifecycle modelling is solid.

Thanks for the review.

I addressed the two blocking items:

  • .git/config is now written using IniFile/IniFileImpl, and retrieveGitUrl reads the url from the remote "origin" section.
  • The bare RuntimeException usages were replaced with IllegalStateException including meaningful messages and the original cause.

I also added equals/hashCode for GitChange and GitCommit to address the minor hash stability note.

Regarding the scope question: I intended this PR to focus on the GitContextMock infrastructure and its self-tests. Reworking consumer tests such as UpdateCommandletTest would be a follow-up, unless you prefer to include it here.

@Caylipp Caylipp moved this from Team Review to 👀 In review in IDEasy board Jul 13, 2026
@Caylipp
Caylipp requested a review from maybeec July 14, 2026 07:30

@hohwille hohwille left a comment

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.

@Caylipp thanks for your PR. Nice job with great JUnit test. 👍
However, I left some comments for rework. Please have a look and improve before we can merge. Thanks in advance.

Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Comment thread cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java Outdated
Caylipp added 3 commits July 22, 2026 11:58
…/1992-improve-gitcontextmock

# Conflicts:
#	CHANGELOG.adoc
#	cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java
- Improve GitContextMock implementation
- Use FileAccess for file operations
@hohwille hohwille added this to the release:2026.08.001 milestone Jul 23, 2026
Comment thread CHANGELOG.adoc Outdated
Comment thread CHANGELOG.adoc

@hohwille hohwille left a comment

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.

@Caylipp thanks for the excellent rework. Perfect now 👍
I will fix the CHANGELOG and then merge.

hohwille added 3 commits July 23, 2026 19:34
Re-added the entry for improving localization of GUI in the changelog.
@hohwille
hohwille merged commit dd45e91 into devonfw:main Jul 23, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in IDEasy board Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request git git version management tool integration internal Nothing to be added to CHANGELOG, only internal story test related to testing and QA

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Improve GitContextMock

5 participants