diff --git a/lib/Sentra/Engine/SearchFiles.pm b/lib/Sentra/Engine/SearchFiles.pm index 0b2f3ad..0603bd0 100644 --- a/lib/Sentra/Engine/SearchFiles.pm +++ b/lib/Sentra/Engine/SearchFiles.pm @@ -15,27 +15,27 @@ package Sentra::Engine::SearchFiles { 'X-GitHub-Api-Version' => '2022-11-28' }; - my $output = ''; - + my $output = ''; my $repo_url = "https://api.github.com/orgs/$org/repos?per_page=$per_page"; - my $repo_tx = $userAgent -> get($repo_url => $headers); - - my $res = $repo_tx->result or return "Error fetching repositories: " . $repo_tx->error->{message} . "\n"; - $res->is_success or return "Error fetching repositories: " . $res->message . "\n"; + my $repo_tx = $userAgent -> get($repo_url => $headers); - my $repos = $res->json; + my $res = $repo_tx -> result(); + + if ($res -> is_success) { + my $repos = $res -> json(); - for my $repo (@$repos) { - next if $repo -> {archived}; - - my $full_name = "$org/$repo->{name}"; - - my $dependabot_url = "https://api.github.com/repos/$full_name/contents/.github/dependabot.yaml"; - my $dependabot_tx = $userAgent->get($dependabot_url => $headers); - - if ($dependabot_tx->result->code == 404) { - $output .= "The dependabot.yml file was not found in this repository: https://github.com/$full_name\n"; - } + for my $repo (@$repos) { + next if $repo -> {archived}; + + my $full_name = "$org/$repo->{name}"; + + my $dependabot_url = "https://api.github.com/repos/$full_name/contents/.github/dependabot.yaml"; + my $dependabot_tx = $userAgent -> get($dependabot_url => $headers); + + if ($dependabot_tx -> result -> code == 404) { + $output .= "The dependabot.yml file was not found in this repository: https://github.com/$full_name\n"; + } + } } return $output || "No issues found.";