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 since property to be able to shallow clone starting from a commit time #4

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions hooks/pre-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,28 @@ set -euo pipefail

echo "Running git-shallow-clone-buildkite-plugin -- pre-checkout"

ARGS=""

# order of precedence
SINCE="${BUILDKITE_PLUGIN_GIT_SHALLOW_CLONE_SINCE:-}"
DEPTH="${BUILDKITE_PLUGIN_GIT_SHALLOW_CLONE_DEPTH:-1}"
export BUILDKITE_GIT_CLONE_FLAGS="-v --depth ${DEPTH}"
export BUILDKITE_GIT_FETCH_FLAGS="-v --prune --depth ${DEPTH}"

# ensure we match a git sha
if [[ "${SINCE}" =~ ^[0-9]+$ ]]
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this just needs to be valid unix timestamp?

then
ARGS="--shallow-since ${SINCE}"
else
ARGS="--depth ${DEPTH}"
fi

BLOBLESS="${BUILDKITE_PLUGIN_GIT_SHALLOW_CLONE_BLOBLESS:-false}"

if [[ "${BLOBLESS}" = "true" ]]
then
ARGS="${ARGS} --filter blob:none"
fi

export BUILDKITE_GIT_CLONE_FLAGS="-v ${ARGS}"
export BUILDKITE_GIT_FETCH_FLAGS="-v --prune ${ARGS}"

#export BUILDKITE_GIT_CLONE_FLAGS="-v --filter=blob:none"
4 changes: 4 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ configuration:
properties:
depth:
type: number
since:
type: number
blobless:
type: boolean
additionalProperties: false