Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for caching repositories with --reference #17

Open
staticfloat opened this issue Nov 16, 2021 · 0 comments
Open

Add support for caching repositories with --reference #17

staticfloat opened this issue Nov 16, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@staticfloat
Copy link
Member

We should do what the buildkite agent does with the "git mirrors" experiment (which we generally have turned on).

Broadly, we should do:

REPO_URL="${BUILDKITE_PLUGIN_EXTERNAL_BUILDKITE_EXTERNAL_REPO}"
REPO_URL_HASH="$(shasum -a 256 <<<"${REPO_URL}")"
REFERENCE_REPO_PATH="/cache/external-buildkite/repos/${REPO_URL_HASH}"

# Clone our persistent mirror repository
if [[ ! -d "${REFERENCE_REPO_PATH}" ]]; then
    git clone --mirror "${REPO_URL}" "${REFERENCE_REPO_PATH}"
else
    git fetch -C "${REFERENCE_REPO_PATH}" origin
fi

# Clone a fresh checkout, using our mirror as a reference (this should generally never require network access)
git clone --reference "${REFERENCE_REPO_PATH}" "${REPO_URL}" ...
@DilumAluthge DilumAluthge added the enhancement New feature or request label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants