Skip to content

Commit

Permalink
Return valid snapshot to use it later
Browse files Browse the repository at this point in the history
  • Loading branch information
JokeWaumans committed Sep 9, 2024
1 parent b8793b8 commit f9b6491
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion mlx/coverity/coverity.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ def initialize_environment(self, app):
report_info("done")
if self.snapshot:
report_info("Verify the given snapshot ID and obtain all enabled checkers... ")
self.coverity_service.validate_snapshot(self.snapshot)
self.snapshot = self.coverity_service.validate_snapshot(self.snapshot)
report_info("done")
else:
self.snapshot = "last()"
# Get all column keys
report_info("obtaining all column keys... ")
self.coverity_service.retrieve_column_keys()
Expand Down
11 changes: 5 additions & 6 deletions mlx/coverity/coverity_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def __init__(self, hostname):
self._checkers = []
self._columns = {}
self.logger = getLogger("mlx.coverity_logging")
self.valid_snapshot = False

@property
def base_url(self):
Expand Down Expand Up @@ -137,11 +136,13 @@ def validate_snapshot(self, snapshot):
url = f"{self.api_endpoint}/snapshots/{snapshot}"
response = self.session.get(url)
if response.ok:
self.valid_snapshot = True
report_info(f"Snapshot ID {snapshot} is valid")
valid_snapshot = snapshot
else:
report_warning(f"No snapshot found for ID {snapshot}; Continue with using the latest snapshot.", "")
self.valid_snapshot = False
valid_snapshot = "last()"

return valid_snapshot

def retrieve_issues(self, filters):
"""Retrieve issues from the server (Coverity Connect).
Expand Down Expand Up @@ -312,14 +313,12 @@ def get_defects(self, stream, filters, column_names, snapshot):
if (filter := filters["component"]) and (filter_values := self.handle_component_filter(filter)):
query_filters.append(self.assemble_query_filter("Component", filter_values, "nameMatcher"))

scope = snapshot if snapshot and self.valid_snapshot else "last()"

data = {
"filters": query_filters,
"columns": list(self.column_keys(column_names)),
"snapshotScope": {
"show": {
"scope": scope,
"scope": snapshot,
"includeOutdatedSnapshots": False
}
}
Expand Down

0 comments on commit f9b6491

Please sign in to comment.