diff --git a/src/build.sh b/src/build.sh index 365de7060cee27db74e0b1172df4988f4cb95576..7b2d7300d37a5983894e6a48e93653f8cf96d9fd 100755 --- a/src/build.sh +++ b/src/build.sh @@ -115,11 +115,29 @@ if [ -n "${BRANCH_NAME}" ] && [ -n "${DEVICE}" ]; then echo ">> [$(date)] Syncing branch repository" builddate=$(date +%Y%m%d) + repo_out=$(repo sync -c --force-sync 2>&1 > /dev/null) + repo_status=$? + echo -e $repo_out + + if [ "$repo_status" != "0" ]; then + if [ -f /root/userscripts/clean.sh ]; then + if [[ "$repo_out" == *"Failing repos:"* ]]; then + list_line=`echo -e $repo_out | sed 's/.*Failing repos: //'` + fi + if [[ "$repo_out" == *"Cannot remove project"* ]]; then + list_line=`echo -e $repo_out | grep "Cannot remove project" | sed -e 's/.*error: \(.*\): Cannot.*/\1/'` + fi + echo ">> [$(date)] Running clean.sh" + /root/userscripts/clean.sh $list_line + if ! repo sync -c --force-sync ; then + sync_successful=false + fi + else + sync_successful=false + fi + fi - if ! repo sync -c --force-sync - then - sync_successful=false - else + if [ "$sync_successful" = true ]; then repo forall -c 'git lfs pull' fi