6
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gitinspectorを使ってみた

Posted at

インストール

公式サイト https://code.google.com/p/gitinspector/ よりダウンロードして、unzip。
gitとPython2.6以上が必要、CentOS 6.xならyumで多分大丈夫。

使い方

gitinspector.py [オプション] [gitレポジトリのパス]

分析結果が標準出力されるので、ファイルに保存したい場合はリダイレクトを使う。

gitinspector.py -f java,conf,css,html,js,properties,sh,vm,xml -F htmlembedded -THmrl /home/mriit/ITRM > /var/www/html/inspector_simple.html

-fで解析したいファイルの拡張子をカンマ区切りで指定、-Fで出力形式を指定、デフォルトはテキスト形式。html形式はjQueryなどを外部から参照している、htmlembeddedはそれらを埋め込んだもの。公式に各種のサンプルがあり、以下はその一部。

inspector_sample.png

authorごとに、コミット数、追加行数、削除行数、変更の割合や、月ごと(-Wで週ごと)の変更行数などが表示される。

よくわからない事故が・・・

そのまま使ったら、「git blameに eオプションはない」というエラーが出た。git 1.7.1にはblameに-eがないことは確認。
blame.pyにその記述があるので、そこをいじることにした。

「-e」削るだけではだめなようだ

色々試したところ、-nが正解っぽいようなので、該当箇所を下記のようにする

blame.py
blame_string = "git blame -n -w {0} ".format("-C -C -M" if hard else "") + \

そしたら、authorの名前取得がうまくいかなくなった模様…
下記のメソッドでgit blame で出力されたものからemailをとって、それをもとにauthorの名前をとるようにしている?

blame.py
@staticmethod
        def get_author_email(string):
                author_email = re.search(" \((.*?)\d\d\d\d-\d\d-\d\d", string)
                return author_email.group(1).strip().lstrip("<").rstrip(">")
changes.py
def get_latest_author_by_email(self, name):
               return self.authors_by_email[name]

自分の環境でgit blameをしたら、authorの名前が出ているので、そんなことをしない方がうまくいくのでは思い、上記のメソッドを、もらったnameをそのまま返すように変更したら動くようになった。もっと適切な解決があると思うが、とりあえずはこれで。

まとめ

やけくそ感満載だけど、とりあえずリポジトリからの情報が得られたので良しとする。gitの方にも問題があったかも。gitで開発する際は、定期的にこれを見てみる。期間が短い場合は、週ごとの表示にした方がよいかも。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?