LoginSignup
8
7

More than 3 years have passed since last update.

[Ruby][Git] git log -L で特定の関数 (メソッド) の変更履歴が見られるらしいので Ruby でも試してみた

Last updated at Posted at 2019-05-24

概要

次のツイートを見て便利そうだと思った。

どうやら

git log -L :<関数名>:<ファイルパス>

という形式で特定の関数の変更履歴が見られるらしい。
このツイートでは Python の関数の変更履歴を表示していたが、Ruby のメソッドでもできるか試してみた。

試しに Active Support コア拡張機能の String#truncate の変更履歴を確認してみる。ローカルに Rails のリポジトリを git clone して、次の git コマンドを実行する。

git log -L :truncate:activesupport/lib/active_support/core_ext/string/filters.rb

01.png

02.png

本当に truncate のログと差分だけ表示された!メソッドの変更を追跡するのにファイルごとだと粒度が大きいので、メソッドごとに表示できるのは便利だ ☺️

8
7
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
8
7