Skip to content

Commit

Permalink
Ensure repos are not empty before processing in crawl_repositories me…
Browse files Browse the repository at this point in the history
…thods
  • Loading branch information
andrew committed Dec 19, 2024
1 parent 62ab62f commit 55a4fd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/hosts/gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def fetch_repository(full_name)
def crawl_repositories_async
last_id = REDIS.get("gitlab_last_id:#{@host.id}")
repos = api_client.projects(per_page: 100, archived: false, id_before: last_id, simple: true)
if repos.present?
if repos.present? && repos.any?
repos.each { |repo| @host.sync_repository_async(repo["path_with_namespace"]) }
REDIS.set("gitlab_last_id:#{@host.id}", repos.last["id"])
end
Expand All @@ -292,7 +292,7 @@ def crawl_repositories_async
def crawl_repositories
last_id = REDIS.get("gitlab_last_id:#{@host.id}")
repos = api_client.projects(per_page: 100, archived: false, id_before: last_id, simple: true)
if repos.present?
if repos.present? && repos.any?
repos.reject! { |repo| repo.dig("namespace", "kind") == "user" } if ENV["SKIP_USER_REPOS"]
repos.each { |repo| @host.sync_repository(repo["path_with_namespace"], uuid: repo["id"]) }
REDIS.set("gitlab_last_id:#{@host.id}", repos.last["id"])
Expand Down

0 comments on commit 55a4fd0

Please sign in to comment.