aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/git-sync-deps
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2014-06-25 13:28:29 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-25 13:28:30 -0700
commit20fb7c6220b200eeda86d7d190739a4c5fabe571 (patch)
tree1595069b957767b3f60cd9f84712548a6b8c3f62 /tools/git-sync-deps
parentb726df472bb996aaab9ea0e62568208599385a1c (diff)
tools/git-sync-deps is a stand-alone program, not dependent on synced deps.
Motivation: With common repo, we had a chicken-egg problem. BUG=skia: R=borenet@google.com, mtklein@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/351063003
Diffstat (limited to 'tools/git-sync-deps')
-rwxr-xr-xtools/git-sync-deps29
1 files changed, 26 insertions, 3 deletions
diff --git a/tools/git-sync-deps b/tools/git-sync-deps
index ac4576ddc7..22309bd792 100755
--- a/tools/git-sync-deps
+++ b/tools/git-sync-deps
@@ -11,6 +11,9 @@ Args:
An optional list of deps_os values.
Environment Variables:
+ GIT_EXECUTABLE: path to "git" binary; if unset, will look for one of
+ ['git', 'git.exe', 'git.bat'] in your default path.
+
GIT_SYNC_DEPS_PATH: file to get the dependency list from; if unset,
will use the file ../DEPS relative to this script's directory.
@@ -32,8 +35,25 @@ import subprocess
import sys
import threading
-import fix_pythonpath
-from common.py.utils.git_utils import GIT
+
+def git_executable():
+ """Find the git executable.
+
+ Returns:
+ A string suitable for passing to subprocess functions, or None.
+ """
+ envgit = os.environ.get('GIT_EXECUTABLE')
+ searchlist = ['git', 'git.exe', 'git.bat']
+ if envgit:
+ searchlist.insert(0, envgit)
+ with open(os.devnull, 'w') as devnull:
+ for git in searchlist:
+ try:
+ subprocess.call([git, '--version'], stdout=devnull)
+ except (OSError,):
+ continue
+ return git
+ return None
DEFAULT_DEPS_PATH = os.path.normpath(
@@ -146,6 +166,9 @@ def git_sync_deps(deps_file_path, deps_os_list, verbose):
Raises DepsError exception and git Exceptions.
"""
+ git = git_executable()
+ assert git
+
deps_file_directory = os.path.dirname(deps_file_path)
deps = parse_file_to_dict(deps_file_path)
dependencies = deps['deps'].copy()
@@ -167,7 +190,7 @@ def git_sync_deps(deps_file_path, deps_os_list, verbose):
relative_directory = os.path.join(deps_file_directory, directory)
list_of_arg_lists.append(
- (GIT, repo, checkoutable, relative_directory, verbose))
+ (git, repo, checkoutable, relative_directory, verbose))
multithread(git_checkout_to_directory, list_of_arg_lists)