Skip to content

Feature/git cache#2384

Open
b4u-mw wants to merge 7 commits into
actions:mainfrom
b4u-mw:feature/git-cache
Open

Feature/git cache#2384
b4u-mw wants to merge 7 commits into
actions:mainfrom
b4u-mw:feature/git-cache

Conversation

@b4u-mw

@b4u-mw b4u-mw commented Mar 5, 2026

Copy link
Copy Markdown

Full implementation of a reference cache. Works for main git and submodules (recursive). Cache is automatically created/updated.
Fixes #2303

b4u-mw added 2 commits March 5, 2026 15:33
- Add `reference-cache` input to action.yml
- Introduce `GitCacheHelper` for bare clone cache management
- Prevent race conditions with `proper-lockfile` and atomic directory renames
- Support iterative submodule caching and robust relative URL resolution
- Append to `info/alternates` preserving existing alternate references
- Add fallback to standard clone on submodule cache failure
- Add unit tests for `GitCacheHelper`

Signed-off-by: Michael Wyraz <mw@brick4u.de>
When reference-cache is enabled, shallow fetches (fetch-depth > 0) are
counterproductive because objects are served from the local cache.
Shallow negotiation only adds network latency without saving bandwidth.

If fetch-depth was not explicitly set by the user, it is automatically
overridden to 0. If explicitly set, a warning is emitted explaining
the performance impact.

Signed-off-by: Michael Wyraz <mw@brick4u.de>
Copilot AI review requested due to automatic review settings March 5, 2026 15:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a reference cache feature for the actions/checkout GitHub Action, addressing issue #2303. The reference cache allows storing bare clones of repositories locally, so subsequent checkouts can use Git alternates to avoid re-downloading objects over the network. This is particularly valuable for self-hosted runners and custom runner images with persistent storage.

Changes:

  • Adds a new reference-cache input parameter that accepts a path to a local directory for storing bare cache repositories, with associated settings, input parsing, and documentation.
  • Introduces GitCacheHelper class (src/git-cache-helper.ts) that manages bare cache repositories with file-based locking (via proper-lockfile), atomic clone-to-rename patterns, and automatic cache creation/update.
  • Modifies the checkout flow in git-source-provider.ts to set up Git alternates for the main repository and iteratively process submodule updates with per-submodule reference caches, including automatic fetch-depth adjustment when reference cache is active.

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
action.yml Adds new reference-cache input parameter
src/git-source-settings.ts Adds referenceCache and fetchDepthExplicit fields to settings interface
src/input-helper.ts Reads reference-cache input and tracks explicit fetch-depth
src/git-cache-helper.ts New file: cache management with locking, bare clone/fetch, and URL-based dir naming
src/git-source-provider.ts Integrates reference cache into clone and submodule flows; adds adjustFetchDepthForCache
src/git-command-manager.ts Makes execGit/GitOutput public; adds referenceAdd for Git alternates
src/git-auth-helper.ts Adds removeGlobalAuth method for cache auth lifecycle
package.json / package-lock.json Adds proper-lockfile dependency and types
adrs/2303-reference-cache.md ADR documenting the design and acceptance criteria
README.md Documents the new reference-cache input
__test__/git-source-provider.test.ts Tests for adjustFetchDepthForCache
__test__/git-cache-helper.test.ts Tests for cache dir naming and setup behavior
__test__/git-directory-helper.test.ts Updates mock to include new interface methods
__test__/git-auth-helper.test.ts Updates mock and settings for new fields
__test__/input-helper.test.ts Asserts referenceCache defaults to empty
dist/index.js Bundled output including new code and proper-lockfile

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread adrs/2303-reference-cache.md Outdated
Comment thread src/git-source-provider.ts Outdated
Comment thread package.json Outdated
Comment thread src/git-source-provider.ts Outdated
Comment thread src/git-cache-helper.ts Outdated
Comment thread __test__/git-cache-helper.test.ts
Comment thread __test__/git-cache-helper.test.ts
Comment thread __test__/git-cache-helper.test.ts
Comment thread __test__/git-cache-helper.test.ts
Comment thread __test__/git-source-provider.test.ts

@Golubhatt Golubhatt left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something missing check

@BastirEiii

BastirEiii commented Mar 10, 2026 via email

Copy link
Copy Markdown

@b4u-mw

b4u-mw commented Mar 10, 2026

Copy link
Copy Markdown
Author

algo más directo y con codigos de respeto celestial dame el último más directo de los chekaut

Sorry, that version of the ADR was not meant to be checked in. I already have added the final, translated version

@b4u-mw

b4u-mw commented Mar 10, 2026

Copy link
Copy Markdown
Author

something missing check

@Golubhatt I'm sorry but I do not understand your comments. I can run all tests locally without issues. Could you please be more precise what is missing or failing?

@tvishwanatharkin

Copy link
Copy Markdown

Is this PR moving ahead? This is a very good feature IMHO which can reduce the load on Github.

@quic-seaswara

Copy link
Copy Markdown

Looking forward for getting this merged

@b4u-mw

b4u-mw commented Jul 8, 2026

Copy link
Copy Markdown
Author

I wonder if there's anything to do from my side. Seems that it's approved. There are a few open comments where I cannot read anything to do from (marking those as resolved).
So please merge if there's nothing missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support reference clones

6 participants