0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

コミットハッシュに紐づく GitHub のプルリクエストをブラウザで開く

Last updated at Posted at 2023-11-26

目的

コミットハッシュを元に、そのコミットが含まれる GitHub の PullRequest の URL をデフォルトブラウザで開きます

前提

  • macOS Ventura 13.5.2
  • gh version 2.33.0 (2023-08-18)
  • jq-1.7

コマンド

$ gh api repos/:owner/:reponame/commits/:commit/pulls | jq '.[0].html_url' | xargs open

:owner :reponame は適宜読み替えてください。 :commit には対象のコミットハッシュが入ります。

関数化

open-pr() {
  local commit_hash=$1
  local repo_owner="hoge"
  local repo_name="fuga"
  gh api repos/$repo_owner/$repo_name/commits/$commit_hash/pulls | jq '.[0].html_url' | xargs open
}
$ open-pr xxxxxxxx

良い感じに。

HEAD に紐づくPRを開く

現在のコミットに対応するPRを開きたい場合もまぁある。

open-pr-head() {
  open-pr $(git rev-parse HEAD)
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?