blob: 58d3d849738edef1d9c4280add83ab79c7a872f0 [file] [log] [blame]
[email protected]e6c00f32012-04-13 15:39:491@echo off
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
4:: found in the LICENSE file.
5
6:: This batch file will try to sync the root directory.
7
8setlocal
9
[email protected]aa574c62013-03-20 22:13:2310:: Windows freaks out if a file is overwritten while it's being executed. Copy
11:: this script off to a temporary location and reinvoke from there before
12:: running any svn or git commands.
13IF %~nx0==update_depot_tools.bat (
14 COPY /Y %~dp0update_depot_tools.bat %TEMP%\update_depot_tools_tmp.bat >nul
15 if errorlevel 1 goto :EOF
16 %TEMP%\update_depot_tools_tmp.bat %~dp0 %*
17)
18
19set DEPOT_TOOLS_DIR=%1
20SHIFT
21
[email protected]9f36c382013-01-07 23:53:3622set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git
23
[email protected]e6c00f32012-04-13 15:39:4924:: Will download svn and python.
25:: If you don't want to install the depot_tools version of these tools, remove
26:: the 'force' option on the next command. The tools will be installed only if
27:: not already in the PATH environment variable.
[email protected]aa574c62013-03-20 22:13:2328call "%DEPOT_TOOLS_DIR%bootstrap\win\win_tools.bat" force
[email protected]e6c00f32012-04-13 15:39:4929if errorlevel 1 goto :EOF
[email protected]b9d08ce2012-05-01 18:32:4330:: Now clear errorlevel so it can be set by other programs later.
31set errorlevel=
[email protected]e6c00f32012-04-13 15:39:4932
33:: Shall skip automatic update?
34IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF
35
36:: We need either .\.svn\. or .\.git\. to be able to sync.
[email protected]aa574c62013-03-20 22:13:2337IF EXIST "%DEPOT_TOOLS_DIR%.svn\." GOTO :SVN_UPDATE
38IF EXIST "%DEPOT_TOOLS_DIR%.git\." GOTO :GIT_UPDATE
[email protected]e6c00f32012-04-13 15:39:4939echo Error updating depot_tools, no revision tool found.
40goto :EOF
41
42
43:SVN_UPDATE
[email protected]aa574c62013-03-20 22:13:2344call svn up -q "%DEPOT_TOOLS_DIR%."
[email protected]e6c00f32012-04-13 15:39:4945goto :EOF
46
47
48:GIT_UPDATE
[email protected]aa574c62013-03-20 22:13:2349cd /d "%DEPOT_TOOLS_DIR%."
[email protected]b9d08ce2012-05-01 18:32:4350call git config remote.origin.fetch > NUL
51if errorlevel 1 goto :GIT_SVN_UPDATE
[email protected]9f36c382013-01-07 23:53:3652for /F %%x in ('git config --get remote.origin.url') DO (
53 IF not "%%x" == "%GIT_URL%" (
54 echo Your depot_tools checkout is configured to fetch from an obsolete URL
55 choice /N /T 60 /D N /M "Would you like to update it? [y/N]: "
56 IF not errorlevel 2 (
57 call git config remote.origin.url "%GIT_URL%"
58 )
59 )
60)
[email protected]b9d08ce2012-05-01 18:32:4361call git fetch -q origin > NUL
[email protected]495e57b2012-09-11 18:07:0262call git rebase -q origin/master > NUL
[email protected]86c497d2013-09-30 17:32:5263if errorlevel 1 echo Failed to update depot_tools.
64
[email protected]b9d08ce2012-05-01 18:32:4365goto :EOF
66
67:GIT_SVN_UPDATE
[email protected]aa574c62013-03-20 22:13:2368cd /d "%DEPOT_TOOLS_DIR%."
[email protected]e6c00f32012-04-13 15:39:4969call git svn rebase -q -q
70goto :EOF