From 871b28ef57c3ffcd333cd86ed9a67299a333d04d Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Fri, 13 Mar 2026 08:40:57 -0400 Subject: add my two best jira-cli scripts --- .local/bin/jira-CR.php | 79 ++++++++++++++++++++++++++++++++++++++++++++++ .local/bin/jira-codereview | 46 +++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100755 .local/bin/jira-CR.php create mode 100755 .local/bin/jira-codereview diff --git a/.local/bin/jira-CR.php b/.local/bin/jira-CR.php new file mode 100755 index 0000000..e87d265 --- /dev/null +++ b/.local/bin/jira-CR.php @@ -0,0 +1,79 @@ +#!/usr/bin/env php + 38) { + $title = substr($title,0,35)."..."; + } + $author = $pr['author']['login']; + + // Show approvers + $review_status = ""; + + $changeNames = []; + foreach ($pr['reviews'] as $r) { + if ($r['state'] === "CHANGES_REQUESTED") { + $changeNames[] = $r['author']['login']; + } + } + $changes = $changeNames ? (str_repeat("❌", count($changeNames)) . ": " . implode(", ", $changeNames) . '. ') : ''; + + $requestNames = []; + foreach ($pr['reviewRequests'] as $rr) { + if ($rr['__typename'] === "Team") { + $requestNames[] = $rr['name']; + } else { + $requestNames[] = $rr['login']; + } + } + $reviewRequests = $requestNames ? (str_repeat("🟡", count($requestNames)) . ": " . implode(", ", $requestNames) . '. ') : ''; + + $approvers = []; + foreach ($pr['reviews'] as $r) { + if ($r['state'] === "APPROVED") { + $approvers[] = $r['author']['login']; + } + } + $approvals = $approvers ? (str_repeat("✅", count($approvers)) . ": " . implode(", ", $approvers) . '. ') : ''; + + $commentNames = []; + foreach ($pr['reviews'] as $r) { + $newName = $r['author']['login']; + if ($r['state'] === "COMMENTED" && !in_array($newName, $approvers) && !in_array($newName, $requestNames) && $newName != $author) { + $commentNames[] = $newName; + } + } + $commentNames = array_unique($commentNames); + $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)\t$review_status\n"; + } +} +exit(1); + + diff --git a/.local/bin/jira-codereview b/.local/bin/jira-codereview new file mode 100755 index 0000000..9fbdfc3 --- /dev/null +++ b/.local/bin/jira-codereview @@ -0,0 +1,46 @@ +#!/bin/sh +if test "$1"; then + ticket=$1 +else + ticket=$(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,PRIORITY,SUMMARY,ASSIGNEE | fzf --print-query | tail -n1 | cut -f1) + ticket=$(printf "%s" $ticket) +fi +if test "$ticket"; then + echo "Reviewing $ticket ..." + # ugh + #xdg-open https://proactivedealersolutions.atlassian.net/browse/$ticket + xdg-open "https://github.com/pulls?q=is%3Aopen+is%3Apr+user%3ABetterCarPeople+$ticket" + #xdg-open "https://github.com/search?q=is%3Aopen+is%3Apr+org%3ABetterCarPeople+$ticket" +else + exit 1; +fi + +start=$(date +%H%M) +start_uts=$(date +%s) +#started="$(date -Iseconds | tr 'T' ' ')" +started="$(date +'%Y-%m-%d %H:%M:%S')" +tz="America/New_York" + +date +echo "Press enter when you're done reviewing" +read -r hi +date + +end=$(date +%H%M) +end_uts=$(date +%s) + +printf "%s - %s %s CR\n" "$start" "$end" "$ticket" +minutes_rounded_up=$(( ((($end_uts - $start_uts )/300)+ 1 ) * 5 )) +printf "should log %dm\n" "$minutes_rounded_up" + + +jira-cli issue worklog add "$ticket" --comment="CR" --started="$started" --timezone="$tz" + +printf "%s - %s %s CR\n" "$start" "$end" "$ticket" | wl-copy + + +echo "Do you want to move the ticket?" +echo 'jira-cli issue edit '$ticket' --label DBA_Approved --no-input' +echo 'jira-cli issue move '$ticket' "Check out My Work"' #"Pending Demo"' +echo 'jira-cli issue edit '$ticket' --label "Post-mortem_(Demo)" --no-input && jira-cli issue move '$ticket' "Testing"' + -- cgit 1.4.1