Use treeless clone to 'shallow' clone again. #2022
Open
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.
What does this PR do?
The ability to shallow clone (
--depth 1
) was removed in 9848c33 as shallow clones don't preserve commit history, tags etc, meaning the saltversion.py
script was failing. However this resulted in much larger and slower cloning.This PR uses a treeless clone to fetch the latest commit, commit history, tags etc without trees and blobs ('files'), keeping the clone small but allowing version to still work.
What issues does this PR fix or reference?
Previous Behavior
The original 'shallow' clone using
git clone --depth 1 --branch master https://github.com/saltstack/salt.git
produces a local repo around 92MB in size, but with missing metadata, resulting in incorrect versions:* INFO: shallow path git cloned master, version 3007.0+0na.221420cd5
The current HEAD with this disabled, using
git clone --branch master
produces a local repo around 640MB in size, with correct versioning:* INFO: shallow path (disabled shallow) git cloned master, version 3007.1+443.g221420cd5
New Behavior
This PR uses
git clone --filter=tree:0 --branch master
reducing the local repo to around 145MB in size, but versioning is still correct:* INFO: shallow path git cloned master, version 3007.1+443.g221420cd5