Skip to content

Commit

Permalink
Refactor _process_updates_git() to eliminate lint finding
Browse files Browse the repository at this point in the history
docker/importer/importer.py:213:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
  • Loading branch information
andrewpollock committed Aug 16, 2022
1 parent 72e806f commit 8f7caf5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions docker/importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ def _process_updates_git(self, source_repo):
changed_entries = set()
deleted_entries = set()

if source_repo.last_synced_hash:
# Syncing from a previous commit.
def _sync_from_previous_commit(repo):
entries_changed = set()
entries_deleted = set()

walker = repo.walk(repo.head.target, pygit2.GIT_SORT_TOPOLOGICAL)
walker.hide(source_repo.last_synced_hash)

Expand All @@ -233,14 +235,21 @@ def _process_updates_git(self, source_repo):
if delta.old_file and _is_vulnerability_file(
source_repo, delta.old_file.path):
if delta.status == pygit2.GIT_DELTA_DELETED:
deleted_entries.add(delta.old_file.path)
entries_deleted.add(delta.old_file.path)
continue

changed_entries.add(delta.old_file.path)
entries_changed.add(delta.old_file.path)

if delta.new_file and _is_vulnerability_file(
source_repo, delta.new_file.path):
changed_entries.add(delta.new_file.path)
entries_changed.add(delta.new_file.path)

return entries_changed, entries_deleted

if source_repo.last_synced_hash:
# Syncing from a previous commit.
changed_entries, deleted_entries = _sync_from_previous_commit(repo)

else:
# First sync from scratch.
logging.info('Syncing repo from scratch')
Expand Down

0 comments on commit 8f7caf5

Please sign in to comment.