「このコンポーネント詳しい人誰だろう?」を git-who で見つける

sinclairtarget/git-who というツールがあって面白かったのでメモ

まずは何ができるのかの結論から、
JetBrains/kotlin を clone してルートディレクトリで git-who を実行すると
以下のように Commiter を commit 順に表示してくれるというツール

~/.../JetBrains/kotlin (master)$ git-who
┌─────────────────────────────────────────────────────┐
│Author                            Last Edit   Commits│
├─────────────────────────────────────────────────────┤
│Alexander Udalov                  5 days ago    6,748│
│Mikhail Glukhikh                  5 days ago    5,500│
│Dmitriy Novozhilov                3 days ago    4,195│
│Nikolay Krasko                    6 days ago    4,163│
│Andrey Breslav                    6 yr. ago     3,740│
│Valentin Kipyatkov                4 yr. ago     3,064│
│Ilya Gorbunov                     3 weeks ago   3,041│
│Ilya Kirillov                     1 month ago   2,531│
│Yan Zhulanow                      2 weeks ago   2,510│
│Alexey Sedunov                    6 yr. ago     2,505│
│...999 more...                                       │
└─────────────────────────────────────────────────────┘

特定のディレクトリに絞って (以下の例では /JetBrains/kotlin/plugins/ ) 実行することもできる

~/.../JetBrains/kotlin/plugins (master)$ git-who
┌─────────────────────────────────────────────────────┐
│Author                            Last Edit   Commits│
├─────────────────────────────────────────────────────┤
│Alexander Udalov                  5 days ago    6,748│
│Mikhail Glukhikh                  5 days ago    5,500│
│Dmitriy Novozhilov                3 days ago    4,195│
│Nikolay Krasko                    6 days ago    4,163│
│Andrey Breslav                    6 yr. ago     3,740│
│Valentin Kipyatkov                4 yr. ago     3,064│
│Ilya Gorbunov                     3 weeks ago   3,041│
│Ilya Kirillov                     1 month ago   2,531│
│Yan Zhulanow                      2 weeks ago   2,510│
│Alexey Sedunov                    6 yr. ago     2,505│
│...999 more...                                       │
└─────────────────────────────────────────────────────┘

表示項目については様々なオプションがあるので詳細は --help を参照する

~/.../JetBrains/kotlin (master)$ git-who table --help
Usage: git-who table [options...] [revisions...] [[--] paths...]
Print out a table showing total contributions by author

  -author value
        Only count commits by these authors. Can be specified multiple times
  -c    Sort by first modified (created)
  -csv
        Output as csv
  -e    Show email address of each author
  -f    Sort by files changed
  -l    Sort by lines added + removed
  -m    Sort by last modified
  -merges
        Count merge commits toward commit total
  -n int
        Limit rows in table (set to 0 for no limit) (default 10)
  -nauthor value
        Exclude commits by these authors. Can be specified multiple times
  -since string
        Only count commits after the given date. See git-commit(1) for valid date formats
  -until string
        Only count commits before the given date. See git-commit(1) for valid date formats

ちなみに git-whoGit Aliases という機能により git who という呼び出しができる

ここまで見てきたように「ある特定のサブシステムやコンポーネントで詳しい人 (≒ よく commit している人) は誰なんだろうか?」という疑問に対して一旦の回答を瞬時に得ることができる。
実際 README.md にも以下のようにツールのモチベーションについて書かれている。

git-who is a command-line tool for answering that eternal question:

Who wrote this code?!

Unlike git blame, which can tell you who wrote a line of code, git-who tells you the people responsible for entire components or subsystems in a codebase. You can think of git-who sort of like git blame but for file trees rather than individual files.

また README.md によれば他にも以下のような実行が可能とのこと

# tag に対しても実行できる
git who v3.7.1
git who v3.10.9..v3.11.9

# 期間や author でフィルタリングすることもできる
# --nauthor とすると対象の author を含まないというフィルタリング
git who --since "1 year ago" --nauthor "Alexander Udalov"

また、デフォルトでは table 形式で表示されるが以下のように tree として表示することも可能
(※ table と比較して実行に多少時間がかかる)

