-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#! /usr/bin/env bash | ||
|
||
#------------------------------------------------------------------------------# | ||
# This script updates any submodules that are set to track a specific branch | ||
# to the HEAD of the specified branch. | ||
# | ||
# The script checks that: | ||
# - The user is on the HEAD of the 'devel' branch of the current project. | ||
# - The user does not have any uncommitted changes. | ||
# | ||
# This script should be used with some care because it will modify the remote. | ||
#------------------------------------------------------------------------------# | ||
|
||
# Make sure that the user is on the devel branch | ||
branch=`git branch | grep \* | cut -d ' ' -f2` | ||
|
||
if [ "$branch" != "devel" ] ; then | ||
echo "ERROR: You must be on the devel branch to run this script!!!" | ||
echo "Try: git checkout devel" | ||
exit 1 | ||
fi | ||
|
||
# Make sure that the user is on the HEAD of the devel branch | ||
local_hash=`git rev-parse devel` | ||
remote_hash=`git rev-parse origin/devel` | ||
|
||
if [ "$local_hash" != "$remote_hash" ] ; then | ||
echo "ERROR: You're local devel branch is not up-to-date with the remote!!!" | ||
echo "Try: git pull" | ||
exit 1 | ||
fi | ||
|
||
# Make sure that the user does not have any uncommitted changes | ||
modfied=`git status | grep modified` | ||
|
||
if [ ! -z "${modified// }" ] ; then | ||
echo "ERROR: You have uncommitted changes in your local repository!!!" | ||
echo "You can only run this script on a clean devel branch" | ||
exit 1 | ||
fi | ||
|
||
# Pull in the latest HEAD for all submodules that track a branch | ||
git submodule update --remote | ||
|
||
# Only add and commit if something actually changed | ||
modfied=`git status | grep modified` | ||
|
||
if [ ! -z "${modified// }" ] ; then | ||
git add -u | ||
git commit -m "Updating submodules [update-submodules script]" | ||
git push | ||
else | ||
echo "Everything up-to-date" | ||
fi |