Skip to content

Instantly share code, notes, and snippets.

@nickboldt
Created January 19, 2018 20:47
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/a74a1e9378fd19d1294e8bf4efe3b04d to your computer and use it in GitHub Desktop.
Save nickboldt/a74a1e9378fd19d1294e8bf4efe3b04d to your computer and use it in GitHub Desktop.
merge 19 dtp repos into 1
#!/bin/bash -xe
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
}
targetRepo=org.eclipse.datatools
repoList="org.eclipse.datatools.connectivity org.eclipse.datatools.doc org.eclipse.datatools.enablement.general org.eclipse.datatools.enablement.hsqldb org.eclipse.datatools.enablement.ibm org.eclipse.datatools.enablement.ingres org.eclipse.datatools.enablement.msft org.eclipse.datatools.enablement.mysql org.eclipse.datatools.enablement.oda org.eclipse.datatools.enablement.oracle org.eclipse.datatools.enablement.postgresql org.eclipse.datatools.enablement.sap org.eclipse.datatools.enablement.sqlite org.eclipse.datatools.enablement.sybase org.eclipse.datatools.incubator org.eclipse.datatools.modelbase org.eclipse.datatools.nl org.eclipse.datatools.sqltools"
# Now clone the repos
for d in ${targetRepo} ${repoList}; do
if [[ ! -d ${d} ]]; then
git clone http://git.eclipse.org/gitroot/datatools/${d}.git
fi
done
for d in ${targetRepo} ${repoList}; do
pushd ${d}
gitBranchSettings
git reset --hard origin/master
popd
done
# Let's collect all the gitignores into one file to use later
for d in ${repoList}; do
pushd ${d}
rm -f pom.xml
rm -f .project
cat .gitignore >> ../git_ignore_accumulator
rm -f .gitignore
git commit -a -m "Removing poms and .gitignore files that will be clobbered" --signoff
popd
done
cd ${targetRepo}
mkdir -p examples plugins releng docs features tests
for d in ${repoList}; do
$LOCAL_PULL_CMD ../${d}
done
# "Merging all repos together" .
cat ../git_ignore_accumulator >> .gitignore
cat .gitignore | sort | uniq > .gitignore2
mv -f .gitignore2 .gitignore
# WARNING: make sure correct quotes used in next line (stupid google)
git commit -s -m "Accumulate all gitignore files. To be cleaned later" .gitignore
# move stuff around
cd plugins/
git mv org.eclipse.datatools.modelbase.* modelbase/
git mv org.eclipse.datatools.enablement.* enablement/
git mv org.eclipse.datatools.connectivity* connectivity/
mkdir docs
git mv org.eclipse.datatools.doc.isv docs/
git mv org.eclipse.datatools.help docs/
git mv org.eclipse.datatools.oda.cshelp docs/
git commit -s -m "reorganize plugins into modelbase, enablement, connectivity, docs folders" .
cd ../
# generate poms
xmvn -o org.eclipse.tycho:tycho-pomgenerator-plugin:generate-poms \
-DgroupId=org.eclipse.datatools -Dversion=1.14.100-SNAPSHOT
git add */pom.xml */*/pom.xml */*/*/pom.xml
git commit -s -m "add generated poms" */pom.xml */*/pom.xml */*/*/pom.xml
# edit generated root pom - comment out some lines (were not included in Fedora build so might not work here):
cat pom.xml | egrep -v \
"org.eclipse.datatools.sdk|org.eclipse.birt.dtp.nl|features/org.eclipse.datatools.enablement.oda.ecore|features/org.eclipse.datatools.enablement.sdk.feature" \
> pom2.xml; mv pom2.xml pom.xml
git add pom.xml
git commit -s -m "add generated root pom, minus some features/plugins" pom.xml
END_TIME=`date +%s`
EXEC_TIME=$((END_TIME-START_TIME))
echo $EXEC_TIME " seconds execution time without build"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment