[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>
This commit is contained in:
Eric Boren 2021-02-24 11:32:17 -05:00 committed by Skia Commit-Bot
parent 72917e4529
commit 03521cbe13

View File

@ -5,6 +5,7 @@
"""This module contains functions for using git."""
import os
import re
import shutil
import subprocess
@ -122,9 +123,14 @@ class NewGitCheckout(utils.tmp_dir):
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."""
@ -139,7 +145,12 @@ class NewGitCheckout(utils.tmp_dir):
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])