aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/upstreamMerge.sh
blob: 319a71695df6bc22fda4c4de18509f214a0937dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash

(
set -e
PS1="$"
basedir="$(cd "$1" && pwd -P)"
workdir="$basedir/work"
gitcmd="git -c commit.gpgsign=false"

updated="0"
function getRef {
    git ls-tree $1 $2  | cut -d' ' -f3 | cut -f1
}
function update {
    cd "$workdir/$1"
    $gitcmd fetch && $gitcmd clean -fd && $gitcmd reset --hard origin/master
    refRemote=$(git rev-parse HEAD)
    cd ../
    $gitcmd add --force $1
    refHEAD=$(getRef HEAD "$workdir/$1")
    echo "$1 $refHEAD - $refRemote"
    if [ "$refHEAD" != "$refRemote" ]; then
        export updated="1"
    fi
}

update Bukkit
update CraftBukkit
update Spigot

if [[ "$2" = "all" || "$2" = "a" ]] ; then
	update BuildData
fi
if [ "$updated" == "1" ]; then
    echo "Rebuilding patches without filtering to improve apply ability"
    cd "$basedir"
    ./gradlew cleanCache || exit 1 # todo: Figure out why this is necessary
    ./gradlew applyPatches -Dpaperweight.debug=true || exit 1
    ./gradlew rebuildPatches || exit 1
fi
)