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

Unified Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git.py

Issue 2663623003: Simplify the initialization of Git objects in Host. (Closed)
Patch Set: Remove second paragraph in comment about awesome windows git hack Created 3 years, 11 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
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git_mock.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6933ca45dcd3ef65bc7c22201fba06b6f41a1a5a 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,40 @@ 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.
+ _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,
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/git_mock.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698