This repository was archived by the owner on Jun 9, 2023. It is now read-only.
forked from actions/checkout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor on sparse-checkout test
- Loading branch information
Showing
2 changed files
with
37 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# Check that only sparse-checkout folders has been fetched | ||
for pattern in $(git ls-tree --name-only HEAD) | ||
do | ||
if [ -d "$pattern" ]; then | ||
if [[ "$pattern" != "__test__" && "$pattern" != ".github" && "$pattern" != "dist" ]]; then | ||
echo "Expected directory '$pattern' to not exist" | ||
exit 1 | ||
fi | ||
fi | ||
done | ||
|
||
# Check that .github and its childrens has been fetched correctly | ||
if [ ! -d "./__test__" ]; then | ||
echo "Expected directory '__test__' to exist" | ||
# Verify .git folder | ||
if [ ! -d "./sparse-checkout/.git" ]; then | ||
echo "Expected ./sparse-checkout/.git folder to exist" | ||
exit 1 | ||
fi | ||
|
||
for file in $(git ls-tree -r --name-only HEAD __test__) | ||
do | ||
if [ ! -f "$file" ]; then | ||
echo "Expected file '$file' to exist" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Check that .github and its childrens has been fetched correctly | ||
if [ ! -d "./.github" ]; then | ||
echo "Expected directory '.github' to exist" | ||
exit 1 | ||
fi | ||
# Verify sparse-checkout | ||
cd sparse-checkout | ||
|
||
for file in $(git ls-tree -r --name-only HEAD .github) | ||
do | ||
if [ ! -f "$file" ]; then | ||
echo "Expected file '$file' to exist" | ||
checkSparse () { | ||
if [ ! -d "./$1" ]; then | ||
echo "Expected directory '$1' to exist" | ||
exit 1 | ||
fi | ||
done | ||
|
||
# Check that dist and its childrens has been fetched correctly | ||
if [ ! -d "./dist" ]; then | ||
echo "Expected directory 'dist' to exist" | ||
exit 1 | ||
fi | ||
for file in $(git ls-tree -r --name-only HEAD $1) | ||
do | ||
if [ ! -f "$file" ]; then | ||
echo "Expected file '$file' to exist" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
for file in $(git ls-tree -r --name-only HEAD dist) | ||
# Check that all folders and its childrens has been fetched correctly | ||
checkSparse __test__ | ||
checkSparse .github | ||
checkSparse dist | ||
|
||
# Check that only sparse-checkout folders has been fetched | ||
for pattern in $(git ls-tree --name-only HEAD) | ||
do | ||
if [ ! -f "$file" ]; then | ||
echo "Expected file '$file' to exist" | ||
exit 1 | ||
if [ -d "$pattern" ]; then | ||
if [[ "$pattern" != "__test__" && "$pattern" != ".github" && "$pattern" != "dist" ]]; then | ||
echo "Expected directory '$pattern' to not exist" | ||
exit 1 | ||
fi | ||
fi | ||
done |