def GenerateBlameList(source_repo, lkgm_path, only_print_chumps=False): """Generate the blamelist since the specified manifest. Arguments: source_repo: Repository object for the source code. lkgm_path: Path to LKGM manifest. only_print_chumps: If True, only print changes that were chumped. """ handler = git.Manifest(lkgm_path) reviewed_on_re = re.compile(r'\s*Reviewed-on:\s*(\S+)') author_re = re.compile(r'\s*Author:.*<(\S+)@\S+>\s*') committer_re = re.compile(r'\s*Commit:.*<(\S+)@\S+>\s*') for project in handler.projects.keys(): rel_src_path = handler.projects[project].get('path') # If it's not part of our source tree, it doesn't affect our build. if not rel_src_path: continue # Additional case in case the repo has been removed from the manifest. src_path = source_repo.GetRelativePath(rel_src_path) if not os.path.exists(src_path): cros_build_lib.Info('Detected repo removed from manifest %s' % project) continue revision = handler.projects[project]['revision'] result = cros_build_lib.RunCommand(['git', 'log', '--pretty=full', '%s..HEAD' % revision], print_cmd=False, redirect_stdout=True, cwd=src_path) current_author = None current_committer = None for line in unicode(result.output, 'ascii', 'ignore').splitlines(): author_match = author_re.match(line) if author_match: current_author = author_match.group(1) committer_match = committer_re.match(line) if committer_match: current_committer = committer_match.group(1) review_match = reviewed_on_re.match(line) if review_match: review = review_match.group(1) _, _, change_number = review.rpartition('/') if current_committer != 'chrome-bot': cros_build_lib.PrintBuildbotLink( 'CHUMP %s:%s' % (current_author, change_number), review) elif not only_print_chumps: cros_build_lib.PrintBuildbotLink( '%s:%s' % (current_author, change_number), review)
def Report(self, out, archive_urls=None, current_version=None): """Generate a user friendly text display of the results data.""" results = self._results_log line = '*' * 60 + '\n' edge = '*' * 2 if current_version: out.write(line) out.write(edge + ' RELEASE VERSION: ' + current_version + '\n') out.write(line) out.write(edge + ' Stage Results\n') for name, result, _, run_time in results: timestr = datetime.timedelta(seconds=math.ceil(run_time)) # Don't print data on skipped stages. if result == self.SKIPPED: continue out.write(line) details = '' if result == self.SUCCESS: status = 'PASS' elif result == self.FORGIVEN: status = 'FAILED BUT FORGIVEN' else: status = 'FAIL' if isinstance(result, cros_build_lib.RunCommandError): # If there was a RunCommand error, give just the command that # failed, not its full argument list, since those are usually # too long. details = ' in %s' % result.result.cmd[0] elif isinstance(result, BuildScriptFailure): # BuildScriptFailure errors publish a 'short' name of the # command that failed. details = ' in %s' % result.shortname else: # There was a normal error. Give the type of exception. details = ' with %s' % type(result).__name__ out.write('%s %s %s (%s)%s\n' % (edge, status, name, timestr, details)) out.write(line) if archive_urls: out.write('%s BUILD ARTIFACTS FOR THIS BUILD CAN BE FOUND AT:\n' % edge) for board, url in sorted(archive_urls.iteritems()): out.write('%s %s: %s' % (edge, board, url)) cros_build_lib.PrintBuildbotLink('Artifacts[%s]' % board, url, handle=out) out.write(line) for x in self.GetTracebacks(): if x.failed_stage and x.traceback: out.write('\nFailed in stage %s:\n\n' % x.failed_stage) out.write(x.traceback) out.write('\n')
def testGenerateBlameListSinceLKGM(self): """Tests that we can generate a blamelist from two commit messages. This test tests the functionality of generating a blamelist for a git log. Note in this test there are two commit messages, one commited by the Commit Queue and another from Non-Commit Queue. We test the correct handling in both cases. """ fake_git_log = """Author: Sammy Sosa <*****@*****.**> Commit: Chris Sosa <*****@*****.**> Date: Mon Aug 8 14:52:06 2011 -0700 Add in a test for cbuildbot TEST=So much testing BUG=chromium-os:99999 Change-Id: Ib72a742fd2cee3c4a5223b8easwasdgsdgfasdf Reviewed-on: http://gerrit.chromium.org/gerrit/1234 Reviewed-by: Fake person <*****@*****.**> Tested-by: Sammy Sosa <*****@*****.**> Author: Sammy Sosa <*****@*****.**> Commit: Gerrit <*****@*****.**> Date: Mon Aug 8 14:52:06 2011 -0700 Add in a test for cbuildbot TEST=So much testing BUG=chromium-os:99999 Change-Id: Ib72a742fd2cee3c4a5223b8easwasdgsdgfasdf Reviewed-on: http://gerrit.chromium.org/gerrit/1235 Reviewed-by: Fake person <*****@*****.**> Tested-by: Sammy Sosa <*****@*****.**> """ self.manager.incr_type = 'build' self.mox.StubOutWithMock(os.path, 'exists') self.mox.StubOutWithMock(cros_build_lib, 'RunCommand') self.mox.StubOutWithMock(cros_build_lib, 'PrintBuildbotLink') fake_revision = '1234567890' fake_project_handler = self.mox.CreateMock(git.Manifest) fake_project_handler.projects = { 'fake/repo': { 'name': 'fake/repo', 'path': 'fake/path', 'revision': fake_revision, } } fake_result = self.mox.CreateMock(cros_build_lib.CommandResult) fake_result.output = fake_git_log self.mox.StubOutWithMock(git, 'Manifest', use_mock_anything=True) git.Manifest(self.tmpmandir + '/LKGM/lkgm.xml').AndReturn(fake_project_handler) os.path.exists(mox.StrContains('fake/path')).AndReturn(True) cros_build_lib.RunCommand( ['git', 'log', '--pretty=full', '%s..HEAD' % fake_revision], print_cmd=False, redirect_stdout=True, cwd=self.tmpdir + '/fake/path').AndReturn(fake_result) cros_build_lib.PrintBuildbotLink( 'CHUMP | repo | fake | 1234', 'http://gerrit.chromium.org/gerrit/1234') cros_build_lib.PrintBuildbotLink( 'repo | fake | 1235', 'http://gerrit.chromium.org/gerrit/1235') self.mox.ReplayAll() self.manager._GenerateBlameListSinceLKGM() self.mox.VerifyAll()