~/.../JetBrains/kotlin (master)$ git who tree -d 3 # -d は深さを制限するオプション
./.............................................................................................Alexander Udalov (6,748)
├── .fleet/....................................................................................Nikolay Krasko (2)
│   └── settings.json..........................................................................Sebastian Sellmair (1)
├── .idea/.....................................................................................Pavel Talanov (159)
│   ├── codeStyles/............................................................................Nikolay Krasko (3)
│   │   ├── Project.xml
│   │   └── codeStyleConfig.xml................................................................Simon Ogorodnik (1)
│   ├── copyright/.............................................................................Pavel Talanov (4)
│   │   ├── apache.xml.........................................................................Dmitry Savvinov (2)
│   │   └── profiles_settings.xml
│   ├── dictionaries/..........................................................................Nikolay Krasko (21)
│   │   ├── 4u7.xml............................................................................Vyacheslav Gerasimov (12)
│   │   ├── Alexey_Sedunov.xml.................................................................Alexey Sedunov (1)
│   │   ├── Andrey_Yastrebov.xml...............................................................Andrey Yastrebov (2)
│   │   ├── Artem_Daugel_Dauge.xml.............................................................Artem Daugel-Dauge (1)
│   │   ├── Denis_Zharkov.xml..................................................................Denis.Zharkov (1)
│   │   ├── Kirill.xml.........................................................................Kirill Rakhman (1)
│   │   ├── Nikolay_Krasko.xml
│   │   ├── abreslav.xml.......................................................................Andrey Breslav (8)
│   │   ├── bashor.xml.........................................................................Zalim Bashorov (8)
│   │   ├── darthorimar.xml....................................................................Ilya Kirillov (1)
│   │   ├── dimonchik0036.xml..................................................................Dmitry Gridin (1)
│   │   ├── dmitriy_dolovov.xml................................................................Dmitriy Dolovov (8)
│   │   ├── dzharkov.xml.......................................................................Denis Zharkov (5)
│   │   ├── geevee.xml.........................................................................Evgeny Gerashchenko (7)           
│   │   ├── hungnv.xml.........................................................................Hung Nguyen (5)
│   │   ├── igor.xml...........................................................................Igor Laevsky (4)                  
│   │   ├── max.xml............................................................................Maxim Shafirov (3)
│   │   ├── sebastiansellmair.xml..............................................................sebastian.sellmair (4)            
│   │   ├── sergej_jaskiewicz.xml..............................................................Sergej Jaskiewicz (2)
│   │   ├── sergey_igushkin.xml................................................................Sergey Igushkin (1)               
│   │   ├── skuzmich.xml.......................................................................Svyatoslav Kuzmich (3)
│   │   ├── svyatoslav_kuzmich.xml.............................................................Svyatoslav Kuzmich (2)            
│   │   ├── valentin.xml.......................................................................Valentin Kipyatkov (21)
│   │   ├── yan.xml............................................................................Yan Zhulanow (15)                 
│   │   └── yole.xml...........................................................................Dmitry Jemerov (1)
│   ├── inspectionProfiles/....................................................................Nikolay Krasko (37)

hist というコマンドでアクティビティの量みたいなのを見ることもできる
いまいち読み取り方わかってないが詳細は README#the-hist-subcommand

~/.../JetBrains/kotlin (master)$ git who hist
2008#                                     The Android Open Source … (1)
20092010#                                     Andrey Breslav (93)
2011###----                               Andrey Breslav (862)
2012####---------------                   Evgeny Gerashchenko (1,082)
2013###----------                         Andrey Breslav (984)
2014###---------------                    Alexander Udalov (810)
2015#####-----------------------          Valentin Kipyatkov (1,537)
2016###----------------------             Alexander Udalov (753)
2017##-------------------------           Alexander Udalov (681)
2018##-------------------------           Mikhail Glukhikh (683)
2019##---------------------------         Mikhail Glukhikh (589)
2020###---------------------------------  Dmitriy Novozhilov (973)
2021###---------------------------        Dmitriy Novozhilov (824)
2022##-------------------                 Dmitriy Novozhilov (462)
2023##---------------------------         Dmitrii Gridin (674)
2024###-----------------------------      Dmitrii Gridin (765)
2025#-------                              Dmitrii Gridin (225)

まとめ

何かしらのプロダクトに新規で参画した際や初めて触るモジュールが出てきた際にはぜひ使っていこうと思った。