[infra] Change git_utils.NewGitRepo to use the default "git clone" dir
Change-Id: I616d2a119886d04e2b21499aece3e042226f6f3f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375057
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
diff --git a/infra/bots/git_utils.py b/infra/bots/git_utils.py
index 4269ae8..893c9cd 100755
--- a/infra/bots/git_utils.py
+++ b/infra/bots/git_utils.py
@@ -5,6 +5,7 @@
"""This module contains functions for using git."""
+import os
import re
import shutil
import subprocess
@@ -122,10 +123,15 @@
new copy is updated from there.
"""
super(NewGitCheckout, self).__init__()
+ self._checkout_root = ''
self._repository = repository
self._local = local
@property
+ def name(self):
+ return self._checkout_root
+
+ @property
def root(self):
"""Returns the root directory containing the checked-out files."""
return self.name
@@ -139,7 +145,12 @@
remote = self._repository
if self._local:
remote = self._local
- subprocess.check_output(args=['git', 'clone', remote, self.root])
+ subprocess.check_output(args=['git', 'clone', remote])
+ repo_name = remote.split('/')[-1]
+ if repo_name.endswith('.git'):
+ repo_name = repo_name[:-len('.git')]
+ self._checkout_root = os.path.join(os.getcwd(), repo_name)
+ os.chdir(repo_name)
if self._local:
subprocess.check_call([
'git', 'remote', 'set-url', 'origin', self._repository])