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

Unified Diff: gclient_scm.py

Issue 497053002: Use a regex instead of shlex.split() to get remote url (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix Created 6 years, 4 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 | tests/gclient_scm_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index 0dabd265e4fbfb1b388156dff71cca2914444a3e..f58343175f9193cbb03747330fee9f389b3f4747 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -11,7 +11,6 @@ import logging
import os
import posixpath
import re
-import shlex
import sys
import tempfile
import traceback
@@ -159,13 +158,19 @@ class SCMWrapper(object):
return getattr(self, command)(options, args, file_list)
+ @staticmethod
+ def _get_first_remote_url(checkout_path):
+ log = scm.GIT.Capture(
+ ['config', '--local', '--get-regexp', r'remote.*.url'],
+ cwd=checkout_path)
+ # Get the second token of the first line of the log.
+ return log.splitlines()[0].split(' ', 1)[1]
+
def GetActualRemoteURL(self, options):
"""Attempt to determine the remote URL for this SCMWrapper."""
# Git
if os.path.exists(os.path.join(self.checkout_path, '.git')):
- actual_remote_url = shlex.split(scm.GIT.Capture(
- ['config', '--local', '--get-regexp', r'remote.*.url'],
- cwd=self.checkout_path))[1]
+ actual_remote_url = self._get_first_remote_url(self.checkout_path)
# If a cache_dir is used, obtain the actual remote URL from the cache.
if getattr(self, 'cache_dir', None):
@@ -173,9 +178,7 @@ class SCMWrapper(object):
mirror = git_cache.Mirror(url)
if (mirror.exists() and mirror.mirror_path.replace('\\', '/') ==
actual_remote_url.replace('\\', '/')):
- actual_remote_url = shlex.split(scm.GIT.Capture(
- ['config', '--local', '--get-regexp', r'remote.*.url'],
- cwd=mirror.mirror_path))[1]
+ actual_remote_url = self._get_first_remote_url(mirror.mirror_path)
return actual_remote_url
# Svn
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698