[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 | ||||
Aaron Gable | a0e5cc4 | 2016-06-21 14:22:18 | [diff] [blame] | 12 | :: running any 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 | |||||
Dan Jacques | 74d7e13 | 2017-06-01 22:17:15 | [diff] [blame] | 22 | IF EXIST "%DEPOT_TOOLS_DIR%.disable_auto_update" GOTO :EOF |
23 | |||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 24 | set GIT_URL=https://chromium.googlesource.com/chromium/tools/depot_tools.git |
25 | |||||
Dan Jacques | 13f258b | 2017-07-07 00:13:27 | [diff] [blame] | 26 | :: Will download git and python. |
[email protected] | 83f4767 | 2014-03-19 19:22:08 | [diff] [blame] | 27 | call "%DEPOT_TOOLS_DIR%bootstrap\win\win_tools.bat" |
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 28 | if errorlevel 1 goto :EOF |
29 | :: Now clear errorlevel so it can be set by other programs later. | ||||
30 | set errorlevel= | ||||
31 | |||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 32 | :: Shall skip automatic update? |
33 | IF "%DEPOT_TOOLS_UPDATE%" == "0" GOTO :EOF | ||||
34 | |||||
Dan Jacques | 13f258b | 2017-07-07 00:13:27 | [diff] [blame] | 35 | :: We need .\.git\. to be able to sync. |
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 36 | IF EXIST "%DEPOT_TOOLS_DIR%.git\." GOTO :GIT_UPDATE |
37 | echo Error updating depot_tools, no revision tool found. | ||||
38 | goto :EOF | ||||
39 | |||||
40 | |||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 41 | :GIT_UPDATE |
42 | cd /d "%DEPOT_TOOLS_DIR%." | ||||
43 | call git config remote.origin.fetch > NUL | ||||
[email protected] | 805133d | 2014-02-21 20:38:01 | [diff] [blame] | 44 | for /F %%x in ('git config --get remote.origin.url') DO ( |
45 | IF not "%%x" == "%GIT_URL%" ( | ||||
46 | echo Your depot_tools checkout is configured to fetch from an obsolete URL | ||||
47 | choice /N /T 60 /D N /M "Would you like to update it? [y/N]: " | ||||
48 | IF not errorlevel 2 ( | ||||
49 | call git config remote.origin.url "%GIT_URL%" | ||||
50 | ) | ||||
51 | ) | ||||
52 | ) | ||||
53 | call git fetch -q origin > NUL | ||||
54 | call git rebase -q origin/master > NUL | ||||
Dan Jacques | 5aeeb72 | 2017-07-28 13:22:25 | [diff] [blame] | 55 | if errorlevel 1 ( |
56 | echo Failed to update depot_tools. | ||||
57 | goto :EOF | ||||
58 | ) | ||||
59 | |||||
60 | :: Sync CIPD and CIPD client tools. | ||||
61 | call "%~dp0\cipd_bin_setup.bat" |