summary refs log tree commit diff
path: root/.local/bin/jira-CR.php
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/jira-CR.php')
-rwxr-xr-x.local/bin/jira-CR.php19
1 files changed, 10 insertions, 9 deletions
diff --git a/.local/bin/jira-CR.php b/.local/bin/jira-CR.php
index cb8d637..fc72906 100755
--- a/.local/bin/jira-CR.php
+++ b/.local/bin/jira-CR.php
@@ -15,19 +15,21 @@ if (!function_exists('array_any')) {
 
 $padlen = 50;
 print(str_pad("\rGetting tickets from jira...", $padlen));
-$ticket_lines = explode("\n", rtrim(`jira-cli issues list -q"project IS NOT EMPTY and project != AUTO and project != NET and project != MSP and project != SYST and project != LOYAL" --order-by="Sprint" -s"Code Review" --columns=KEY,LABELS --plain | grep -v '^KEY\b'`));
+$ticket_lines = explode("\n", rtrim(shell_exec("jira-cli issues list -q'project IS NOT EMPTY and project != AUTO and project != NET and project != MSP and project != SYST and project != LOYAL' --order-by='Sprint' -s'Code Review' --columns=KEY,LABELS --plain | grep -v '^KEY\b'")));
 $tickets = array_map(fn($x) => explode("\t", $x)[0], $ticket_lines);
 $ticketLabels = array_combine(
     $tickets,
     array_map(fn($x) => explode(',', explode("\t", $x)[1] ?? ''), $ticket_lines)
 );
 
+$params = 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName,mergeable';
+
 print(str_pad("\rGetting OnBDC2 PR's from github...", $padlen));
-$prs_jsons[] = json_decode(`gh pr list -L 50 -R BetterCarPeople/OnBDC2 --json 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName,mergeable'`, true);
+$prs_jsons[] = json_decode(shell_exec("gh pr list -L 50 -R BetterCarPeople/OnBDC2 --json '$params'"), true);
 print(str_pad("\rGetting maple-ai PR's from github...", $padlen));
-$prs_jsons[] = json_decode(`gh pr list -R BetterCarPeople/maple-ai --json 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName,mergeable'`, true);
+$prs_jsons[] = json_decode(shell_exec("gh pr list -R BetterCarPeople/maple-ai --json '$params'"), true);
 print(str_pad("\rGetting maple-web PR's from github...", $padlen));
-$prs_jsons[] = json_decode(`gh pr list -R BetterCarPeople/maple-web --json 'title,url,statusCheckRollup,reviews,author,reviewDecision,reviewRequests,headRefName,mergeable'`, true);
+$prs_jsons[] = json_decode(shell_exec("gh pr list -R BetterCarPeople/maple-web --json '$params'"), true);
 
 print(str_pad("\r", $padlen));
 print("\r");
@@ -77,7 +79,6 @@ foreach ($prs_json as $pr) {
             }
         }
         $changeNames = array_unique($changeNames);
-        $changes = $changeNames ? (str_repeat("❌", count($changeNames)) . ": " . implode(", ", $changeNames) . '. ') : '';
 
         $requestNames = [];
         foreach ($pr['reviewRequests'] as $rr) {
@@ -88,7 +89,6 @@ foreach ($prs_json as $pr) {
             }
         }
         $requestNames = array_unique($requestNames);
-        $reviewRequests = $requestNames ? (str_repeat("🟡", count($requestNames)) . ": " . implode(", ", $requestNames) . '. ') : '';
 
         $approvers = [];
         foreach ($pr['reviews'] as $r) {
@@ -96,7 +96,6 @@ foreach ($prs_json as $pr) {
                 $approvers[] = $r['author']['login'];
             }
         }
-        $approvals = $approvers ? (str_repeat("✅", count($approvers)) . ": " . implode(", ", $approvers) . '. ') : '';
 
         $commentNames = [];
         foreach ($pr['reviews'] as $r) {
@@ -106,11 +105,13 @@ foreach ($prs_json as $pr) {
             }
         }
         $commentNames = array_unique($commentNames);
+
+        $changes = $changeNames ? (str_repeat("❌", count($changeNames)) . ": " . implode(", ", $changeNames) . '. ') : '';
+        $reviewRequests = $requestNames ? (str_repeat("🟡", count($requestNames)) . ": " . implode(", ", $requestNames) . '. ') : '';
+        $approvals = $approvers ? (str_repeat("✅", count($approvers)) . ": " . implode(", ", $approvers) . '. ') : '';
         $comments = $commentNames ? (str_repeat("💬", count($commentNames)) . ": " . implode(", ", $commentNames) . '. ') : '';
 
         $review_status = $changes . $reviewRequests . $approvals . $comments;
-        // Show review requested for
-        // show other review statuses
         
         echo "$pr[url]?T=$title($author)$labelsText$mergeable$pipeline_status$review_status\n";
     }