Skip to content

Experimenting with git submodules

Bernhard Thiele edited this page May 21, 2019 · 2 revisions

Experimenting with git submodules

As of 2019-05-21 the master branch uses git submodules. These are just some notes from experimenting with it.

Adding

Example for adding a git submodule

git submodule add --name gtest ../../google/googletest.git Modelica_DeviceDrivers/Resources/thirdParty/googletest
git commit -a -m "Add googletest as submodule"
cd Modelica_DeviceDrivers/Resources/thirdParty/googletest/
git tag -l
git checkout release-1.8.1
cd ..
add googletest
git commit -m "Move googletest submodule to release-1.8.1"

Using

git clone --recursive https://github.com/modelica/Modelica_DeviceDrivers.git
git submodule update --init --recursive

Issues when cutting a release

Exporting the git project to a ZIP (git archive ...), as I do for cutting the releases, does not export the files in the submodule.

Wrote a shell script which allows to export a source archive including the files from the googletest submodule.

The script also works in the git bash which is shipped with the Windows TortoiseGit client, except that the zip executable is missing in a standard installation. It looks like:

MDDVERSION="1.6.0"
MDDVERSIONV="v1_6_0"

# Below there should be no need for changes
MDDPREFIX="Modelica_DeviceDrivers $MDDVERSION"
MDDARCHIVE_TAR="Modelica_DeviceDrivers_$MDDVERSIONV.tar"
MDDARCHIVE_ZIP="Modelica_DeviceDrivers_$MDDVERSIONV.zip"
git archive -o $MDDARCHIVE_TAR --prefix="$MDDPREFIX/" HEAD:Modelica_DeviceDrivers/
cd Modelica_DeviceDrivers/Resources/thirdParty/googletest/
git archive -o googletest.tar --prefix="$MDDPREFIX/Resources/thirdParty/googletest/"  HEAD
cd ../../../..
mv Modelica_DeviceDrivers/Resources/thirdParty/googletest/googletest.tar .
tar --concatenate --file=$MDDARCHIVE_TAR googletest.tar
mkdir tmp_archive
tar -C tmp_archive -xf "$MDDARCHIVE_TAR"
cd tmp_archive
zip -9 -r $MDDARCHIVE_ZIP "$MDDPREFIX/"
mv $MDDARCHIVE_ZIP ..
cd ..
gzip -9 -v $MDDARCHIVE_TAR
rm googletest.tar
rm -r tmp_archive
Clone this wiki locally