4 URLBASE=$(git ls-remote --get-url)
5 if echo "$@" | grep -c "\-\-reset" &> /dev/null; then
9 # Remove untracked files and directories.
10 # This is needed by buildbot to avoid conflict when applying a patch.
11 # Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9584
12 # WARNING: Be careful when using this since it'll delete your local changes.
14 if echo "$@" | grep -c "\-\-clean" &> /dev/null; then
15 CleanCommand='git clean -df'
19 isLocalGit=$([ -d "$URLBASE" ] && echo 1 || echo 0)
20 if [ $isLocalGit == "1" ]; then
22 local_gits=$(find $URLBASE/src -name .git -type d | xargs dirname | sort)
23 for REPO in $local_gits; do
24 REPOPATH=${REPO#$URLBASE/}
26 if [ -d $REPOPATH ] ; then
27 pushd $REPOPATH 2>&1 > /dev/null
30 if [ "$isReset" == "1" ]; then
31 git reset --hard FETCH_HEAD
33 git rebase FETCH_HEAD || exit $?
37 git clone $REPO $REPOPATH
41 if [ -d $URLBASE/out.x64/Dependencies ] && [ ! -d out.x64/Dependencies ]; then
42 SCRIPTDIR=$(cd $(dirname $0); pwd -P)
43 SRCDIR=$URLBASE/out.x64/Dependencies
44 TGTDIR=$SCRIPTDIR/out.x64/Dependencies
46 cp -al $SRCDIR out.x64/
47 find out.x64/Dependencies -name *.pc -exec sed -i "s:$SRCDIR:$TGTDIR:g" {} \;
52 URLBASE=$(dirname $URLBASE)
53 REPOS=( "src|$URLBASE/s-chromium.git" \
54 "src/third_party/WebKit|$URLBASE/s-blink" \
55 "src/third_party/skia|$URLBASE/s-skia.git" \
56 "src/third_party/libjingle/source/talk|$URLBASE/s-libjingle_source_talk.git" \
57 "src/third_party/webrtc|$URLBASE/s-webrtc.git" \
58 "src/v8|$URLBASE/s-v8" )
60 function rmdir_if_not_repo {
63 if [ -d $REPOPATH ] ; then
64 isDesiredRepo=$(git --git-dir=$REPOPATH/.git --work-tree=$REPOPATH ls-remote --get-url \
65 | grep -c $REPOURL || :)
66 if [ "$isDesiredRepo" == "0" ] ; then
67 echo "... Deleting ${REPOPATH} (backup: ${REPOPATH}.bak)"
68 mv ${REPOPATH} ${REPOPATH}.bak 2>&1 > /dev/null
73 for K in ${REPOS[@]} ; do
77 rmdir_if_not_repo $REPOPATH $REPO
78 if [ -d $REPOPATH ] ; then
79 pushd $REPOPATH 2>&1 > /dev/null
81 CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`
82 if [ "x$CURRENT_BRANCH" == "x$BRANCH" ] ; then
83 echo Updating branch $BRANCH of $REPO in $REPOPATH
84 git fetch $REPO $BRANCH
85 if [ "$isReset" == "1" ]; then
86 git reset --hard FETCH_HEAD
88 git rebase FETCH_HEAD || exit $?
91 echo Fetching branch $BRANCH of $REPO into $REPOPATH
92 REMOTENAME=$(git remote -v | grep -m 1 $REPO | cut -f1)
93 git remote set-branches --add $REMOTENAME $BRANCH
94 git fetch $REMOTENAME $BRANCH
95 git checkout ${isReset:+-f} -B $BRANCH --track $REMOTENAME/$BRANCH
99 echo Cloning branch $BRANCH of $REPO into $REPOPATH
100 git clone --single-branch -b $BRANCH $REPO $REPOPATH
104 if [ "$isReset" == "1" ]; then