Chromium Code Reviews| Index: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git.py |
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git.py |
| index 442173fb86d31016846e588b3f92eaaf9ec7738b..0e45687f52537374ae961b21983ed25adccf4b2b 100644 |
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git.py |
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git.py |
| @@ -48,12 +48,45 @@ class Git(object): |
| executable_name = 'git' |
| - def __init__(self, cwd, executive=None, filesystem=None): |
| - self.cwd = cwd |
| + def __init__(self, cwd=None, executive=None, filesystem=None): |
| self._executive = executive or Executive() |
| self._filesystem = filesystem or FileSystem() |
| + |
| + self.cwd = cwd or self._filesystem.abspath(self._filesystem.getcwd()) |
| + if not Git.in_working_directory(self.cwd, executive=self._executive): |
| + module_directory = self._filesystem.abspath( |
| + self._filesystem.dirname(self._filesystem.path_to_module(self.__module__))) |
| + _log.info('The current directory (%s) is not in a git repo, trying directory %s.', |
| + cwd, module_directory) |
| + if Git.in_working_directory(module_directory, executive=self._executive): |
| + self.cwd = module_directory |
| + _log.error('Failed to find Git repo for %s or %s', cwd, module_directory) |
| + |
| + self._init_executable_name() |
| self.checkout_root = self.find_checkout_root(self.cwd) |
| + def _init_executable_name(self): |
| + # FIXME: This is a hack and should be removed. |
| + try: |
| + self._executive.run_command(['git', 'help']) |
| + except OSError: |
| + try: |
| + self._executive.run_command(['git.bat', 'help']) |
| + # The Win port uses the depot_tools package, which contains a number |
| + # of development tools, including Python and git. Instead of using a |
| + # real git executable, depot_tools indirects via a batch file, called |
| + # "git.bat". This batch file allows depot_tools to auto-update the real |
| + # git executable, which is contained in a subdirectory. |
| + # |
| + # That's all fine and good, except that subprocess.popen can detect |
| + # the difference between a real git executable and batch file when we |
| + # don't use shell=True. Rather than use shell=True on Windows, |
| + # we set the executable name on a class variable. |
|
jeffcarp
2017/02/01 17:27:03
Nit: I think this should be 'instance variable' no
qyearsley
2017/02/01 17:46:13
You're right, it's set here as an instance variabl
jeffcarp
2017/02/01 18:27:55
👍
|
| + _log.debug('Engaging git.bat Windows hack.') |
| + self.executable_name = 'git.bat' |
| + except OSError: |
| + _log.debug('Failed to engage git.bat Windows hack.') |
| + |
| def _run_git(self, |
| command_args, |
| cwd=None, |