Skip to content
Browse files
Allow result sha to be overriden with local sha (#77832)
  • Loading branch information
sivel committed May 18, 2022
1 parent 66e92a3 commit a415697d70794f0e6e09135e1e107390c2f46435
Showing 1 changed file with 11 additions and 5 deletions.
@@ -86,6 +86,10 @@ def parse_args():
help='increase verbosity')

help='Override the result sha')

targets = parser.add_mutually_exclusive_group()

@@ -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:[coverage_data.result_sha, '--'])[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,15 +370,15 @@ def __init__(self, path, source, coverage_data, coverage_points):
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)

sources = []

for path_coverage in data.values():
for path, path_data in path_coverage.items():
sources.append(SourceFile(path,['%s:%s' % (coverage_data.result_sha, path)]), coverage_data, path_data))
sources.append(SourceFile(path,['%s:%s' % (result_sha, path)]), coverage_data, path_data))

return sources

0 comments on commit a415697

Please sign in to comment.