-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapplyPatches.sh
executable file
·76 lines (61 loc) · 1.85 KB
/
applyPatches.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
ORIG_PWD="$(pwd)"
cd "$(dirname "$0")"
echo " Rebuilding Forked projects.... "
function requireCleanWorkTree {
# Update the index
git update-index -q --ignore-submodules --refresh
err=0
# Disallow unstaged changes in the working tree
if ! git diff-files --quiet --ignore-submodules --
then
echo >&2 "cannot apply patches to $1: you have unstaged changes."
git diff-files --name-status -r --ignore-submodules -- >&2
err=1
fi
# Disallow uncommitted changes in the index
if ! git diff-index --cached --quiet HEAD --ignore-submodules --
then
echo >&2 "cannot apply patches to $1: your index contains uncommitted changes."
git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
err=1
fi
if [ $err = 1 ]
then
echo >&2 "Please commit or stash them."
exit 1
fi
}
function applyPatches {
what=base/$1
target=build/$1
patches=$1
cd $what
git branch -f upstream >/dev/null
cd ../../
if [ ! -d $target ]; then
git clone $what $target -b upstream
fi
cd $target
requireCleanWorkTree $target
echo " Resetting $target to $what..."
git remote rm upstream 2>/dev/null 2>&1
git remote add upstream ../../$what >/dev/null 2>&1
git fetch upstream >/dev/null 2>&1
git reset --hard upstream/upstream
echo " Applying patches to $target..."
git am --abort
if !(git am --3way ../../$patches/*.patch); then
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"
cd "$ORIG_PWD"
exit 1
else
echo " Patches applied cleanly to $target"
fi
cd ../..
}
applyPatches Bukkit
applyPatches CraftBukkit
cd "$ORIG_PWD"