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

Unified Diff: scripts/slave/update_scripts.py

Issue 2256183003: Ensure gclient solutions are always managed. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/update_scripts.py
diff --git a/scripts/slave/update_scripts.py b/scripts/slave/update_scripts.py
index b37de1476052da9cad06c561d449d3f530ef63ef..a88f18602ab9982183a5762992c99ba0fddfe2f8 100644
--- a/scripts/slave/update_scripts.py
+++ b/scripts/slave/update_scripts.py
@@ -5,6 +5,7 @@
import json
import logging
import os
+import re
import subprocess
import sys
import tempfile
@@ -33,6 +34,25 @@ def _run_command(cmd, **kwargs):
return proc.returncode, stdout
+def ensure_managed(dot_gclient_filename):
+ """Rewrites a .gclient file to set "managed": True.
+
+ Returns:
+ True if the .gclient file was modified.
+ """
+
+ with open(dot_gclient_filename) as fh:
+ contents = fh.read()
+
+ new_contents = re.sub(r'("managed"\s*:\s*)False', r'\1True', contents)
+
+ if contents != new_contents:
+ with open(dot_gclient_filename, 'w') as fh:
+ fh.write(new_contents)
+ return True
+ return False
+
+
def update_scripts():
if os.environ.get('RUN_SLAVE_UPDATED_SCRIPTS'):
os.environ.pop('RUN_SLAVE_UPDATED_SCRIPTS')
@@ -41,6 +61,10 @@ def update_scripts():
stream = annotator.StructuredAnnotationStream()
with stream.step('update_scripts') as s:
+ if ensure_managed(os.path.join(env.Build, os.pardir, '.gclient')):
+ s.step_text('Top-level gclient solution was unmanaged, '
+ 'changed to managed')
+
gclient_name = 'gclient'
if sys.platform.startswith('win'):
gclient_name += '.bat'
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698