From 03521cbe13f6b131add9217e1f260372c759a75e Mon Sep 17 00:00:00 2001 From: Eric Boren Date: Wed, 24 Feb 2021 11:32:17 -0500 Subject: [PATCH] [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 Commit-Queue: Eric Boren --- infra/bots/git_utils.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/infra/bots/git_utils.py b/infra/bots/git_utils.py index 4269ae8984..893c9cdab2 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,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])