Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: tools/grab_deps.py

Issue 191133005: git-sync-deps tool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: AnotherPatchSet Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« tools/DEPS.py ('K') | « tools/DEPS.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright 2014 Google Inc.
3 #
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7
8 import sys
9 import os
10 import subprocess
11 import git_utils
12 import subprocess
13 import misc_utils
14
15 from DEPS import deps
16
17
18 def rm_directory_if_exists(directory):
19 if os.path.isdir(directory) and not os.path.islink(directory):
20 shutil.rmtree(directory)
21 elif os.path.lexists(directory):
22 os.remove(directory)
23
24
25 def git_checkout_to_directory(repo, checkout, directory, verbose=False):
26 """TODO(halcanary): document this function.
27 """
28 git = git_utils.git_executable()
29 assert git
30 if not checkout:
31 checkout = 'origin/master'
32 try:
33 with misc_utils.ChangeDir(directory):
34 if verbose:
35 print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
36 subprocess.check_call([git, 'fetch'])
37 subprocess.check_call([git, 'checkout', '--quiet', checkout])
38 except:
39 rm_directory_if_exists(directory)
40 subprocess.check_call([git, 'clone', repo, directory])
41 with misc_utils.ChangeDir(directory):
42 if verbose:
43 print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
44 subprocess.check_call([git, 'checkout', '--quiet', checkout])
45
46
47 def main(argv):
48 dependencies = deps["ALL"].copy()
49 for arg in argv:
50 if arg not in deps:
51 print arg, '?'
52 exit(1)
53 for dep in deps[arg]:
54 dependencies[dep] = deps[arg][dep]
55 for directory in dependencies:
56 repo, checkout = dependencies[directory]
57 git_checkout_to_directory(repo, checkout, directory, verbose=True)
58
59
60 if __name__ == '__main__':
61 main(sys.argv[1:])
62
OLDNEW
« tools/DEPS.py ('K') | « tools/DEPS.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698