Repository navigation
[0.38] test(git-cache): resolve, clone and fetch against a real local remote (#4552 item 6, slice 4) - #4721
Merged
Daniel Meppiel (danielmeppiel) merged 4 commits intoNov 22, 2026
Conversation
…ocal remote #4552 item 6, slice 4 (work in progress). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
#4552 item 6, slice 4. The ls-remote, bare-repo, has-sha and fetch-by-sha tests patched git_env's executable lookup and child env (49 sites). They now run the real git_cache and git_env against a file:// remote, faking only the git child process at subprocess.run for parser edge cases and failures. AQ004 for tests/integration/test_git_cache_hermetic.py drops from 66 to 16. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 22, 2026 08:35
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new Git integration tests inherit runner settings that can redirect fixture setup, require commit signing, or disable file transport, so they need an isolated environment throughout.
1 open issue
What changed in this PR
This test-only refactor advances #4552 item 6 by replacing owner-level mocks with real local Git operations, strengthening coverage of the Git cache without changing production behavior.
Changes:
- Exercise ref resolution, cloning, commit lookup and fetching against a local
file://remote. - Check durable repository state, staged-directory cleanup and lost-landing behavior, using child-process stand-ins for exceptional cases.
- Reduce the module's owner-patching baseline (AQ004) from 66 to 16, leaving checkout and eviction rewrites for a later slice.
| File | Description |
|---|---|
tests/quality/assertion_quality_baseline.json |
Lowers the Git cache module's AQ004 allowance to 16. |
tests/integration/test_git_cache_hermetic.py |
Adds a real remote fixture and replaces mocked outcomes with repository-state assertions. |
Review effort: Balanced
Addresses review on #4721: fixtures, probes and cache calls inherit an IsolatedApmEnvironment base, so runner GIT_DIR, global config and credential state never reach the real git children. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Nov 22, 2026
Merged
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-4552-weak-tests-slice4
branch
November 22, 2026 16:29
Merged
3 of 10 tasks
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.

Description
#4552 item 6, slice 4: the owner-group rewrite of
tests/integration/test_git_cache_hermetic.py(ownerapm_cli.cache.git_cache). It had 66 AQ004 entries, the largest AQ004 debt among the files no open PR or lane touches. Slice 3 (test_config_command.py) is #4718.The ls-remote, bare-repo, has-sha and fetch-by-sha tests patched
git_env's ownget_git_executable,git_subprocess_envand_validated_git_url_rewrite_policy(49 sites). They now run the realgit_cacheandgit_envcode:_Remotefixture: a real repository served overfile://, withmain, tagv1.0.0and afeature/topicbranch.git ls-remote..inc.directory is left behind.atomic_landrace is simulated honestly: a competing process lands the winner first, then the realatomic_landloses. The test asserts whether the winner is fetched to the sha or reused._GitChildstand-in atsubprocess.runis used only where real git cannot produce the case: malformed output, timeouts,OSError, a server refusing a fetch by sha, and env pass-through. It records each child's argv and env, so the tests assert the sanitized env (an explicitGIT_DIRnever reaches the child).robust_rmtreeand the clone patches inTestCreateCheckout). They are left for a later slice.Assertion-quality baseline (shrink only):
tests/integration/test_git_cache_hermetic.pyIssue and approved scope
Issue: Refs #4552 (item 6, slice 4)
Human scope-approval comment: #4552 (comment) (item 6: "start the owner-group rewrites of mock-only, owner-patching and assertion-free tests, shrinking the AQ003, AQ004 and AQ006 entries").
Does this PR complete the issue, or what remains? No. Slices 1 (#4683), 2 (#4716) and 3 (#4718) cover other owner groups. Further groups and the other #4552 items remain.
Type of change
Testing
Local results, run through the host guard:
pytest tests/integration/test_git_cache_hermetic.py: 60 passed (58 before; the parametrized cases add 2).pytest -n 2 tests/quality/test_quality_baselines.py tests/quality/test_test_taxonomy.py: 43 passed.scripts/check_test_assertions.py: the ratchet is clean.python -m tests.quality.taxonomy --changed: tm006 is clean.scripts/check_exact_test_duplicates.py: clean.--cov=apm_cli.cache.git_cache --cov=apm_cli.cache.locking:git_cache.pygoes from 317 to 319 executed lines andlocking.pyfrom 18 to 29. No line is lost.Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)