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

Unified Diff: scripts/slave/recipe_modules/findit/api.py

Issue 1416763007: Add a recipe to identify culprits for chromium compile failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Rebase and Address comments. Created 5 years, 1 month 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
Index: scripts/slave/recipe_modules/findit/api.py
diff --git a/scripts/slave/recipe_modules/findit/api.py b/scripts/slave/recipe_modules/findit/api.py
new file mode 100644
index 0000000000000000000000000000000000000000..8055a32863fdd98212d7c7c925bc49c4d40ef811
--- /dev/null
+++ b/scripts/slave/recipe_modules/findit/api.py
@@ -0,0 +1,48 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from recipe_engine import recipe_api
+
+
+class FinditApi(recipe_api.RecipeApi):
+
+ def _calculate_repo_dir(self, solution_name):
+ """Returns the relative path of the solution checkout to the root one."""
+ if solution_name == 'src':
+ return ''
+ else:
+ root_solution_name = 'src/'
+ assert solution_name.startswith(root_solution_name)
+ return solution_name[len(root_solution_name):]
+
+ def get_files_affected_by_revision(self, revision, solution_name):
+ """Returns the files changed by the given revision.
Dirk Pranke 2015/11/24 00:17:41 I would probably call this routine "files_changed_
stgao 2015/11/24 23:19:19 Done.
+
+ Args:
+ revision (str): the git hash of a commit.
+ solution_name (str): the gclient solution name, eg:
+ "src" for chromium, "src/third_party/pdfium" for pdfium.
+ """
+ solution_name = solution_name.replace('\\', '/')
+ repo_dir = self._calculate_repo_dir(solution_name)
+ cwd = self.m.path['checkout'].join(repo_dir)
+
+ previous_revision = '%s~1' % revision
+ step_result = self.m.git('diff', revision + '~1', revision, '--name-only',
+ name='git diff to analyze commit',
+ stdout=self.m.raw_io.output(),
+ cwd=cwd,
+ step_test_data=lambda:
+ self.m.raw_io.test_api.stream_output('foo.cc'))
+
+ paths = step_result.stdout.split()
+ if repo_dir:
+ paths = [self.m.path.join(repo_dir, path) for path in paths]
+ if self.m.platform.is_win:
+ # Looks like "analyze" wants POSIX slashes even on Windows (since git
+ # uses that format even on Windows).
+ paths = [path.replace('\\', '/') for path in paths]
+
+ step_result.presentation.logs['files'] = paths
+ return paths

Powered by Google App Engine
This is Rietveld 408576698