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

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: 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..9809b0223e16d635d376d2bfcaccd2cf221964b8
--- /dev/null
+++ b/scripts/slave/recipe_modules/findit/api.py
@@ -0,0 +1,39 @@
+# 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 get_files_affected_by_revision(self, revision, repo_dir=''):
+ """Returns the files changed by the given revision.
+
+ Args:
+ revision (str): the git hash of a commit.
+ repo_dir (str): the relative path to the checkout directory.
+ """
+ if repo_dir:
+ cwd = self.m.path['checkout']
+ else:
+ cwd = self.m.path['checkout'].join(repo_dir)
iannucci 2015/11/18 03:57:53 is this if/else backwards? Does it make sense to
stgao 2015/11/19 22:06:33 Changed input parameter to "solution_name" and der
+
+ previous_revision = '%s~1' % revision
+ step_result = self.m.git('diff', previous_revision, revision, '--name-only',
iannucci 2015/11/18 03:57:54 I think revision+"~1" is possibly clearer and
stgao 2015/11/19 22:06:33 Done.
+ 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