fix: use /pulls instead of /pulls/pinned #4

Merged
lyn merged 10 commits from fix/pr-list-endpoint into main 2026-04-01 17:09:04 +00:00
Showing only changes of commit 5725ac79bb - Show all commits

View File

@@ -134,6 +134,30 @@ cmd_commits() {
echo "$RESPONSE" | jq -r '.[] | "\(.sha[0:7])\t\(.commit.message | split("\n")[0])"' 2>/dev/null || echo "$RESPONSE"
}
# Subcommand: show
cmd_show() {
local repo_path="$1"
local pr_index="$2"
get_repo_info "$repo_path"
local token
token="$(ensure_token)"
echo "Showing PR #$pr_index in: $OWNER/$REPO_NAME"
RESPONSE=$(curl -s -X GET "https://git.hangman-lab.top/api/v1/repos/${OWNER}/${REPO_NAME}/pulls/${pr_index}" \
-H 'accept: application/json' \
-H "Authorization: token ${token}")
if echo "$RESPONSE" | jq -e '.message' >/dev/null 2>&1; then
ERROR_MSG=$(echo "$RESPONSE" | jq -r '.message')
echo "Error: $ERROR_MSG"
exit 1
fi
echo "$RESPONSE" | jq '.'
}
# Subcommand: merge
cmd_merge() {
local repo_path="$1"
@@ -194,9 +218,9 @@ cmd_merge() {
200)
MERGED=$(echo "$RESPONSE" | jq -r '.merged')
if [[ "$MERGED" == "true" ]]; then
echo "Pull request merged successfully!"
echo "merge success"
else
echo "Error: Failed to merge pull request"
echo "merge failed"
echo "$RESPONSE" | jq '.'
exit 1
fi
@@ -217,7 +241,7 @@ cmd_merge() {
exit 1
;;
405)
echo "$RESPONSE" | jq -r '.message'
echo "merge failed check the pr status"
exit 1
;;
*)
@@ -243,6 +267,7 @@ usage() {
echo " commits <repo-local-path> <pr-index> List commits in a PR"
echo " merge <repo-local-path> <pr-index> <do> [commit-id] [title] [message]"
echo " Merge a pull request"
echo " show <repo-local-path> <pr-index> Show PR details"
echo ""
echo " <do> can be: merge, squash, rebase, manually-merged"
exit 2
@@ -285,6 +310,13 @@ case "$COMMAND" in
fi
cmd_merge "$@"
;;
show)
if [[ $# -lt 2 ]]; then
echo "Error: show requires <repo-local-path> <pr-index>"
exit 2
fi
cmd_show "$@"
;;
*)
echo "Error: Unknown command: $COMMAND"
usage