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

Unified Diff: gclient_utils.py

Issue 9214004: Add UpgradeToHttps() to reliably and forcibly upgrade all urls to https (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix for nul url Created 8 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 | git_cl.py » ('j') | git_cl.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index 1edce769a71e8dc3ad88384ee7a2c4fc22a230f8..a3782c74d7a822cd112665c9aee0aa443be82625 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -734,6 +734,25 @@ def RunEditor(content, git):
os.remove(filename)
+def UpgradeToHttps(url):
+ """Upgrades random urls to https://.
+
+ Do not touch unknown urls like ssh:// or git://.
+ Fixes invalid GAE url.
+ """
+ if not url:
+ return url
+ if not re.match(r'[a-z\-]+\://.*', url):
+ # Make sure it is a valid uri.
+ url = 'https://%s' % url
+ url = re.sub(r'^http\:', r'https:', url)
+ url = re.sub(
+ '^https\:\/\/codereview.chromium.org',
+ 'https://chromiumcodereview.appspot.com',
+ url)
+ return url
+
+
def ParseCodereviewSettingsContent(content):
"""Process a codereview.settings file properly."""
lines = (l for l in content.splitlines() if not l.strip().startswith("#"))
@@ -742,5 +761,9 @@ def ParseCodereviewSettingsContent(content):
except ValueError:
raise Error(
'Failed to process settings, please fix. Content:\n\n%s' % content)
- # TODO(maruel): Post-process
+ def fix_url(key):
+ if keyvals.get(key):
+ keyvals[key] = UpgradeToHttps(keyvals[key])
+ fix_url('CODE_REVIEW_SERVER')
+ fix_url('VIEW_VC')
return keyvals
« no previous file with comments | « no previous file | git_cl.py » ('j') | git_cl.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698