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

Use treeless clone to 'shallow' clone again. #2022

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
18 changes: 8 additions & 10 deletions bootstrap-salt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2097,21 +2097,19 @@ __git_clone_and_checkout() {
fi

if [ "$__SHALLOW_CLONE" -eq $BS_TRUE ]; then
# Let's try shallow cloning to speed up.
# Test for "--single-branch" option introduced in git 1.7.10, the minimal version of git where the shallow
# Let's try 'treeless' cloning to speed up. Treeless cloning omits trees and blobs ('files')
# but includes metadata (commit history, tags, branches etc.
# Test for "--filter" option introduced in git 2.19, the minimal version of git where the treeless
# cloning we need actually works
if [ "$(git clone 2>&1 | grep 'single-branch')" != "" ]; then
# The "--single-branch" option is supported, attempt shallow cloning
if [ "$(git clone 2>&1 | grep 'filter')" != "" ]; then
# The "--filter" option is supported, attempt treeless cloning
echoinfo "Attempting to shallow clone $GIT_REV from Salt's repository ${_SALT_REPO_URL}"
## Shallow cloning is resulting in the wrong version of Salt, even with a depth of 5
## getting 3007.0+0na.246d066 when it should be 3007.1+410.g246d066457, disabling for now
## if git clone --depth 1 --branch "$GIT_REV" "$_SALT_REPO_URL" "$__SALT_CHECKOUT_REPONAME"; then
echodebug "git command, git clone --branch $GIT_REV $_SALT_REPO_URL $__SALT_CHECKOUT_REPONAME"
if git clone --branch "$GIT_REV" "$_SALT_REPO_URL" "$__SALT_CHECKOUT_REPONAME"; then
echodebug "git command, git clone --filter=tree:0 --branch $GIT_REV $_SALT_REPO_URL $__SALT_CHECKOUT_REPONAME"
if git clone --filter=tree:0 --branch "$GIT_REV" "$_SALT_REPO_URL" "$__SALT_CHECKOUT_REPONAME"; then
# shellcheck disable=SC2164
cd "${_SALT_GIT_CHECKOUT_DIR}"
__SHALLOW_CLONE=$BS_TRUE
echoinfo "shallow path (disabled shallow) git cloned $GIT_REV, version $(python3 salt/version.py)"
echoinfo "shallow path git cloned $GIT_REV, version $(python3 salt/version.py)"
else
# Shallow clone above failed(missing upstream tags???), let's resume the old behaviour.
echowarn "Failed to shallow clone."
Expand Down
Loading