山口です。
「今のプロジェクトで自分は何行ぐらいコードを書いてるのかな〜?」と思ったことはありませんか? ありますよね!
今回は、そんな方に是非とも使って頂きたいコマンドの紹介です。
git-countとは?
git-count は git のサブコマンドで、git リポジトリ内にあるコードを対象に "誰が"、"何行" コードを書いたのかを計測するコマンドです。 履歴ではなく、今現在のコードに対して計測を行います。
git のサブコマンドになっているので、 git count
という感じにお手軽に実行できます。
出力結果は以下の様にファイルの数と誰が何行書いたのか、合計で何行なのかが表示されます。
899 files found.
mironal 34019
mtmta 28792
ryohey 3963
YanaC 2116
Total 68890
その他には以下の様な機能があります。
詳しくは help を参照して下さい(下記参照)。
usage: git count <path> [<regex>]
CAUTION !!
Is very time consuming, if the repository is large.
OPTIONS
<path>
Attempt to counts the file hierarchy rooted in each file.
e.g.
Following the "src" directory. -> git count "path/to/src"
Following the "test" directory. -> git count "path/to/test"
Following the current directory. -> git count "."
<regex>
If you specify this regex pattern.
You can count lines that files that match the regular expression.
This regex pattern is the egrep regex pattern.
e.g.
Following the "src" directory. -> git count "path/to/src"
Only Java source code. -> git count "." "\.java$"
Only Scala source code. -> git count "." "\.scala$"
Only Objective-C code. -> git count "." "\.[hm]$"
Or
You can use default regex from git-config.
git config --local git-count.regex "your regex pattern"
git config --global git-count.regex "your regex pattern"
Commandline argument takes precedence.
For more information -> "https://github.com/neethouse/git-count"
何のために使うのか?
特に用途は定めていませんが以下の様な感じで使えます。
- 自分の書いたコード量が分かってモチベーションアップ or ダウン
- 日々実行してグラフにすればコードの増加量が分かる
- Jenkins のテストが通るまでの暇つぶし
インストール方法
READMEの Installation を参考にして下さい。
厚かましいお願い
- リポジトリのサイズが大きいと実行に非常に時間がかかってしまいます、こうすれば爆速になるぜ!ってアイデアをお持ちの方はプルリクエスト頂けると嬉しいです
- 英語が微妙なので、おかしいところがあったらプルリクエスト頂けると嬉しいです
- 本家 brew に登録しようとしましたが、知名度が低すぎて却下されたので Star 頂けると嬉しいです
NeetHouse について
The Neet House Project
は弊社社員が開発中に思いついたツールを公開するリポジトリとなっております。
今後も公開できるものを増やしていく予定です。
それでは皆様、良い Git ライフを!