2013-01-15 12:18:40 +11:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-04-14 21:01:27 +10:00
|
|
|
PS1="$"
|
2013-01-21 20:24:30 +11:00
|
|
|
basedir=`pwd`
|
2019-01-04 20:04:33 +11:00
|
|
|
clean=$1
|
2013-01-15 12:18:40 +11:00
|
|
|
echo "Rebuilding patch files from current fork state..."
|
2014-04-14 21:01:27 +10:00
|
|
|
|
2017-01-30 08:34:39 +11:00
|
|
|
cleanupPatches() {
|
2013-11-05 16:26:20 -08:00
|
|
|
cd "$1"
|
2013-01-16 12:08:09 -05:00
|
|
|
for patch in *.patch; do
|
2013-01-21 21:46:26 -05:00
|
|
|
gitver=$(tail -n 2 $patch | grep -ve "^$" | tail -n 1)
|
|
|
|
diffs=$(git diff --staged $patch | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index)")
|
|
|
|
|
|
|
|
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
|
|
|
|
if [ "x$testver" != "x" ]; then
|
|
|
|
diffs=$(echo "$diffs" | head -n -2)
|
|
|
|
fi
|
2017-01-30 08:34:39 +11:00
|
|
|
|
2013-01-21 21:46:26 -05:00
|
|
|
|
|
|
|
if [ "x$diffs" == "x" ] ; then
|
2013-01-16 12:08:09 -05:00
|
|
|
git reset HEAD $patch >/dev/null
|
|
|
|
git checkout -- $patch >/dev/null
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
2014-04-14 21:01:27 +10:00
|
|
|
|
2017-01-30 08:34:39 +11:00
|
|
|
savePatches() {
|
2013-01-15 12:18:40 +11:00
|
|
|
what=$1
|
|
|
|
target=$2
|
2019-01-04 20:04:33 +11:00
|
|
|
branch=$3
|
2013-11-05 16:26:20 -08:00
|
|
|
cd "$basedir/$target"
|
2021-01-13 10:11:04 +11:00
|
|
|
git format-patch --no-stat -N -o "../${what}-Patches/" $branch
|
2013-11-05 16:26:20 -08:00
|
|
|
cd "$basedir"
|
2021-01-13 10:11:04 +11:00
|
|
|
git add -A "${what}-Patches"
|
2019-01-04 20:04:33 +11:00
|
|
|
if [ "$clean" != "clean" ]; then
|
2021-01-13 10:11:04 +11:00
|
|
|
cleanupPatches "${what}-Patches"
|
2019-01-04 20:04:33 +11:00
|
|
|
fi
|
2013-01-15 12:18:40 +11:00
|
|
|
echo " Patches saved for $what to $what-Patches/"
|
|
|
|
}
|
2019-01-04 20:04:33 +11:00
|
|
|
if [ "$clean" == "clean" ]; then
|
2021-01-13 10:11:04 +11:00
|
|
|
rm -rf *-Patches
|
2014-12-03 20:22:10 -05:00
|
|
|
fi
|
2019-01-04 20:04:33 +11:00
|
|
|
savePatches Bukkit Spigot-API origin/spigot
|
|
|
|
savePatches CraftBukkit Spigot-Server origin/patched
|