@ -1,17 +1,29 @@
#!/bin/bash
#!/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..."
echo "This script can only be run from a top level git directory. Exiting..."
exit 1
exit 1
fi
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"
echo "Preparing $PWD for development use"
if [[ $1 == "" ]]; then
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
else
gituser=$1
gituser=$1
fi
fi
if [[ $gituser == "" ]]; then
read -p "Enter your TDE GIT username []: " -e gituser
fi
if [[ $gituser == "" ]]; then
if [[ $gituser == "" ]]; then
gituser="anonymous"
gituser="anonymous"
fi
fi
@ -19,8 +31,10 @@ fi
read -p "Enter your commit message []: " -e commitmessage
read -p "Enter your commit message []: " -e commitmessage
git submodule foreach "git commit -a -m \"$commitmessage\" || true"
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 "sed -i \"s/system@scm\.trinitydesktop\.org/$gituser@scm\.trinitydesktop\.org/g\" \`git rev-parse --git-dir\`/config"
git submodule foreach "git pull && git push origin master"
git submodule foreach "git pull &&\
[[ \"\`git rev-parse HEAD\`\" == \"\`git rev-parse origin/$branch\`\" ]] ||\
git push origin HEAD"
RETCODE=$?
RETCODE=$?
if [[ $RETCODE != 0 ]]; then
if [[ $RETCODE != 0 ]]; then
echo "Something went wrong"
echo "Something went wrong"
@ -28,5 +42,7 @@ if [[ $RETCODE != 0 ]]; then
fi
fi
git commit -a -m "$commitmessage" || true
git commit -a -m "$commitmessage" || true
sed -i "s/system@scm\.trinitydesktop\.org/$gituser@scm\.trinitydesktop\.org/g" .git/config
sed -i "s/system@scm\.trinitydesktop\.org/$gituser@scm\.trinitydesktop\.org/g" `git rev-parse --git-dir`/config
git pull && git push origin master || true
git pull &&\
[[ "`git rev-parse HEAD`" == "`git rev-parse origin/$branch`" ]] ||\
git push origin HEAD || true