summaryrefslogtreecommitdiffstats
path: root/scripts/commit_all_submodules
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/commit_all_submodules')
-rwxr-xr-xscripts/commit_all_submodules48
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/commit_all_submodules b/scripts/commit_all_submodules
new file mode 100755
index 000000000..ce3a8c7ab
--- /dev/null
+++ b/scripts/commit_all_submodules
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+if [[ ! -e .git ]] ||
+ [[ -z "`git rev-parse --git-dir 2>/dev/null`" ]]; then
+ echo "This script can only be run from a top level git directory. Exiting..."
+ exit 1
+fi
+
+branch=`git symbolic-ref --short -q HEAD`
+if [[ -z "$branch" ]] ||
+ [[ -z "`git rev-parse --symbolic-full-name --remotes=\"*/$branch\"`" ]]; then
+ echo "There is not active upstream branch. Exiting..."
+ exit 1
+fi
+
+echo "Preparing $PWD for development use"
+if [[ $1 == "" ]]; then
+ gituser=`sed -n "/^\[remote \"origin\"\]/,/url/s/\turl = http:\/\/\([^@]*\)@.*/\1/p" <\`git rev-parse --git-dir\`/config | grep -v "\(anonymous\|system\)"`
+else
+ gituser=$1
+fi
+
+if [[ $gituser == "" ]]; then
+ read -p "Enter your TDE GIT username []: " -e gituser
+fi
+
+if [[ $gituser == "" ]]; then
+ gituser="anonymous"
+fi
+
+read -p "Enter your commit message []: " -e commitmessage
+
+git submodule foreach "git commit -a -m \"$commitmessage\" || true"
+git submodule foreach "sed -i \"s/system@scm\.trinitydesktop\.org/$gituser@scm\.trinitydesktop\.org/g\" \`git rev-parse --git-dir\`/config"
+git submodule foreach "git pull &&\
+ [[ \"\`git rev-parse HEAD\`\" == \"\`git rev-parse origin/$branch\`\" ]] ||\
+ git push origin HEAD"
+RETCODE=$?
+if [[ $RETCODE != 0 ]]; then
+ echo "Something went wrong"
+ exit 1
+fi
+
+git commit -a -m "$commitmessage" || true
+sed -i "s/system@scm\.trinitydesktop\.org/$gituser@scm\.trinitydesktop\.org/g" `git rev-parse --git-dir`/config
+git pull &&\
+ [[ "`git rev-parse HEAD`" == "`git rev-parse origin/$branch`" ]] ||\
+ git push origin HEAD || true