Allow result sha to be overriden with local sha (#77832)

pull/77851/head
Matt Martz 3 years ago committed by GitHub
parent 66e92a3aff
commit a415697d70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -86,6 +86,10 @@ def parse_args():
action='store_true',
help='increase verbosity')
parser.add_argument('--result-sha',
default=None,
help='Override the result sha')
targets = parser.add_mutually_exclusive_group()
targets.add_argument('--targets',
@ -131,11 +135,13 @@ def incidental_report(args):
git = Git(os.path.abspath(args.source))
coverage_data = CoverageData(os.path.abspath(args.result))
result_sha = args.result_sha or coverage_data.result_sha
try:
git.show([coverage_data.result_sha, '--'])
git.show([result_sha, '--'])
except subprocess.CalledProcessError:
raise ApplicationError('%s: commit not found: %s\n'
'make sure your source repository is up-to-date' % (git.path, coverage_data.result_sha))
'make sure your source repository is up-to-date' % (git.path, result_sha))
if coverage_data.result != "succeeded":
check_failed(args, 'results indicate tests did not pass (result: %s)\n'
@ -225,7 +231,7 @@ def incidental_report(args):
cached(source_expanded_target_path, args.use_cache, args.verbose,
lambda: ct.expand(source_target_path, source_expanded_target_path))
summary[target_name] = sources = collect_sources(source_expanded_target_path, git, coverage_data)
summary[target_name] = sources = collect_sources(source_expanded_target_path, git, coverage_data, result_sha)
txt_report_path = os.path.join(reports_path, '%s.txt' % cache_name)
cached(txt_report_path, args.use_cache, args.verbose,
@ -364,7 +370,7 @@ class SourceFile:
self.covered_lines = set(abs(p[0]) for p in self.covered_points) | set(abs(p[1]) for p in self.covered_points)
def collect_sources(data_path, git, coverage_data):
def collect_sources(data_path, git, coverage_data, result_sha):
with open(data_path) as data_file:
data = json.load(data_file)
@ -372,7 +378,7 @@ def collect_sources(data_path, git, coverage_data):
for path_coverage in data.values():
for path, path_data in path_coverage.items():
sources.append(SourceFile(path, git.show(['%s:%s' % (coverage_data.result_sha, path)]), coverage_data, path_data))
sources.append(SourceFile(path, git.show(['%s:%s' % (result_sha, path)]), coverage_data, path_data))
return sources

Loading…
Cancel
Save