mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 22:55:13 +00:00
Fix(triage): Update pr-triage.sh script (#7698)
Co-authored-by: Srinath Padmanabhan <srithreepo@google.com>
This commit is contained in:
committed by
GitHub
parent
c0794215d3
commit
d5d150449d
46
.github/scripts/pr-triage.sh
vendored
46
.github/scripts/pr-triage.sh
vendored
@@ -19,24 +19,10 @@ process_pr() {
|
|||||||
local PR_NUMBER=$1
|
local PR_NUMBER=$1
|
||||||
echo "🔄 Processing PR #${PR_NUMBER}"
|
echo "🔄 Processing PR #${PR_NUMBER}"
|
||||||
|
|
||||||
# Get PR body with error handling
|
# Get closing issue number with error handling
|
||||||
local PR_BODY
|
local ISSUE_NUMBER
|
||||||
if ! PR_BODY=$(gh pr view "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --json body -q .body 2>/dev/null); then
|
if ! ISSUE_NUMBER=$(gh pr view "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --json closingIssuesReferences -q '.closingIssuesReferences.nodes[0].number' 2>/dev/null); then
|
||||||
echo " ⚠️ Could not fetch PR #${PR_NUMBER} details"
|
echo " ⚠️ Could not fetch closing issue for PR #${PR_NUMBER}"
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Look for issue references using multiple patterns
|
|
||||||
local ISSUE_NUMBER=""
|
|
||||||
|
|
||||||
# Pattern 1: Direct reference like #123
|
|
||||||
if [[ -z "${ISSUE_NUMBER}" ]]; then
|
|
||||||
ISSUE_NUMBER=$(echo "${PR_BODY}" | grep -oE '#[0-9]+' | head -1 | sed 's/#//' 2>/dev/null || echo "")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Pattern 2: Closes/Fixes/Resolves patterns (case-insensitive)
|
|
||||||
if [[ -z "${ISSUE_NUMBER}" ]]; then
|
|
||||||
ISSUE_NUMBER=$(echo "${PR_BODY}" | grep -iE '(closes?|fixes?|resolves?) #[0-9]+' | grep -oE '#[0-9]+' | head -1 | sed 's/#//' 2>/dev/null || echo "")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${ISSUE_NUMBER}" ]]; then
|
if [[ -z "${ISSUE_NUMBER}" ]]; then
|
||||||
@@ -95,21 +81,6 @@ process_pr() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Find labels to remove (on PR but not on issue)
|
|
||||||
local LABELS_TO_REMOVE=""
|
|
||||||
for label in "${PR_LABEL_ARRAY[@]}"; do
|
|
||||||
if [[ -n "${label}" ]] && [[ " ${ISSUE_LABEL_ARRAY[*]} " != *" ${label} "* ]]; then
|
|
||||||
# Don't remove status/need-issue since we already handled it
|
|
||||||
if [[ "${label}" != "status/need-issue" ]]; then
|
|
||||||
if [[ -z "${LABELS_TO_REMOVE}" ]]; then
|
|
||||||
LABELS_TO_REMOVE="${label}"
|
|
||||||
else
|
|
||||||
LABELS_TO_REMOVE="${LABELS_TO_REMOVE},${label}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Apply label changes
|
# Apply label changes
|
||||||
if [[ -n "${LABELS_TO_ADD}" ]]; then
|
if [[ -n "${LABELS_TO_ADD}" ]]; then
|
||||||
echo "➕ Adding labels: ${LABELS_TO_ADD}"
|
echo "➕ Adding labels: ${LABELS_TO_ADD}"
|
||||||
@@ -118,14 +89,7 @@ process_pr() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${LABELS_TO_REMOVE}" ]]; then
|
if [[ -z "${LABELS_TO_ADD}" ]]; then
|
||||||
echo "➖ Removing labels: ${LABELS_TO_REMOVE}"
|
|
||||||
if ! gh pr edit "${PR_NUMBER}" --repo "${GITHUB_REPOSITORY}" --remove-label "${LABELS_TO_REMOVE}" 2>/dev/null; then
|
|
||||||
echo " ⚠️ Failed to remove some labels"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${LABELS_TO_ADD}" ]] && [[ -z "${LABELS_TO_REMOVE}" ]]; then
|
|
||||||
echo "✅ Labels already synchronized"
|
echo "✅ Labels already synchronized"
|
||||||
fi
|
fi
|
||||||
echo "needs_comment=false" >> "${GITHUB_OUTPUT}"
|
echo "needs_comment=false" >> "${GITHUB_OUTPUT}"
|
||||||
|
|||||||
Reference in New Issue
Block a user