From 6f4c13a6fbd6adc47bd825f83e8ae80ec6ac9bb4 Mon Sep 17 00:00:00 2001 From: Andy Lulham Date: Mon, 26 Feb 2018 15:26:43 +0000 Subject: [PATCH] Simplify update_submodules script --- update_submodules.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/update_submodules.sh b/update_submodules.sh index 6d06bf4b..e76f5a33 100755 --- a/update_submodules.sh +++ b/update_submodules.sh @@ -13,23 +13,16 @@ for version in 1.04 1.05 2.01 2.02 2.03; do # Check out a new branch to get around branch protection git checkout -b update-submodules-$timestamp-$version - # Loop over each subfolder, pull the latest version and add to staging - for folder in IATI-Codelists IATI-Extra-Documentation IATI-Schemas IATI-Rulesets; do - # Enter the specified folder (which contains the submodule) - cd $folder + # Discard local changes to submodules + # See: https://stackoverflow.com/a/27415757/2323348 + git submodule deinit -f . + git submodule update --init - # Ensure that we are on the correct branch (i.e. Git branch) - git checkout version-$version + # Pull the latest versions of submodules + git submodule update --remote - # Pull the latest code from origin for this version (i.e. Git branch) - git pull origin version-$version - - # Go back to the SSOT folder - cd .. - - # Add the specified folder (which contains the submodule) to staging - git add $folder - done + # Git add submodules + git add IATI-Codelists IATI-Extra-Documentation IATI-Schemas IATI-Rulesets # Commit updated submodules git commit -m "Updated submodules (using script) "$version