-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
show patch coverage only for changed files, and don't show indirect changed files #60
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,6 +116,53 @@ | |
return "".join(("|", coverage, complexity, icon)) | ||
|
||
|
||
def make_patch_only_metrics(before, after, relative, show_complexity, yaml): | ||
if after is None: | ||
# e.g. missing flags | ||
coverage = " `?` |" | ||
|
||
elif after is False: | ||
# e.g. file deleted | ||
coverage = " |" | ||
|
||
else: | ||
layout = " `{relative}` |" | ||
coverage = layout.format( | ||
relative=format_number_to_str( | ||
yaml, relative.coverage if relative else 0, style="{0}%", if_null="\xF8" | ||
), | ||
) | ||
return "".join(("|", coverage)) | ||
|
||
|
||
def get_metrics_method(hide_project_coverage): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [very nit] I think that technically both |
||
if hide_project_coverage: | ||
metrics = make_patch_only_metrics | ||
else: | ||
metrics = make_metrics | ||
return metrics | ||
|
||
|
||
def get_table_header(hide_project_coverage, show_complexity): | ||
if not hide_project_coverage: | ||
table_header = ( | ||
"| Coverage \u0394 |" | ||
+ (" Complexity \u0394 |" if show_complexity else "") | ||
+ " |" | ||
) | ||
else: | ||
table_header = "| Coverage |" | ||
|
||
return table_header | ||
|
||
|
||
def get_table_layout(hide_project_coverage, show_complexity): | ||
if hide_project_coverage: | ||
return "|---|---|" | ||
else: | ||
return "|---|---|---|" + ("---|" if show_complexity else "") | ||
|
||
|
||
def format_number_to_str( | ||
yml, value, if_zero=None, if_null=None, plus=False, style="{0}" | ||
) -> str: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ | |
diff_to_string, | ||
ellipsis, | ||
escape_markdown, | ||
get_metrics_method, | ||
get_table_header, | ||
get_table_layout, | ||
make_metrics, | ||
sort_by_importance, | ||
) | ||
|
@@ -464,11 +467,13 @@ async def do_write_section(self, comparison, diff, changes, links, behind_by=Non | |
head_report = comparison.head.report | ||
if base_report is None: | ||
base_report = Report() | ||
hide_project_coverage = self.settings.get("hide_project_coverage", False) | ||
metrics = get_metrics_method(hide_project_coverage) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] I think |
||
files_in_diff = [ | ||
( | ||
_diff["type"], | ||
path, | ||
make_metrics( | ||
metrics( | ||
get_totals_from_file_in_reports(base_report, path) or False, | ||
get_totals_from_file_in_reports(head_report, path) or False, | ||
_diff["totals"], | ||
|
@@ -487,12 +492,8 @@ async def do_write_section(self, comparison, diff, changes, links, behind_by=Non | |
c.path for c in changes or [] | ||
) | ||
if files_in_diff: | ||
table_header = ( | ||
"| Coverage \u0394 |" | ||
+ (" Complexity \u0394 |" if self.show_complexity else "") | ||
+ " |" | ||
) | ||
table_layout = "|---|---|---|" + ("---|" if self.show_complexity else "") | ||
table_header = get_table_header(hide_project_coverage, self.show_complexity) | ||
table_layout = get_table_layout(hide_project_coverage, self.show_complexity) | ||
# add table headers | ||
yield ( | ||
"| [Files Changed]({0}?src=pr&el=tree) {1}".format( | ||
|
@@ -539,7 +540,7 @@ def tree_cell(typ, path, metrics, _=None): | |
) | ||
) | ||
|
||
if changes: | ||
if changes and not hide_project_coverage: | ||
len_changes_not_in_diff = len(all_files or []) - len(files_in_diff or []) | ||
if files_in_diff and len_changes_not_in_diff > 0: | ||
yield ("") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for these helpful comments