Skip to content

Instantly share code, notes, and snippets.

@nickboldt
Forked from robstryker/move_jee_features_to_ws.sh
Last active January 18, 2018 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickboldt/29c9fa3a25c25c481ebcf1a5193a693e to your computer and use it in GitHub Desktop.
Save nickboldt/29c9fa3a25c25c481ebcf1a5193a693e to your computer and use it in GitHub Desktop.
#!/bin/bash -xe
# see also https://gist.github.com/nickboldt/6afc71826e82518c5e7b7d3c3fdcc4f3
# merge sse repos into a single repo
START_TIME=`date +%s`
# work in a tempdir. The tmp-dir name is something like /home/user/tmp/this_scripts_name/
tmpdir=~/tmp/${0/.sh/.tmp}
tmpdirCache=~/tmp/${0/.sh/.tmp}_cache
#rm -fr ${tmpdir}
mkdir -p ${tmpdir}
cd ${tmpdir}
# in case we have another alias for mv, like 'mv -i'
alias mv=mv
alias rm=rm
# set our local pull command depending on git version
verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
verlt() {
[ "$1" = "$2" ] && return 1 || verlte $1 $2
}
GIT_VERSION=`git version | head -1 | cut -f 3 -d " "`
verlte $GIT_VERSION 2.9.0 && ALLOW_PULL_FLAG=false || ALLOW_PULL_FLAG=true
if $ALLOW_PULL_FLAG
then
LOCAL_PULL_CMD="git pull --no-edit --allow-unrelated-histories --no-rebase --rebase=false"
else
LOCAL_PULL_CMD="git pull --no-edit --no-rebase --rebase=false"
fi
MVN="mvn clean install -fae -e -Dplatform-repo.url=http://download.eclipse.org/eclipse/updates/4.8-I-builds/"
# Make sure different users with different settings will run the script as intended
gitBranchSettings ()
{
git config branch.autosetuprebase never
git config branch.autosetupmerge false
git config branch.master.rebase false
}
# handle changes to parent pom
if [[ ! -d webtools.releng.aggregator ]]; then git clone http://git.eclipse.org/gitroot/webtools/webtools.releng.aggregator.git; fi
pushd webtools.releng.aggregator/wtp-parent
gitBranchSettings
git reset --hard origin/master
${MVN}
popd
git clone http://git.eclipse.org/gitroot/webservices/webtools.webservices.git
if [[ -d ${tmpdirCache}/javaee_tmp_filterbranched ]]; then
cp -R ${tmpdirCache}/javaee_tmp_filterbranched webtools.javaee
else
echo "${tmpdirCache}/javaee_tmp_filterbranched does not exist"
git clone http://git.eclipse.org/gitroot/jeetools/webtools.javaee.git
cd webtools.javaee
git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch docs/ plugins/ site/ tests/ pom.xml' --prune-empty --tag-name-filter cat -- --all
git filter-branch --force --tree-filter \
'mkdir features/javaee-web; mv features/* features/javaee-web/ || true' \
--tag-name-filter cat -- --all
END_TIME=`date +%s`
EXEC_TIME=$((END_TIME-START_TIME))
echo $EXEC_TIME " seconds to complete filter branch"
mkdir ${tmpdirCache}
mkdir ${tmpdirCache}/javaee_tmp_filterbranched
rm .project .gitignore
git commit -a -m "Remove files likely to clash on merge" --signoff
cd ../
cp -R webtools.javaee ${tmpdirCache}/javaee_tmp_filterbranched
fi
cd webtools.webservices
$LOCAL_PULL_CMD ../webtools.javaee
cat pom.xml | head -n 128 > pom2.xml;
cat features/javaee-web/pom.xml | grep "<module>" | sed 's/ *//g' | sed 's/module>org/module>features\/javaee-web\/org/g' | awk '{ print " " $0;}' >> pom2.xml;
cat pom.xml | tail -n 15 >> pom2.xml
mv pom2.xml pom.xml
git commit -a -m "Update root pom" --signoff
# next apply these changes:
# https://github.com/robstryker/webtools.webservices/pull/1
git cherry-pick c2c6a57e5664883fa3a25555c666af8abbe8a6fe
# https://github.com/robstryker/webtools.webservices/pull/2
git cherry-pick 0273700670bac6ceaaf4766b9c171bd1706407e6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment