Chromium Code Reviews

Side by Side Diff: update_depot_tools

Issue 10263004: Handle updating depot_tools repos that are git cloned. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: comment Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | update_depot_tools.bat » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env bash 1 #!/usr/bin/env bash
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 45 matching lines...)
56 56
57 GITV="${GITV#* version }" # git svn --version has extra output to remove. 57 GITV="${GITV#* version }" # git svn --version has extra output to remove.
58 GITV="${GITV% (svn*}" 58 GITV="${GITV% (svn*}"
59 local GITD=( ${GITV//./ } ) # Split version number into decimals 59 local GITD=( ${GITV//./ } ) # Split version number into decimals
60 if ((GITD[0] < 1 || (GITD[0] == 1 && GITD[1] < 6) )); then 60 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" 61 echo "git version is ${GITV}, please update to a version later than 1.6"
62 exit 1 62 exit 1
63 fi 63 fi
64 } 64 }
65 65
66 function is_git_clone_repo {
M-A Ruel 2012/04/30 14:17:34 Why isn't this sufficient? My bash-fu is lacking.
cmp 2012/04/30 18:12:37 That's a great suggestion. I didn't realize that
67 GITCONFIG="$("$GIT" config remote.origin.fetch > /dev/null)"
68 GITCONFIG_RC="$?"
69 if [ "$GITCONFIG_RC" == "0" ]
70 then
71 return 0
72 fi
73 return 1
74 }
75
76 function update_git_repo {
77 if is_git_clone_repo; then
78 git fetch -q origin
79 git rebase -q origin
80 return 0
81 fi
82
83 test_git_svn
84 # work around a git-svn --quiet bug
85 OUTPUT=`"$GIT" svn rebase -q -q`
86 if [[ ! "$OUTPUT" == *Current.branch* ]]; then
87 echo $OUTPUT 1>&2
88 fi
89 return 0
90 }
91
66 # Get the current SVN revision. 92 # Get the current SVN revision.
67 get_svn_revision() { 93 get_svn_revision() {
68 LANGUAGE=C "$SVN" info "$base_dir" | \ 94 LANGUAGE=C "$SVN" info "$base_dir" | \
69 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}' 95 awk -F': ' '{ if ($1 == "Last Changed Rev") { print $2 }}'
70 } 96 }
71 97
72 # Update git checkouts. 98 # Update git checkouts.
73 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ] 99 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ]
74 then 100 then
75 cd $base_dir 101 cd $base_dir
76 test_git_svn 102 update_git_repo
77 # work around a git-svn --quiet bug
78 OUTPUT=`"$GIT" svn rebase -q -q`
79 if [[ ! "$OUTPUT" == *Current.branch* ]]; then
80 echo $OUTPUT 1>&2
81 fi
82 cd - > /dev/null 103 cd - > /dev/null
83 fi 104 fi
84 105
85 # We're on POSIX. We can now safely look for svn checkout. 106 # We're on POSIX. We can now safely look for svn checkout.
86 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.svn" ] 107 if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.svn" ]
87 then 108 then
88 # Update the root directory to stay up-to-date with the latest depot_tools. 109 # Update the root directory to stay up-to-date with the latest depot_tools.
89 BEFORE_REVISION=$(get_svn_revision) 110 BEFORE_REVISION=$(get_svn_revision)
90 "$SVN" -q up "$base_dir" 111 "$SVN" -q up "$base_dir"
91 AFTER_REVISION=$(get_svn_revision) 112 AFTER_REVISION=$(get_svn_revision)
92 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then 113 if [[ "$BEFORE_REVISION" != "$AFTER_REVISION" ]]; then
93 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2 114 echo "Depot Tools has been updated to revision $AFTER_REVISION." 1>&2
94 fi 115 fi
95 fi 116 fi
96 117
97 find "$base_dir" -iname "*.pyc" -exec rm {} \; 118 find "$base_dir" -iname "*.pyc" -exec rm {} \;
OLDNEW
« no previous file with comments | « no previous file | update_depot_tools.bat » ('j') | no next file with comments »

Powered by Google App Engine