Try to get sparse checkout to work with lfs

This commit is contained in:
Dan Hawkins 2019-05-15 00:02:48 +01:00
commit eb8a1005ec

View file

@ -227,6 +227,25 @@ def setlfsfetchinclude(String targetDir, ArrayList<String> sparseitemlist) {
} }
} }
def gitsparserestore(String targetDir) {
echo "Clean out full fetch; Force a sparse fetch"
dir(targetDir) {
if (isUnix()) {
sh """
git rm -rf .
git clean -fxd
git reset --hard
"""
} else {
bat """
git rm -rf .
git clean -fxd
git reset --hard
"""
}
}
}
def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) { def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repoRootSuffix = "", int cloneDepth = 1, boolean shallowClone = true, ArrayList<String> sparseitemlist = new ArrayList<String>()) {
echo "Performing alternative checkout" echo "Performing alternative checkout"
def String reporootpath = lfsinstallandreporoot(gitURL) def String reporootpath = lfsinstallandreporoot(gitURL)
@ -236,6 +255,9 @@ def gitCheckoutAlt(String gitURL, String revision, String targetDir, String repo
setlfsfetchinclude(targetDir, sparseitemlist) setlfsfetchinclude(targetDir, sparseitemlist)
} }
docheckout(gitURL, revision, cloneDepth, reporootpath, shallowClone, targetDir, sparseitemlist) docheckout(gitURL, revision, cloneDepth, reporootpath, shallowClone, targetDir, sparseitemlist)
if (!sparseitemlist.isEmpty()) {
gitsparserestore(targetDir)
}
} }
def checkRepoExists(String gitURL) { def checkRepoExists(String gitURL) {