[CI-SKIP] Avoid rebuilding Paper-Server if Paper-API did not apply

This scenario occurs when Paper-API fails, we then rebuild the patches,
however Paper-Server was left un an outdated state since the most
recent patches did not get applied to it.

This results in us reverting Paper-Server to an older state.

If Paper-API fails to apply, then Paper-Server has to be considered dirty.

This should avoid us having accidental patch reversions
This commit is contained in:
Aikar 2018-08-12 11:54:35 -04:00
parent f8ecb526e7
commit 668ad2cf0b
No known key found for this signature in database
GPG key ID: 401ADFC9891FAAFE
2 changed files with 12 additions and 1 deletions

View file

@ -37,6 +37,8 @@ function applyPatch {
echo " Applying patches to $target..."
statusfile=".git/patch-apply-failed"
rm -f "$statusfile"
$gitcmd am --abort >/dev/null 2>&1
# Special case Windows handling because of ARG_MAX constraint
@ -48,6 +50,7 @@ function applyPatch {
fi
if [ "$?" != "0" ]; then
echo 1 > "$statusfile"
echo " Something did not apply cleanly to $target."
echo " Please review above details and finish the apply then"
echo " save the changes with rebuildPatches.sh"
@ -64,6 +67,7 @@ function applyPatch {
exit 1
else
rm -f "$statusfile"
echo " Patches applied cleanly to $target"
fi
}

View file

@ -4,6 +4,7 @@
PS1="$"
basedir="$(cd "$1" && pwd -P)"
workdir="$basedir/work"
source "$basedir/scripts/functions.sh"
gitcmd="git -c commit.gpgsign=false -c core.safecrlf=false"
echo "Rebuilding patch files from current fork state..."
@ -60,5 +61,11 @@ function savePatches {
}
savePatches "$workdir/Spigot/Spigot-API" "Paper-API"
savePatches "$workdir/Spigot/Spigot-Server" "Paper-Server"
if [ -f "$basedir/Paper-API/.git/patch-apply-failed" ]; then
echo "$(color 1 31)[[[ WARNING ]]] $(color 1 33)- Not saving Paper-Server as it appears Paper-API did not apply clean.$(colorend)"
echo "$(color 1 33)If this is a mistake, delete $(color 1 34)Paper-API/.git/patch-apply-failed$(color 1 33) and run rebuild again.$(colorend)"
echo "$(color 1 33)Otherwise, rerun ./paper patch to have a clean Paper-API apply so the latest Paper-Server can build.$(colorend)"
else
savePatches "$workdir/Spigot/Spigot-Server" "Paper-Server"
fi
) || exit 1