Skip to content

Instantly share code, notes, and snippets.

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/8cc1b35e65dd7756ad9d09be17d5a8b6 to your computer and use it in GitHub Desktop.
Save nickboldt/8cc1b35e65dd7756ad9d09be17d5a8b6 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 -f .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
## This concludes the merge of jee features. The rest of this script is optional
cp .gitignore ../gitignore_bak
cd ../
git clone http://git.eclipse.org/gitroot/webservices/webtools.webservices.axis2.git
git clone http://git.eclipse.org/gitroot/webservices/webtools.webservices.jaxws.git
cd webtools.webservices.axis2
cat .gitignore >> ../gitignore_bak
rm -f pom.xml .gitignore .project
git commit -a -m "Remove files likely to clash in merge" --signoff
cd ../
cd webtools.webservices.jaxws
cat .gitignore >> ../gitignore_bak
rm -f pom.xml .gitignore .project
git commit -a -m "Remove files likely to clash in merge" --signoff
cd ../
cd webtools.webservices
$LOCAL_PULL_CMD ../webtools.webservices.axis2/
$LOCAL_PULL_CMD ../webtools.webservices.jaxws/
cat .gitignore | sort | uniq > .gitignore2
mv -f .gitignore2 .gitignore
# Inspect .gitignore, realize no changes were really done here
git checkout .gitignore
ls ../webtools.webservices.axis2/bundles/ | awk '{ print " <module>bundles/" $0 "</module>";}' > bundles.txt
ls ../webtools.webservices.jaxws/bundles/ | awk '{ print " <module>bundles/" $0 "</module>";}' >> bundles.txt
ls ../webtools.webservices.axis2/docs/ | awk '{ print " <module>docs/" $0 "</module>";}' > docs.txt
ls ../webtools.webservices.jaxws/docs/ | awk '{ print " <module>docs/" $0 "</module>";}' >> docs.txt
ls ../webtools.webservices.axis2/features/ | awk '{ print " <module>features/" $0 "</module>";}' > features.txt
ls ../webtools.webservices.jaxws/features/ | awk '{ print " <module>features/" $0 "</module>";}' >> features.txt
ls ../webtools.webservices.axis2/tests/ | awk '{ print " <module>tests/" $0 "</module>";}' | grep -v "jmock" > tests.txt
ls ../webtools.webservices.jaxws/tests/ | awk '{ print " <module>tests/" $0 "</module>";}' | grep -v "jmock" >> tests.txt
{ cat pom.xml | head -n 150; cat *.txt; cat pom.xml | tail -n 5; } > pom2.xml
mv pom2.xml pom.xml
rm -f bundles.txt docs.txt features.txt tests.txt
JEEARTID=`cat pom.xml | grep "artifactId" | head -n 2 | tail -n 1 | sed 's/.*artifactId.org/org/' | sed 's/<.*//'`
JEEVERSID=`cat pom.xml | grep "version" | head -n 3 | tail -n 1 | sed 's/[^0-9]*//' | sed 's/-SNAPSHOT.*/-SNAPSHOT/'`
for td2 in $(find . -maxdepth 1 -type d | grep -v "^\.$" | grep -v "\.git" | grep -v "site$"); do
cd $td2
echo "inside " `pwd`
for td in $(find . -maxdepth 1 -type d | grep -v "^\.$"); do
if [[ -f ${td}/pom.xml ]]; then
echo "Fixing $td pom.xml"
sed "1,/artifactId.*/s/artifactId.*/artifactId>$JEEARTID<\/artifactId>/" $td/pom.xml > $td/pom2.xml
sed "1,/groupId.*/s/groupId.*/groupId>org.eclipse.webtools.webservices<\/groupId>/" $td/pom2.xml > $td/pom3.xml
tr '\n' '%' < $td/pom3.xml | sed "s/version>[^>]*/version>$JEEVERSID<\/version/1" | tr '%' '\n' > $td/pom4.xml
mv $td/pom4.xml $td/pom.xml
rm -f $td/pom2.xml $td/pom3.xml
else
echo "[WARNING] ${td}/pom.xml not found, skipping."
fi
done
cd ../
done
git commit -a -m "Update poms to reference proper root pom" --signoff
{ cat tests/org.eclipse.jst.ws.cxf.tests/pom.xml | head -n 58; cat tests/org.eclipse.jst.ws.cxf.tests/pom.xml | tail -n 18; } > tests/org.eclipse.jst.ws.cxf.tests/pom2.xml
mv tests/org.eclipse.jst.ws.cxf.tests/pom2.xml tests/org.eclipse.jst.ws.cxf.tests/pom.xml
git commit -a -m "Remove external dependency to ws.jxb.core which is in same reactor now" --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