summaryrefslogtreecommitdiffstats
path: root/commit_all_submodules
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2012-12-04 03:44:32 +0100
committerSlávek Banko <slavek.banko@axis.cz>2012-12-04 03:44:32 +0100
commit95dd4739aa62188f6ffbfdf80b6537357559a7ec (patch)
treefa3730e7ea8f71643e57b69fcb488bb32921a57c /commit_all_submodules
parent5ead2a2d3b029dbdc616c282d7aa6b6fc7ea7907 (diff)
downloadscripts-95dd4739aa62188f6ffbfdf80b6537357559a7ec.tar.gz
scripts-95dd4739aa62188f6ffbfdf80b6537357559a7ec.zip
Updating git scripts
+ add support for gitfile (submodules with git >= 1.7.8) + add gituser detection from git configuration + add support for branches + various optimizations
Diffstat (limited to 'commit_all_submodules')
-rwxr-xr-xcommit_all_submodules28
1 files changed, 22 insertions, 6 deletions
diff --git a/commit_all_submodules b/commit_all_submodules
index 2ade46f..c754640 100755
--- a/commit_all_submodules
+++ b/commit_all_submodules
@@ -1,26 +1,40 @@
#!/bin/bash
-if [[ ! -d .git ]]; then
+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 -q HEAD | sed "s|^refs/heads/||"`
+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
- read -p "Enter your TDE GIT username []: " -e gituser
+ 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/config"
-git submodule foreach "git pull && git push origin master"
+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"
@@ -28,5 +42,7 @@ if [[ $RETCODE != 0 ]]; then
fi
git commit -a -m "$commitmessage" || true
-sed -i "s/system@scm\.trinitydesktop\.org/$gituser@scm\.trinitydesktop\.org/g" .git/config
-git pull && git push origin master || 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