build script: check if .git is present

This commit is contained in:
Zack A 2021-08-29 16:16:14 -07:00 committed by Francesco Abbate
parent e34ec195b4
commit 97ca19c73f
1 changed files with 10 additions and 7 deletions

View File

@ -14,10 +14,9 @@ copy_directory_from_repo () {
} }
_archive () { _archive () {
if [[ -d ".git" || $BUILD_PROHIBIT_GIT -eq 1 ]]; then if [[ $git_available -eq 1 ]]; then
git archive "$1" "$2" --format=tar | tar xf - -C "$3" "$4" git archive "$1" "$2" --format=tar | tar xf - -C "$3" "$4"
else else
echo ".git not found, falling back to UNIX operation"
cp -r "$2" "$3" cp -r "$2" "$3"
fi fi
} }
@ -29,14 +28,12 @@ build_dir_is_usable () {
echo "invalid build directory, no path allowed: \"$build\"" echo "invalid build directory, no path allowed: \"$build\""
return 1 return 1
fi fi
if [[ -d ".git" || $BUILD_PROHIBIT_GIT -eq 1 ]]; then if [[ $git_available -eq 1 ]]; then
git ls-files --error-unmatch "$build" &> /dev/null git ls-files --error-unmatch "$build" &> /dev/null
if [ $? == 0 ]; then if [ $? == 0 ]; then
echo "invalid path, \"$build\" is under revision control" echo "invalid path, \"$build\" is under revision control"
return 1 return 1
fi fi
else
echo ".git not found, skipping check for revision control"
fi fi
} }
@ -203,7 +200,6 @@ lite_copy_third_party_modules () {
mv "$build/lite-colors-master/colors" "$build/third/data" mv "$build/lite-colors-master/colors" "$build/third/data"
rm -fr "$build/lite-colors-master" rm -fr "$build/lite-colors-master"
} }
unset arch unset arch
while [ ! -z {$1+x} ]; do while [ ! -z {$1+x} ]; do
case $1 in case $1 in
@ -226,8 +222,15 @@ if [ -z ${arch+set} ]; then
exit 1 exit 1
fi fi
if [[ -d ".git" || $BUILD_PROHIBIT_GIT -ne 0 ]]; then
git_available=1;
else
echo "Use of git prohibited. Either '.git' wasn't found or BUILD_PROHIBIT_GIT was set."
git_available=0;
fi
if [ -z ${use_branch+set} ]; then if [ -z ${use_branch+set} ]; then
if [[ -d ".git" || $BUILD_PROHIBIT_GIT -eq 1 ]]; then if [[ $git_available -eq 1 ]]; then
use_branch="$(git rev-parse --abbrev-ref HEAD)" use_branch="$(git rev-parse --abbrev-ref HEAD)"
else else
# it really doesn't matter if git isn't present # it really doesn't matter if git isn't present