Repository navigation
feat(gh-cli): add pull request involvement report #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4989d4d
feat(gh-cli): add pull request involvement report
joshjohanning 57b791e
fix(gh-cli): address pull request report review
joshjohanning bbfa3ec
fix(gh-cli): enforce pull request group precedence
joshjohanning 433c90c
fix(gh-cli): clarify argument count errors
joshjohanning 18e0a87
fix(gh-cli): handle search API limits safely
joshjohanning a60a9d3
fix(gh-cli): reject incomplete search results
joshjohanning c6ce235
fix(gh-cli): verify retrieval result counts
joshjohanning de1c164
fix(gh-cli): validate active GitHub authentication
joshjohanning File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #!/bin/bash | ||
| # Get open pull requests grouped by involvement: | ||
| # - Created by me | ||
| # - Assigned to me | ||
| # - Awaiting my review (requested reviewer) | ||
| # - Other involvement (mentioned or commented) | ||
| # | ||
| # Usage: ./get-my-pull-requests.sh [<exclude-organizations>] | ||
| # Example: ./get-my-pull-requests.sh | ||
| # Example: ./get-my-pull-requests.sh joshjohanning-org | ||
| # Example: ./get-my-pull-requests.sh joshjohanning-org,another-org | ||
| # Requires GitHub CLI authentication with access to the repositories being searched. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| echo "Usage: $0 [<exclude-organizations>]" >&2 | ||
| } | ||
|
|
||
| fail() { | ||
| echo "Error: $*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| search_pull_requests() { | ||
| local search_query="$1" | ||
|
|
||
| if ! gh api --method GET --paginate /search/issues \ | ||
| -f q="$search_query" \ | ||
| -F per_page=100 \ | ||
| --jq '.items[] | [.number, .title, (.repository_url | sub("^.*/repos/"; ""))] | @tsv'; then | ||
| fail "Pull request search failed. Check repository access and API rate limits with: gh api rate_limit" | ||
| fi | ||
| } | ||
|
joshjohanning marked this conversation as resolved.
Resolved
|
||
|
|
||
| [[ $# -le 1 ]] || { usage; exit 1; } | ||
| command -v gh >/dev/null 2>&1 || | ||
| fail "Required command not found: gh" | ||
| gh auth status >/dev/null 2>&1 || | ||
| fail "GitHub CLI is not authenticated. Run: gh auth login" | ||
|
|
||
| exclude_orgs="${1:-}" | ||
| user=$(gh api user --jq '.login') | ||
|
|
||
| exclusion="" | ||
| if [ -n "$exclude_orgs" ]; then | ||
| IFS=',' read -ra orgs <<< "$exclude_orgs" | ||
| for org in "${orgs[@]}"; do | ||
| [[ "$org" =~ ^[A-Za-z0-9]([A-Za-z0-9-]{0,37}[A-Za-z0-9])?$ ]] || | ||
| fail "Invalid organization name: $org" | ||
| exclusion="$exclusion -org:$org" | ||
| done | ||
| fi | ||
|
|
||
| echo "Fetching open pull requests for @$user..." >&2 | ||
| echo "" >&2 | ||
|
|
||
| echo "## Created by me" | ||
| search_pull_requests "author:$user is:pr is:open$exclusion" | ||
|
|
||
| echo "" >&2 | ||
| echo "## Assigned to me" | ||
| search_pull_requests "assignee:$user -author:$user is:pr is:open$exclusion" | ||
|
|
||
| echo "" >&2 | ||
| echo "## Awaiting my review (requested reviewer)" | ||
| search_pull_requests "review-requested:$user -author:$user -assignee:$user is:pr is:open$exclusion" | ||
|
|
||
| echo "" >&2 | ||
| echo "## Other involvement" | ||
| search_pull_requests "involves:$user -author:$user -assignee:$user -review-requested:$user is:pr is:open$exclusion" | ||
|
|
||
| echo "" >&2 | ||
| echo "Done!" >&2 | ||
|
joshjohanning marked this conversation as resolved.
Resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.