@@ -2,48 +2,51 @@
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. $(dirname $SOURCE)/init.sh
PS1="$"

spigotVer=$(cat current-spigot)
paperVer=$(cat current-paper)
echo "Rebuilding Forked projects.... "
function applyPatch {
what=$1
what_name=$(basename $what)
target=$2
branch=$3
patch_folder=$4

cd $basedir
if [ ! -d $what ]; then
git clone git@bitbucket.org:starlis/$2 $what
cd "$basedir/$what"
git fetch
git branch -f upstream "$branch" >/dev/null

cd "$basedir"
if [ ! -d "$basedir/$target" ]; then
git clone "$what" "$target"
fi
cd $basedir/$what
echo "Synchronizing $what/master to $2/$spigotVer"
git remote rm origin > /dev/null 2>&1
git remote add origin git@bitbucket.org:starlis/$what >/dev/null 2>&1
cd "$basedir/$target"
echo "Resetting $target to $what_name..."
git remote rm upstream > /dev/null 2>&1
git remote add upstream git@bitbucket.org:starlis/$2 >/dev/null 2>&1

git checkout master >/dev/null 2>&1
git fetch --all --tags
git am --abort
git clean -f

git reset --hard "$spigotVer" >/dev/null
git branch -D upstream 2>/dev/null
git branch upstream
echo " Applying patches to $what..."
git am -3 $basedir/patches/$3/*.patch
git remote add upstream $basedir/$what >/dev/null 2>&1
git checkout master 2>/dev/null || git checkout -b master
git fetch upstream >/dev/null 2>&1
git reset --hard upstream/upstream
echo " Applying patches to $target..."
git am --abort >/dev/null 2>&1
git am --3way --ignore-whitespace "$basedir/patches/$patch_folder/"*.patch
if [ "$?" != "0" ]; then
echo " Something did not apply cleanly to $what. "
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"
echo " save the changes with rebuildPatches.sh"
exit 1
else
echo " Patches applied cleanly to $what"
echo " Patches applied cleanly to $target"
fi
}
applyPatch EmpireCraft-API Spigot-API bukkit
applyPatch EmpireCraft-Server Spigot-Server craftbukkit
applyPatch Paper/Paper-API EmpireCraft-API HEAD api
applyPatch Paper/Paper-Server EmpireCraft-Server HEAD server

basedir
scripts/generatesources
scripts/generatesources.sh
@@ -10,17 +10,17 @@ done


cd $basedir
spigotVer=$(cat current-spigot)
paperVer=$(cat current-paper)

decompile=$(ls -lat Spigot/work/ | grep decompile | head -n 1 | awk '{print $9}')
decompile="Paper/work/1.9"
mkdir -p mc-dev/src/net/minecraft/server

cd mc-dev
if [ ! -d ".git" ]; then
git init
fi

cp $basedir/Spigot/work/$decompile/net/minecraft/server/*.java src/net/minecraft/server
cp $basedir/$decompile/net/minecraft/server/*.java src/net/minecraft/server

base="$basedir/EmpireCraft-Server/src/main/java/net/minecraft/server"
cd $basedir/mc-dev/src/net/minecraft/server/
@@ -33,5 +33,5 @@ done
cd $basedir/mc-dev
git add . -A
git commit . -m "mc-dev"
git tag -a "$spigotVer" -m "$spigotVer" 2>/dev/null
pushRepo . git@bitbucket.org:starlis/mc-dev $spigotVer
git tag -a "$paperVer" -m "$paperVer" 2>/dev/null
pushRepo . git@bitbucket.org:starlis/mc-dev $paperVer
@@ -2,22 +2,22 @@

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. $(dirname $SOURCE)/init.sh

nms="net/minecraft/server"
export MODLOG=""
cd $basedir
decompile=$(ls -lat Spigot/work/ | grep decompile | head -n 1 | awk '{print $9}')

export importedmcdev=""
function import {
export importedmcdev="$importedmcdev $1"
file="${1}.java"
target="$basedir/Spigot/Spigot/Spigot-Server/src/main/java/$nms/$file"
base="$basedir/Spigot/work/$decompile/$nms/$file"
target="$basedir/Paper/Paper-Server/src/main/java/$nms/$file"
base="$basedir/Paper/work/1.9/$nms/$file"

if [[ ! -f "$target" ]]; then
export MODLOG="$MODLOG Imported $file from mc-dev\n";
@@ -27,7 +27,7 @@ function import {
}

(
cd Spigot/Spigot/Spigot-Server/
cd Paper/Paper-Server/
lastlog=$(git log -1 --oneline)
if [[ "$lastlog" = *"EMC-Extra mc-dev Imports"* ]]; then
git reset --hard HEAD^
@@ -61,7 +61,7 @@ import CommandGive
import ChunkCache

(
cd Spigot/Spigot/Spigot-Server/
cd Paper/Paper-Server/
git add src -A
echo -e "EMC-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F -
)
@@ -2,26 +2,25 @@
cd $(dirname $SOURCE)/../
basedir=$(pwd)

emcb=$basedir/EMC-Bukkit
emccb=$basedir/EMC-CraftBukkit

API_REPO="git@bitbucket.org:starlis/Spigot-API"
SERVER_REPO="git@bitbucket.org:starlis/Spigot-Server"

function cleanupPatches {
cd "$1"
for patch in *.patch; do
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|Date\: )")
cd "$1"
for patch in *.patch; do
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|Date\: )")

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
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

if [ "x$diffs" == "x" ] ; then
git reset HEAD $patch >/dev/null
git checkout -- $patch >/dev/null
fi
done
if [ "x$diffs" == "x" ] ; then
git reset HEAD $patch >/dev/null
git checkout -- $patch >/dev/null
fi
done
}
function pushRepo {
echo "Pushing - $1 ($3) to $2"
@@ -2,28 +2,27 @@
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. $(dirname $SOURCE)/init.sh

PS1="$"
echo "Rebuilding patch files from current fork state..."
spigotVer=$(cat current-spigot)
function savePatches {
what=$1
cd $basedir/$what/
mkdir -p $basedir/patches/$2
rm $basedir/patches/$2/*.patch 2>/dev/null
git format-patch --quiet -N -o $basedir/patches/$2 upstream
cd $basedir
git add -A $basedir/patches/$2
cleanupPatches $basedir/patches/$2/
echo " Patches saved for $what to patches/$2"
what=$1
cd $basedir/$what/
mkdir -p $basedir/patches/$2
rm $basedir/patches/$2/*.patch 2>/dev/null
git format-patch --quiet -N -o $basedir/patches/$2 upstream/upstream
cd $basedir
git add -A $basedir/patches/$2
cleanupPatches $basedir/patches/$2/
echo " Patches saved for $what to patches/$2"
}

savePatches EmpireCraft-API bukkit
savePatches EmpireCraft-Server craftbukkit
savePatches EmpireCraft-API api
savePatches EmpireCraft-Server server

$basedir/scripts/push.sh
#$basedir/scripts/push.sh

This file was deleted.

@@ -0,0 +1,58 @@
#!/bin/bash
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. $(dirname $SOURCE)/init.sh

if [ "$1" == "update" ]; then

(
cd "$basedir/Paper/"
git fetch && git reset --hard origin/master
cd ../
git add Paper
)
fi

paperVer=$(gethead Paper)
cd "$basedir/Paper"

./build.sh

basedir
. scripts/importmcdev.sh


cd Paper/

version=$(echo -e "Paper: $paperVer\nmc-dev:$importedmcdev")
tag="upstream-$(echo -e $version | sha1sum | awk '{print $1}')"

function tag {
(
cd $1
if [ "$2" == "1" ]; then
git tag -d "$tag" 2>/dev/null
fi
echo -e "$(date)\n\n$version" | git tag -a "$tag" -F - 2>/dev/null
)
}
echo "Tagging as $tag"
echo -e "$version"

forcetag=0
if [ "$(cat $basedir/current-paper)" != "$tag" ]; then
forcetag=1
fi

tag Paper-API $forcetag
tag Paper-Server $forcetag

echo "$tag" > $basedir/current-paper
pushRepo Paper-API $API_REPO $tag
pushRepo Paper-Server $SERVER_REPO $tag