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

Unified 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 side-by-side diff with in-line comments
Download patch
« tools/DEPS.py ('K') | « tools/DEPS.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grab_deps.py
diff --git a/tools/grab_deps.py b/tools/grab_deps.py
new file mode 100755
index 0000000000000000000000000000000000000000..3c9e19094f4036c8690da687353030a6121b9392
--- /dev/null
+++ b/tools/grab_deps.py
@@ -0,0 +1,62 @@
+#!/usr/bin/python
+# Copyright 2014 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+import sys
+import os
+import subprocess
+import git_utils
+import subprocess
+import misc_utils
+
+from DEPS import deps
+
+
+def rm_directory_if_exists(directory):
+ if os.path.isdir(directory) and not os.path.islink(directory):
+ shutil.rmtree(directory)
+ elif os.path.lexists(directory):
+ os.remove(directory)
+
+
+def git_checkout_to_directory(repo, checkout, directory, verbose=False):
+ """TODO(halcanary): document this function.
+ """
+ git = git_utils.git_executable()
+ assert git
+ if not checkout:
+ checkout = 'origin/master'
+ try:
+ with misc_utils.ChangeDir(directory):
+ if verbose:
+ print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
+ subprocess.check_call([git, 'fetch'])
+ subprocess.check_call([git, 'checkout', '--quiet', checkout])
+ except:
+ rm_directory_if_exists(directory)
+ subprocess.check_call([git, 'clone', repo, directory])
+ with misc_utils.ChangeDir(directory):
+ if verbose:
+ print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
+ subprocess.check_call([git, 'checkout', '--quiet', checkout])
+
+
+def main(argv):
+ dependencies = deps["ALL"].copy()
+ for arg in argv:
+ if arg not in deps:
+ print arg, '?'
+ exit(1)
+ for dep in deps[arg]:
+ dependencies[dep] = deps[arg][dep]
+ for directory in dependencies:
+ repo, checkout = dependencies[directory]
+ git_checkout_to_directory(repo, checkout, directory, verbose=True)
+
+
+if __name__ == '__main__':
+ main(sys.argv[1:])
+
« 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