Commit b9d08cec authored by cmp@chromium.org's avatar cmp@chromium.org

Handle updating depot_tools repos that are git cloned.

Until recently, no proper Git clone of depot_tools existed.
All Git clones were set up locally via git svn clone.  The
way repos of that type are updated is via 'git svn rebase'.

Now, a supported Git clone of depot_tools exists.  The
update process for repos of this type is via 'git fetch'
and 'git rebase'.

Modify the update_depot_tools* scripts so they can update
depot_tools for git cloned or git svn cloned methods.  This
also means that git svn is no longer required, so move that
test after we check for git cloned repos.

R=maruel@chromium.org

TEST=Linux + git clone: on Linux, git clone
https://git.chromium.org/chromium/tools/depot_tools.git.  Apply
and commit this patch locally.  Note commit hash of HEAD.  Run
'git reset --hard "HEAD^^^"'.  Run
'git cherry-pick HASH_OF_UPDATE_CHANGE'.  Run './update_depot_tools'.
Verify depot_tools is updated to latest available revision + this
change.

TEST=Linux + git svn clone: on Linux, git svn clone
svn://svn.chromium.org/chrome/trunk/tools/depot_tools.
Apply and commit this patch locally.  Note commit hash
of HEAD.  Run 'git reset --hard "HEAD^^^"'.  Run 'git cherry-pick
HASH_OF_UPDATE_CHANGE'.  Run './update_depot_tools'.  Verify
depot_tools is updated to latest available revision + this change.

TEST=Windows command prompt + git clone: on Windows command prompt,
run Linux+git clone test, except use update_depot_tools.bat.  Verify
depot_tools is updated to latest available revision + this change.

TEST=Windows command prompt + git svn clone: on Windows command
prompt, run Linux+git svn clone test, except use
update_depot_tools.bat.  Verify depot_tools is updated to latest
available revision + this change.

TEST=Windows cygwin + git clone: on Windows command prompt,
run Linux+git clone test.  Verify depot_tools is updated to latest
available revision + this change.

TEST=Windows cygwin + git svn clone: on Windows command
prompt, run Linux+git svn clone test.  Verify depot_tools is updated
to latest available revision + this change.

Review URL: https://chromiumcodereview.appspot.com/10263004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@134732 0039d316-1c4b-4281-b951-d872f2087c98
parent 4b37d61a
...@@ -63,6 +63,26 @@ function test_git_svn { ...@@ -63,6 +63,26 @@ function test_git_svn {
fi fi
} }
function is_git_clone_repo {
"$GIT" config remote.origin.fetch > /dev/null
}
function update_git_repo {
if is_git_clone_repo; then
git fetch -q origin > /dev/null
git rebase -q origin > /dev/null
return 0
fi
test_git_svn
# work around a git-svn --quiet bug
OUTPUT=`"$GIT" svn rebase -q -q`
if [[ ! "$OUTPUT" == *Current.branch* ]]; then
echo $OUTPUT 1>&2
fi
return 0
}
# Get the current SVN revision. # Get the current SVN revision.
get_svn_revision() { get_svn_revision() {
LANGUAGE=C "$SVN" info "$base_dir" | \ LANGUAGE=C "$SVN" info "$base_dir" | \
...@@ -73,12 +93,7 @@ get_svn_revision() { ...@@ -73,12 +93,7 @@ get_svn_revision() {
if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ] if [ "X$DEPOT_TOOLS_UPDATE" != "X0" -a -e "$base_dir/.git" ]
then then
cd $base_dir cd $base_dir
test_git_svn update_git_repo
# work around a git-svn --quiet bug
OUTPUT=`"$GIT" svn rebase -q -q`
if [[ ! "$OUTPUT" == *Current.branch* ]]; then
echo $OUTPUT 1>&2
fi
cd - > /dev/null cd - > /dev/null
fi fi
......
...@@ -13,6 +13,8 @@ setlocal ...@@ -13,6 +13,8 @@ setlocal
:: not already in the PATH environment variable. :: not already in the PATH environment variable.
call "%~dp0bootstrap\win\win_tools.bat" force call "%~dp0bootstrap\win\win_tools.bat" force
if errorlevel 1 goto :EOF if errorlevel 1 goto :EOF
:: Now clear errorlevel so it can be set by other programs later.
set errorlevel=
:: Shall skip automatic update? :: Shall skip automatic update?
IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF
...@@ -31,5 +33,13 @@ goto :EOF ...@@ -31,5 +33,13 @@ goto :EOF
:GIT_UPDATE :GIT_UPDATE
cd /d "%~dp0." cd /d "%~dp0."
call git config remote.origin.fetch > NUL
if errorlevel 1 goto :GIT_SVN_UPDATE
call git fetch -q origin > NUL
call git rebase -q origin > NUL
goto :EOF
:GIT_SVN_UPDATE
cd /d "%~dp0."
call git svn rebase -q -q call git svn rebase -q -q
goto :EOF goto :EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment