【Mac】ChatGPT API で Git コミットメッセージ をつくる ショートカットApp

ちょうどいいので作っておきます。

ChatGPT API で Git コミットメッセージ をつくる ショートカットApp

OPENAI_API_KEY を持っている人は使えます。


👉 Git Commit Message hatena-bookmark

ダウンロードしたら、OPEN_API_KEY 部分の Text を書き換えてください。

変更内容を入力すると、API経由で Git コミットメッセージを5つ作成してくれます。

お好みのメッセージを選択して、気に入らない部分は変更して、「DONE(完了)」を押すと、

クリップボードにコピー完了です。

あとは、IDEなどコミットメッセージ欄にペーストで貼り付ればOKです。



Mac や iPhone の ショートカットapp として使えます。


Google Authenticator から secret を抽出する方法

まず、エクスポートから QRコードを表示。

Google Authenticator から secret を抽出する

テキスト化します。



otpauth-migration://offline?data=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

※ 登録数が多ければ、XXX.. は、すごく長いです。

それをさらに以下のツールでデコードします。

👉 dim13/otpauth: Google Authenticator migration decoder hatena-bookmark

go を入れるのがだるいので対応するバイナリをダウンロードします。

dim13/otpauth: Google Authenticator migration decoder
👉 Release v0.5.1 · dim13/otpauth hatena-bookmark

どれなのか、良くわからないので、インストール先を調べます。


❯ uname -a
Darwin iMac.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64 x86_64

❯ uname -m
x86_64

otpauth-v0.5.1-darwin-amd64.tgz をダウンロードして展開します。M1+なら「arm64」

先に取得したテキストを渡して実行します。


❯ ./otpauth -link "otpauth-migration://offline?data=XXXXX..."

otpauth://totp/Example%20Company:[email protected]?algorithm=SHA1&digits=6&issuer=Example+Company&period=30&secret=QUU6EA2GHORGMD22SN2YKU6VKISCKYAG
otpauth://totp/Henrik%20Schacks%20blog?algorithm=SHA1&digits=6&period=30&secret=5YGQ4IAR32CYA6PY
otpauth://totp/[email protected]?algorithm=SHA1&digits=6&issuer=MyCompanyName.AbpZeroTemplate&period=30&secret=MFRDCZDFMQ3DAMDC
otpauth://totp/WordPress:ThinkingTeapot?algorithm=SHA1&digits=6&issuer=WordPress&period=30&secret=S55IFILZLA6DESAO
otpauth://totp/Google:[email protected]?algorithm=SHA1&digits=6&issuer=Google&period=30&secret=QJV3EN5JJJHGQ4PK3M6E576YMWUC5D4X
...

これの secret パラメータがそれ。base32 でエンコードされた文字列です。

👉 RFC 6238: TOTP: Time-Based One-Time Password Algorithm hatena-bookmark

他のTOTPジェネレータにも登録しておくと安心できます。

👉 「GitHub」で2要素認証の義務化、3月13日から - ケータイ Watch hatena-bookmark


【Git】.gitignore の状態を確認するコマンドたち

git status --ignored

まずは、状態の確認をしましょう。

以下は、基本的な Android プロジェクトでの例。


 

■ 位置を確認する


❯ find . -name .gitignore                          
./app/.gitignore
./.gitignore
./.idea/.gitignore

👉 AndroidStudio 新規プロジェクトテンプレートから考える .gitignore hatena-bookmark

 

■ git status


❯ git status          
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

 

■ git status --ignored


❯ git status --ignored
On branch main
Your branch is up to date with 'origin/main'.

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        .gradle/
        .idea/workspace.xml
        app/build/
        local.properties

nothing to commit, working tree clean

→ ignore 対象が確認できます。

 

■ git clean -ndX


❯ git clean -ndX
Would remove .gradle/
Would remove .idea/workspace.xml
Would remove app/build/
Would remove build/
Would remove local.properties

 

■ git check-ignore -v


❯ git check-ignore -v .gradle/           
.gitignore:2:.gradle    .gradle/

❯ git check-ignore -v .idea/workspace.xml
.idea/.gitignore:3:/workspace.xml       .idea/workspace.xml

❯ git check-ignore -v app/build/         
app/.gitignore:1:/build app/build/

❯ git check-ignore -v local.properties
.gitignore:15:local.properties  local.properties

❯ git check-ignore -v **/*
app/.gitignore:1:/build app/build
app/.gitignore:1:/build app/build/generated
app/.gitignore:1:/build app/build/generated/ap_generated_sources
app/.gitignore:1:/build app/build/generated/ap_generated_sources/debug
app/.gitignore:1:/build app/build/generated/ap_generated_sources/debug/out
app/.gitignore:1:/build app/build/generated/res
...

→ そのファイルを ignore するパターン記述を特定することができます。

 

■ git ls-files --other --ignored --exclude-standard


❯ git ls-files --other --ignored --exclude-standard
.gradle/7.5.1/checksums/checksums.lock
.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock
.gradle/7.5.1/dependencies-accessors/gc.properties
.gradle/7.5.1/executionHistory/executionHistory.bin
.gradle/7.5.1/executionHistory/executionHistory.lock
...

→ 実際に ignore されたファイル一覧が確認できます。Adroid プロジェクトでは出力行が多くなるので省略しています。

 

■ 参考

👉 Git のステータス: リポジトリの検査 | Atlassian Git Tutorial hatena-bookmark