Skip to content

Commit

Permalink
Send error to queue
Browse files Browse the repository at this point in the history
  • Loading branch information
guibranco committed Feb 18, 2024
1 parent 8463e9d commit 7d679c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions Src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ function loadConfig()
require_once "lib/request.php";
require_once "lib/appveyor.php";
require_once "lib/github.php";
require_once "lib/queue.php";

Check warning on line 47 in Src/config/config.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Src/config/config.php#L47

"require_once" statement detected. File manipulations are discouraged.
8 changes: 7 additions & 1 deletion Src/lib/github.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ function requestGitHub($gitHubToken, $url, $data = null)
$baseUrl = "https://api.github.com/";
$url = $baseUrl . $url;

return doRequest($url, $gitHubToken, $data);
$response = doRequest($url, $gitHubToken, $data);

if($response["status"] >= 300) {

Check notice on line 16 in Src/lib/github.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Src/lib/github.php#L16

Expected "if (...) {\n"; found "if(...) {\n"

Check notice on line 16 in Src/lib/github.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Src/lib/github.php#L16

Expected 1 space(s) after IF keyword; 0 found
sendQueue("github.error", array("url" => $url, "data" => $data), $response);

Check notice on line 17 in Src/lib/github.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Src/lib/github.php#L17

Short array syntax must be used to define arrays
}

return $response;
}

function generateAppToken()
Expand Down
6 changes: 2 additions & 4 deletions Src/pullRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ function handlePullRequest($pullRequest)
$issueResponse = requestGitHub($metadata["token"], $metadata["issuesUrl"] . "/" . $issueNumber);

$labels = array_column(json_decode($issueResponse["body"])->labels, "name");
echo "Labels: \n";
print_r($labels);
$body = array("labels" => array("WIP"));
requestGitHub($metadata["token"], $metadata["issuesUrl"] . "/" . $issueNumber . "/labels", $labels);
requestGitHub($metadata["token"], $metadata["issuesUrl"] . "/" . $issueNumber . "/labels", $body);
$body = array("labels" => $labels);
requestGitHub($metadata["token"], $metadata["prLabelsUrl"] . "/labels", $labels);
requestGitHub($metadata["token"], $metadata["prLabelsUrl"] . "/labels", $body);
}

if (!$botReviewed) {
Expand Down

0 comments on commit 7d679c6

Please sign in to comment.