| OLD | NEW |
| 1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # This script will try to sync the bootstrap directories and then defer control. | 6 # This script will try to sync the bootstrap directories and then defer control. |
| 7 | 7 |
| 8 if [ "$USER" == "root" ]; | 8 if [ "$USER" == "root" ]; |
| 9 then | 9 then |
| 10 echo Running depot tools as root is sad. | 10 echo Running depot tools as root is sad. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 SVN="$base_dir/svn_bin/svn.exe" | 27 SVN="$base_dir/svn_bin/svn.exe" |
| 28 fi | 28 fi |
| 29 | 29 |
| 30 GIT="git" | 30 GIT="git" |
| 31 if [ -d "$base_dir/git_bin" -a $MINGW = 0 ]; then | 31 if [ -d "$base_dir/git_bin" -a $MINGW = 0 ]; then |
| 32 GIT="$base_dir/git_bin/bin/git.exe" | 32 GIT="$base_dir/git_bin/bin/git.exe" |
| 33 fi | 33 fi |
| 34 | 34 |
| 35 # Test git and git --version. | 35 # Test git and git --version. |
| 36 function test_git { | 36 function test_git { |
| 37 local GITV="$("$GIT" --version)" || { | 37 local GITV |
| 38 GITV="$("$GIT" --version)" || { |
| 38 echo "git isn't installed, please install it" | 39 echo "git isn't installed, please install it" |
| 39 exit 1 | 40 exit 1 |
| 40 } | 41 } |
| 41 | 42 |
| 42 GITV="${GITV##* }" # Only examine last word (i.e. version number) | 43 GITV="${GITV##* }" # Only examine last word (i.e. version number) |
| 43 local GITD=( ${GITV//./ } ) # Split version number into decimals | 44 local GITD=( ${GITV//./ } ) # Split version number into decimals |
| 44 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then | 45 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then |
| 45 echo "git version is ${GITV}, please update to a version later than 1.6" | 46 echo "git version is ${GITV}, please update to a version later than 1.6" |
| 46 exit 1 | 47 exit 1 |
| 47 fi | 48 fi |
| 48 } | 49 } |
| 49 | 50 |
| 50 # Test git svn and git svn --version. | 51 # Test git svn and git svn --version. |
| 51 function test_git_svn { | 52 function test_git_svn { |
| 52 local GITV="$("$GIT" svn --version)" || { | 53 local GITV |
| 54 GITV="$("$GIT" svn --version)" || { |
| 53 echo "git-svn isn't installed, please install it" | 55 echo "git-svn isn't installed, please install it" |
| 54 exit 1 | 56 exit 1 |
| 55 } | 57 } |
| 56 | 58 |
| 57 GITV="${GITV#* version }" # git svn --version has extra output to remove. | 59 GITV="${GITV#* version }" # git svn --version has extra output to remove. |
| 58 GITV="${GITV% (svn*}" | 60 GITV="${GITV% (svn*}" |
| 59 local GITD=( ${GITV//./ } ) # Split version number into decimals | 61 local GITD=( ${GITV//./ } ) # Split version number into decimals |
| 60 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then | 62 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then |
| 61 echo "git version is ${GITV}, please update to a version later than 1.6" | 63 echo "git version is ${GITV}, please update to a version later than 1.6" |
| 62 exit 1 | 64 exit 1 |
| 63 fi | 65 fi |
| 64 } | 66 } |
| 65 | 67 |
| 66 function is_git_clone_repo { | 68 function is_git_clone_repo { |
| 67 "$GIT" config remote.origin.fetch > /dev/null | 69 "$GIT" config remote.origin.fetch > /dev/null |
| 68 } | 70 } |
| 69 | 71 |
| 70 function update_git_repo { | 72 function update_git_repo { |
| 71 if is_git_clone_repo; then | 73 if is_git_clone_repo; then |
| 72 git fetch -q origin &> /dev/null | 74 git fetch -q origin &> /dev/null |
| 73 local REBASE_TXT=$(git rebase -q origin/master 2>&1) | 75 local REBASE_TXT STATUS |
| 74 local STATUS=$? | 76 REBASE_TXT=$(git rebase -q origin/master 2>&1) |
| 75 if [[ $STATUS != 0 ]]; then | 77 STATUS=$? |
| 78 if [[ $STATUS -ne 0 ]]; then |
| 76 echo "depot_tools update failed. Conflict in $base_dir" >&2 | 79 echo "depot_tools update failed. Conflict in $base_dir" >&2 |
| 77 echo "$REBASE_TXT" >&2 | 80 echo "$REBASE_TXT" >&2 |
| 78 git rebase --abort 2> /dev/null | 81 git rebase --abort 2> /dev/null |
| 79 fi | 82 fi |
| 80 return $STATUS | 83 return $STATUS |
| 81 fi | 84 fi |
| 82 | 85 |
| 83 test_git_svn | 86 test_git_svn |
| 84 # work around a git-svn --quiet bug | 87 # work around a git-svn --quiet bug |
| 85 OUTPUT=`"$GIT" svn rebase -q -q` | 88 OUTPUT=`"$GIT" svn rebase -q -q` |
| (...skipping 23 matching lines...) Expand all Loading... |
| 109 # Update the root directory to stay up-to-date with the latest depot_tools. | 112 # Update the root directory to stay up-to-date with the latest depot_tools. |
| 110 BEFORE_REVISION=$(get_svn_revision) | 113 BEFORE_REVISION=$(get_svn_revision) |
| 111 "$SVN" -q up "$base_dir" | 114 "$SVN" -q up "$base_dir" |
| 112 AFTER_REVISION=$(get_svn_revision) | 115 AFTER_REVISION=$(get_svn_revision) |
| 113 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then | 116 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then |
| 114 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 | 117 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 |
| 115 fi | 118 fi |
| 116 fi | 119 fi |
| 117 | 120 |
| 118 find "$base_dir" -iname "*.pyc" -exec rm {} \; | 121 find "$base_dir" -iname "*.pyc" -exec rm {} \; |
| OLD | NEW |