Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 09:01:58 +08:00
commit aa33fffdfe
25 changed files with 4562 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
#!/bin/bash
# get-pr-info.sh - Fetches PR information for the current branch
# Usage: get-pr-info.sh [branch_name]
# Output: JSON with PR details
set -e
BRANCH_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}"
# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
echo '{"error": "GitHub CLI (gh) not installed. Install: https://cli.github.com/"}' | jq
exit 1
fi
# Check if authenticated
if ! gh auth status &> /dev/null; then
echo '{"error": "Not authenticated with GitHub CLI. Run: gh auth login"}' | jq
exit 1
fi
# Get PR for current branch
PR_DATA=$(gh pr view "$BRANCH_NAME" --json number,title,body,url,state,isDraft,additions,deletions,changedFiles 2>/dev/null || echo '{"error": "No PR found for branch: '"$BRANCH_NAME"'"}')
# Check if error in PR_DATA
if echo "$PR_DATA" | jq -e '.error' &> /dev/null; then
echo "$PR_DATA"
exit 1
fi
# Add branch name to output
echo "$PR_DATA" | jq --arg branch "$BRANCH_NAME" '. + {branch: $branch}'