[email protected] | e6c00f3 | 2012-04-13 15:39:49 | [diff] [blame] | 1 | @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 | |||||
8 | setlocal | ||||
9 | |||||
[email protected] | aa574c6 | 2013-03-20 22:13:23 | [diff] [blame] | 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. | ||||
13 | IF %~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 | |||||
19 | set DEPOT_TOOLS_DIR=%1 | ||||
20 | SHIFT | ||||
21 | |||||
[email protected] | 9f36c38 | 2013-01-07 23:53:36 | [diff] [blame] | 22 | set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git |
23 | |||||
[email protected] | e6c00f3 | 2012-04-13 15:39:49 | [diff] [blame] | 24 | :: 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] | aa574c6 | 2013-03-20 22:13:23 | [diff] [blame] | 28 | call "%DEPOT_TOOLS_DIR%bootstrap\win\win_tools.bat" force |
[email protected] | e6c00f3 | 2012-04-13 15:39:49 | [diff] [blame] | 29 | if errorlevel 1 goto :EOF |
[email protected] | b9d08ce | 2012-05-01 18:32:43 | [diff] [blame] | 30 | :: Now clear errorlevel so it can be set by other programs later. |
31 | set errorlevel= | ||||
[email protected] | e6c00f3 | 2012-04-13 15:39:49 | [diff] [blame] | 32 | |
33 | :: Shall skip automatic update? | ||||
34 | IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF | ||||
35 | |||||
36 | :: We need either .\.svn\. or .\.git\. to be able to sync. | ||||
[email protected] | aa574c6 | 2013-03-20 22:13:23 | [diff] [blame] | 37 | IF EXIST "%DEPOT_TOOLS_DIR%.svn\." GOTO :SVN_UPDATE |
38 | IF EXIST "%DEPOT_TOOLS_DIR%.git\." GOTO :GIT_UPDATE | ||||
[email protected] | e6c00f3 | 2012-04-13 15:39:49 | [diff] [blame] | 39 | echo Error updating depot_tools, no revision tool found. |
40 | goto :EOF | ||||
41 | |||||
42 | |||||
43 | :SVN_UPDATE | ||||
[email protected] | aa574c6 | 2013-03-20 22:13:23 | [diff] [blame] | 44 | call svn up -q "%DEPOT_TOOLS_DIR%." |
[email protected] | e6c00f3 | 2012-04-13 15:39:49 | [diff] [blame] | 45 | goto :EOF |
46 | |||||
47 | |||||
48 | :GIT_UPDATE | ||||
[email protected] | aa574c6 | 2013-03-20 22:13:23 | [diff] [blame] | 49 | cd /d "%DEPOT_TOOLS_DIR%." |
[email protected] | b9d08ce | 2012-05-01 18:32:43 | [diff] [blame] | 50 | call git config remote.origin.fetch > NUL |
51 | if errorlevel 1 goto :GIT_SVN_UPDATE | ||||
[email protected] | 9f36c38 | 2013-01-07 23:53:36 | [diff] [blame] | 52 | for /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] | b9d08ce | 2012-05-01 18:32:43 | [diff] [blame] | 61 | call git fetch -q origin > NUL |
[email protected] | 495e57b | 2012-09-11 18:07:02 | [diff] [blame] | 62 | call git rebase -q origin/master > NUL |
[email protected] | 86c497d | 2013-09-30 17:32:52 | [diff] [blame] | 63 | if errorlevel 1 echo Failed to update depot_tools. |
64 | |||||
[email protected] | b9d08ce | 2012-05-01 18:32:43 | [diff] [blame] | 65 | goto :EOF |
66 | |||||
67 | :GIT_SVN_UPDATE | ||||
[email protected] | aa574c6 | 2013-03-20 22:13:23 | [diff] [blame] | 68 | cd /d "%DEPOT_TOOLS_DIR%." |
[email protected] | e6c00f3 | 2012-04-13 15:39:49 | [diff] [blame] | 69 | call git svn rebase -q -q |
70 | goto :EOF |