blob: 761c5b34891c3a5316d3eeda73c642fbba1aa399 [file] [log] [blame]
[email protected]805133d2014-02-21 20:38:011@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
10:: 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.
[email protected]851c8292015-08-12 14:24:3813IF "%~nx0"=="update_depot_tools.bat" (
14 COPY /Y "%~dp0update_depot_tools.bat" "%TEMP%\update_depot_tools_tmp.bat" >nul
[email protected]805133d2014-02-21 20:38:0115 if errorlevel 1 goto :EOF
[email protected]851c8292015-08-12 14:24:3816 "%TEMP%\update_depot_tools_tmp.bat" "%~dp0" %*
[email protected]805133d2014-02-21 20:38:0117)
18
[email protected]851c8292015-08-12 14:24:3819set DEPOT_TOOLS_DIR=%~1
[email protected]805133d2014-02-21 20:38:0120SHIFT
21
22set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git
23
[email protected]83f47672014-03-19 19:22:0824:: Will download git, svn and python.
25call "%DEPOT_TOOLS_DIR%bootstrap\win\win_tools.bat"
[email protected]805133d2014-02-21 20:38:0126if errorlevel 1 goto :EOF
27:: Now clear errorlevel so it can be set by other programs later.
28set errorlevel=
29
[email protected]805133d2014-02-21 20:38:0130:: Shall skip automatic update?
31IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF
32
33:: We need either .\.svn\. or .\.git\. to be able to sync.
34IF EXIST "%DEPOT_TOOLS_DIR%.svn\." GOTO :SVN_UPDATE
35IF EXIST "%DEPOT_TOOLS_DIR%.git\." GOTO :GIT_UPDATE
36echo Error updating depot_tools, no revision tool found.
37goto :EOF
38
39
40:SVN_UPDATE
[email protected]69b67582014-11-25 23:34:4141FOR %%A IN (%*) DO (
42 IF "%%A" == "--force" (
43 call svn -q revert -R "%DEPOT_TOOLS_DIR%."
44 )
45)
46call svn -q up "%DEPOT_TOOLS_DIR%."
[email protected]805133d2014-02-21 20:38:0147goto :EOF
48
49
50:GIT_UPDATE
51cd /d "%DEPOT_TOOLS_DIR%."
52call git config remote.origin.fetch > NUL
53if errorlevel 1 goto :GIT_SVN_UPDATE
54for /F %%x in ('git config --get remote.origin.url') DO (
55 IF not "%%x" == "%GIT_URL%" (
56 echo Your depot_tools checkout is configured to fetch from an obsolete URL
57 choice /N /T 60 /D N /M "Would you like to update it? [y/N]: "
58 IF not errorlevel 2 (
59 call git config remote.origin.url "%GIT_URL%"
60 )
61 )
62)
63call git fetch -q origin > NUL
64call git rebase -q origin/master > NUL
65if errorlevel 1 echo Failed to update depot_tools.
[email protected]805133d2014-02-21 20:38:0166goto :EOF
67
[email protected]69b67582014-11-25 23:34:4168
[email protected]805133d2014-02-21 20:38:0169:GIT_SVN_UPDATE
70cd /d "%DEPOT_TOOLS_DIR%."
71call git svn rebase -q -q
[email protected]5d17b922014-02-22 01:47:5372goto :EOF