stMind

about Tech, Computer vision and Machine learning

Tensorflowレポジトリのコミット数ランキングを表示するワンライナー

  1. git logコマンドのfomatオプションでauthor nameを出力
  2. sort
  3. uniq -cで連続する行数をカウント、重複行は削除
  4. sort -nrで降順にソート
  5. headで先頭から10件表示
$ git log --format='%an' | sort | uniq -c | sort -nr | head 
21995 A. Unique TensorFlower
3476 TensorFlower Gardener
1229 Yong Tang
1155 Shanqing Cai
1154 Derek Murray
1055 Gunhan Gulsoy
1046 Benoit Steiner
1036 Vijay Vasudevan
 865 River Riddle
 794 Martin Wicke

tensorflowのレポジトリをローカルに持ってない場合は、Github APIを使ってコミット履歴を取ってくる。(Pageを解釈するのはちょっと難しかったので置いといて...)

  1. wgetでcommitsをJSONで受け取る
  2. jqでjsonのauthor nameを抽出
  3. 上で実行した2以降の処理をする
$ wget -O - -q https://api.github.com/repos/tensorflow/tensorflow/commits?per_page=100 | jq '.[] | .commit.author.name' | sort | uniq -c | sort -nr | head
  16 "A. Unique TensorFlower"
   8 "TensorFlower Gardener"
   5 "Gunhan Gulsoy"
   4 "Yujing Zhang"
   3 "Zhenyu Tan"
   3 "Peter Hawkins"
   3 "Andy Ly"
   2 "tg-at-google"
   2 "Thomas O'Malley"
   2 "T.J. Alumbaugh"

以下のブログにインスパイアされてやってみました。

prithu.xyz