-
Notifications
You must be signed in to change notification settings - Fork 29
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
Filter file comparisons by flags #129
Conversation
@@ -701,7 +704,9 @@ def base_report(self): | |||
@cached_property | |||
def head_report(self): | |||
try: | |||
report = report_service.build_report_from_commit(self.head_commit) | |||
report = report_service.build_report_from_commit( | |||
self.head_commit, report_class=ReadOnlyReport |
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.
Could this be unsafe?
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.
I don't think the API does any report modification so this seems like a good move to me.
parameter = filters.get("ordering", {}).get("parameter") | ||
direction = filters.get("ordering", {}).get("direction") | ||
if parameter and direction: | ||
impacted_files = self.sort_impacted_files( | ||
impacted_files, parameter, direction | ||
) | ||
flags = filters.get("flags", []) | ||
if flags and comparison: | ||
head_commit_report = comparison.head_report |
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.
Brought the comparison all the way down here to only compute the head_report if the flags are provided
Codecov Report
@@ Coverage Diff @@
## main #129 +/- ##
=======================================
+ Coverage 95.34 95.35 +0.01
=======================================
Files 702 702
Lines 14946 14958 +12
=======================================
+ Hits 14250 14262 +12
Misses 696 696
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Codecov ReportPatch coverage is
📢 Thoughts on this report? Let us know!. |
compare/commands/compare/compare.py
Outdated
def fetch_impacted_files( | ||
self, | ||
comparison_report: ComparisonReport, | ||
comparison: Union[PullRequestComparison, Comparison], |
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.
Just Comparison
is fine here since PullRequestComparison
inherits from Comparison
and we're not using anything specific to PullRequestComparison
.
def _apply_filters( | ||
self, | ||
impacted_files: Optional[List[ImpactedFile]], | ||
comparison: Union[PullRequestComparison, Comparison], |
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.
Same here - can just be Comparison
files = files_belonging_to_flags( | ||
commit_report=head_commit_report, flags=flags | ||
) | ||
impacted_files = list( |
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.
This might read a little easier:
impacted_files = [
file
for file in impacted_files
if file.head_name in files
]
@@ -701,7 +704,9 @@ def base_report(self): | |||
@cached_property | |||
def head_report(self): | |||
try: | |||
report = report_service.build_report_from_commit(self.head_commit) | |||
report = report_service.build_report_from_commit( | |||
self.head_commit, report_class=ReadOnlyReport |
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.
I don't think the API does any report modification so this seems like a good move to me.
* main: (74 commits) Fix indentation error (#133) Add cache cleanup (#130) Feature/lint pre commit (#134) feat: trigger label analysis task after update (#131) Filter file comparisons by flags (#129) chore: Remove hard-coded dev BB redirect URL (#132) feat: Validate OIDC ID token during Sentry OAuth flow (#52) Adding beginnings of GHA CI (#127) feat: Filter flags by flags for pathContents (#128) Create checkbox in Owner form in Django admin to set uses_invoice (#109) build(deps): bump certifi from 2020.6.20 to 2023.7.22 (#32) Feature/no compile (#126) Bump django from 4.2.2 to 4.2.3 (#42) Don't compile since source is available (#106) feat: Add firstPull resolver to GraphQL pull type (#108) chore: Upgrade requests and redis dependencies (#124) Update LICENSE (#122) Attempt migration (#121) 359 adjust monthly uploads for trialled customers (#119) Add changes for monthly uploads to account for trialing customer (#101) ...
Purpose/Motivation
We need to filter out file comparisons by flags. This PR introduces that logic
What does this PR do?
Comparison
classLegal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.