[email protected] | 805133d | 2014-02-21 20:38:01 | [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 | |||||
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] | 851c829 | 2015-08-12 14:24:38 | [diff] [blame] | 13 | IF "%~nx0"=="update_depot_tools.bat" ( |
14 | COPY /Y "%~dp0update_depot_tools.bat" "%TEMP%\update_depot_tools_tmp.bat" >nul | ||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 15 | if errorlevel 1 goto :EOF |
[email protected] | 851c829 | 2015-08-12 14:24:38 | [diff] [blame] | 16 | "%TEMP%\update_depot_tools_tmp.bat" "%~dp0" %* |
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 17 | ) |
18 | |||||
[email protected] | 851c829 | 2015-08-12 14:24:38 | [diff] [blame] | 19 | set DEPOT_TOOLS_DIR=%~1 |
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 20 | SHIFT |
21 | |||||
22 | set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git | ||||
23 | |||||
[email protected] | 83f4767 | 2014-03-19 19:22:08 | [diff] [blame] | 24 | :: Will download git, svn and python. |
25 | call "%DEPOT_TOOLS_DIR%bootstrap\win\win_tools.bat" | ||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 26 | if errorlevel 1 goto :EOF |
27 | :: Now clear errorlevel so it can be set by other programs later. | ||||
28 | set errorlevel= | ||||
29 | |||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 30 | :: Shall skip automatic update? |
31 | IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF | ||||
32 | |||||
33 | :: We need either .\.svn\. or .\.git\. to be able to sync. | ||||
34 | IF EXIST "%DEPOT_TOOLS_DIR%.svn\." GOTO :SVN_UPDATE | ||||
35 | IF EXIST "%DEPOT_TOOLS_DIR%.git\." GOTO :GIT_UPDATE | ||||
36 | echo Error updating depot_tools, no revision tool found. | ||||
37 | goto :EOF | ||||
38 | |||||
39 | |||||
40 | :SVN_UPDATE | ||||
[email protected] | 69b6758 | 2014-11-25 23:34:41 | [diff] [blame] | 41 | FOR %%A IN (%*) DO ( |
42 | IF "%%A" == "--force" ( | ||||
43 | call svn -q revert -R "%DEPOT_TOOLS_DIR%." | ||||
44 | ) | ||||
45 | ) | ||||
46 | call svn -q up "%DEPOT_TOOLS_DIR%." | ||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 47 | goto :EOF |
48 | |||||
49 | |||||
50 | :GIT_UPDATE | ||||
51 | cd /d "%DEPOT_TOOLS_DIR%." | ||||
52 | call git config remote.origin.fetch > NUL | ||||
53 | if errorlevel 1 goto :GIT_SVN_UPDATE | ||||
54 | for /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 | ) | ||||
63 | call git fetch -q origin > NUL | ||||
64 | call git rebase -q origin/master > NUL | ||||
65 | if errorlevel 1 echo Failed to update depot_tools. | ||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 66 | goto :EOF |
67 | |||||
[email protected] | 69b6758 | 2014-11-25 23:34:41 | [diff] [blame] | 68 | |
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 69 | :GIT_SVN_UPDATE |
70 | cd /d "%DEPOT_TOOLS_DIR%." | ||||
71 | call git svn rebase -q -q | ||||
[email protected] | 5d17b92 | 2014-02-22 01:47:53 | [diff] [blame] | 72 | goto :EOF |