fix(git): pass explicit repo to Gitea wrappers

This commit is contained in:
Jarvis
2026-05-25 14:19:52 -05:00
parent ae076e194a
commit a70159d350
5 changed files with 129 additions and 58 deletions

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# pr-view.sh - View pull request details on GitHub or Gitea
# Usage: pr-view.sh -n <pr_number>
# Usage: pr-view.sh -n <pr_number> [-r owner/repo]
set -e
@@ -9,6 +9,7 @@ source "$SCRIPT_DIR/detect-platform.sh"
# Parse arguments
PR_NUMBER=""
REPO_OVERRIDE=""
while [[ $# -gt 0 ]]; do
case $1 in
@@ -16,11 +17,16 @@ while [[ $# -gt 0 ]]; do
PR_NUMBER="$2"
shift 2
;;
-r|--repo)
REPO_OVERRIDE="$2"
shift 2
;;
-h|--help)
echo "Usage: pr-view.sh -n <pr_number>"
echo "Usage: pr-view.sh -n <pr_number> [-r owner/repo]"
echo ""
echo "Options:"
echo " -n, --number PR number (required)"
echo " -r, --repo Repository slug (default: infer from git origin)"
echo " -h, --help Show this help"
exit 0
;;
@@ -36,12 +42,23 @@ if [[ -z "$PR_NUMBER" ]]; then
exit 1
fi
detect_platform
if [[ -n "$REPO_OVERRIDE" ]]; then
REPO_INFO="$REPO_OVERRIDE"
PLATFORM=$(detect_platform 2>/dev/null || echo gitea)
else
detect_platform > /dev/null
REPO_INFO=$(get_repo_info)
fi
if [[ -z "$REPO_INFO" || "$REPO_INFO" == error:* ]]; then
echo "Error: Could not determine repository from git origin. Run from a repo or pass --repo." >&2
exit 1
fi
if [[ "$PLATFORM" == "github" ]]; then
gh pr view "$PR_NUMBER"
gh pr view "$PR_NUMBER" --repo "$REPO_INFO"
elif [[ "$PLATFORM" == "gitea" ]]; then
tea pr "$PR_NUMBER"
tea pr "$PR_NUMBER" --repo "$REPO_INFO"
else
echo "Error: Unknown platform"
exit 1