|
10 | 10 |
|
11 | 11 |
|
12 | 12 | def run_git(args, cwd): |
13 | | - if not args: |
14 | | - raise Exception('Please provide a git command to run.') |
15 | | - return subprocess.call(['git'] + args, cwd=cwd) == 0 |
| 13 | + if not args: |
| 14 | + raise Exception('Please provide a git command to run.') |
| 15 | + return subprocess.call(['git'] + args, cwd=cwd) == 0 |
16 | 16 |
|
17 | 17 |
|
18 | 18 | def checkout_shallow_git(path, url, revision): |
19 | | - """Checks out a shallow reference, then sets the expected branch to be |
| 19 | + """Checks out a shallow reference, then sets the expected branch to be |
20 | 20 | checked out.""" |
21 | 21 |
|
22 | | - os.makedirs(path, exist_ok=True) |
23 | | - run_git(['init', '--quiet'], path) |
24 | | - run_git(['config', 'advice.detachedHead', 'false'], path) |
25 | | - run_git(['remote', 'add', 'origin', url], path) |
26 | | - run_git(['fetch', '--depth', '1', 'origin', revision], path) |
27 | | - run_git(['checkout', 'FETCH_HEAD'], path) |
| 22 | + os.makedirs(path, exist_ok=True) |
| 23 | + run_git(['init', '--quiet'], path) |
| 24 | + run_git(['config', 'advice.detachedHead', 'false'], path) |
| 25 | + run_git(['remote', 'add', 'origin', url], path) |
| 26 | + run_git(['fetch', '--depth', '1', 'origin', revision], path) |
| 27 | + run_git(['checkout', 'FETCH_HEAD'], path) |
28 | 28 |
|
29 | 29 |
|
30 | 30 | def checkout_deps(deps): |
31 | | - """Checks out the shallow refs specified in the DEPS file.""" |
32 | | - with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor: |
33 | | - futures = [] |
34 | | - for deps_name, deps_data in deps.items(): |
35 | | - if deps_data.get('dep_type') == 'git': |
36 | | - url = deps_data['url'].split('@')[0] |
37 | | - revision = deps_data['url'].split('@')[1] |
38 | | - futures.append(executor.submit( |
39 | | - checkout_shallow_git, deps_name, url, revision)) |
40 | | - for future in concurrent.futures.as_completed(futures): |
41 | | - future.result() |
| 31 | + """Checks out the shallow refs specified in the DEPS file.""" |
| 32 | + with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor: |
| 33 | + futures = [] |
| 34 | + for deps_name, deps_data in deps.items(): |
| 35 | + if deps_data.get('dep_type') == 'git': |
| 36 | + url = deps_data['url'].split('@')[0] |
| 37 | + revision = deps_data['url'].split('@')[1] |
| 38 | + futures.append( |
| 39 | + executor.submit(checkout_shallow_git, deps_name, url, revision) |
| 40 | + ) |
| 41 | + for future in concurrent.futures.as_completed(futures): |
| 42 | + future.result() |
42 | 43 |
|
43 | 44 |
|
44 | 45 | def main(argv): |
45 | | - if (len(argv) < 1): |
46 | | - raise Exception('Please provide a DEPS file to update.') |
47 | | - deps_file = argv[0] |
48 | | - if not os.path.exists(deps_file): |
49 | | - raise Exception('The DEPS file does not exist.') |
| 46 | + if (len(argv) < 1): |
| 47 | + raise Exception('Please provide a DEPS file to update.') |
| 48 | + deps_file = argv[0] |
| 49 | + if not os.path.exists(deps_file): |
| 50 | + raise Exception('The DEPS file does not exist.') |
50 | 51 |
|
51 | | - host_os = 'linux' |
52 | | - if platform.system() == 'Windows': |
53 | | - host_os = 'win' |
54 | | - if platform.system() == 'Darwin': |
55 | | - host_os = 'mac' |
| 52 | + host_os = 'linux' |
| 53 | + if platform.system() == 'Windows': |
| 54 | + host_os = 'win' |
| 55 | + if platform.system() == 'Darwin': |
| 56 | + host_os = 'mac' |
56 | 57 |
|
57 | | - deps_contents = gclient_utils.FileRead(deps_file) |
58 | | - local_scope = gclient_eval.Parse( |
59 | | - deps_contents, deps_file, builtin_vars={'host_os': host_os}) |
| 58 | + deps_contents = gclient_utils.FileRead(deps_file) |
| 59 | + local_scope = gclient_eval.Parse( |
| 60 | + deps_contents, deps_file, builtin_vars={'host_os': host_os} |
| 61 | + ) |
60 | 62 |
|
61 | | - checkout_deps(local_scope['deps']) |
| 63 | + checkout_deps(local_scope['deps']) |
62 | 64 |
|
63 | 65 |
|
64 | 66 | if '__main__' == __name__: |
65 | | - sys.exit(main(sys.argv[1:])) |
| 67 | + sys.exit(main(sys.argv[1:])) |
0 commit comments