🐱
Githubで自分にアサインされたissue一覧を表示する
使用するツール
Github CLIのインストール
CLIのトップページにHomebrewのコマンドとパッケージがあるのでどちらかでインストール
$ brew install gh
==> Auto-updating Homebrew...
~~ 省略 ~~
##################################################################################################################################################################### 100.0%
==> Pouring gh--2.49.2.arm64_sonoma.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Summary
🍺 /opt/homebrew/Cellar/gh/2.49.2: 198 files, 48.2MB
==> Running `brew cleanup gh`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
$
認証する
いくつか質問をされるので回答
$ gh auth login
? What account do you want to log into? [Use arrows to move, type to filter]
> GitHub.com
GitHub Enterprise Server
? What is your preferred protocol for Git operations on this host? [Use arrows to move, type to filter]
HTTPS
> SSH
? Upload your SSH public key to your GitHub account? [Use arrows to move, type to filter]
> /Users/name/.ssh/id_rsa.pub
Skip
? Title for your SSH key: (GitHub CLI)
? How would you like to authenticate GitHub CLI? [Use arrows to move, type to filter]
> Login with a web browser
Paste an authentication token
! First copy your one-time code: XXXX-XXXX
Press Enter to open github.com in your browser...
今回はブラウザでのログインを選択。
「! First copy your one-time code:」のコードを入力
以下のようなメッセージがでれば認証環境。
✓ Authentication complete.
- gh config set -h github.com git_protocol ssh
✓ Configured git protocol
✓ SSH key already existed on your GitHub account: /Users/name/.ssh/id_rsa.pub
✓ Logged in as xxxx
issue一覧を表示する
.gitに依存して表示する方法
アサインが自分のissue一覧
$ gh issue list --assignee @me
リポジトリで絞り込む
$ gh issue list --assignee @me --repo OWNER/REPO
クローズされたissueも含める
$ gh issue list --assignee @me --state all
JSON形式で出力する
$ gh issue list --assignee @me --limit 100 --json title,number,url,state --jq '.[] | {title, number, url, state}'
.gitに依存しないで全てのリポジトリから取得する方法
gh apiを使用する
$ gh api --paginate -X GET "search/issues?q=assignee:@me+is:issue+is:open" -H "Accept: application/vnd.github.v3+json"
jqコマンドを交えて必要な項目飲みに絞り込む
$ gh api --paginate -X GET "search/issues?q=assignee:@me+is:issue+is:open" -H "Accept: application/vnd.github.v3+json" | jq -r '.items[] | "\(.number): \(.title) (\(.html_url)) [\(.state)]"'
最後に
スプレッドシートに登録したりプロジェクト管理ツールのインポート用のファイルに書き込んだりとここまで取得できれば一覧化するのはいけそうだなと感じました。
間違いなどあれば指摘してください。
Discussion