summaryrefslogtreecommitdiffstats
path: root/switch_all_submodules_to_head_and_clean
blob: 5b409b8fff0ae3bf820d36be600491dce6660fb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

if [[ ! -d .git ]]; then
	echo "This script can only be run from a top level git directory.  Exiting..."
	exit 1
fi

echo "Preparing $PWD for development use"
if [[ $1 == "" ]]; then
	read -p "Enter your TDE GIT username []: " -e gituser
else
	gituser=$1
fi

if [[ $gituser == "" ]]; then
	gituser="anonymous"
fi

THISSCRIPT=$(readlink -f $0)

if [[ ! -e "$THISSCRIPT" ]]; then
	echo "Unable to find myself!  Exiting..."
	exit 1
fi

git reset --hard HEAD
git clean -dxf

if [[ -e .gitmodules ]]; then
	if [[ $gituser == "anonymous" ]]; then
		sed -i 's/system@//g' .gitmodules
	else
		sed -i "s/system@/$gituser@/g" .gitmodules
	fi

	git submodule init
	git submodule update
	git submodule foreach "git checkout master"
	git submodule foreach "git pull"
	git submodule foreach "$THISSCRIPT $gituser"

	git checkout -- .gitmodules
fi