end0tknr's kipple - 新web写経開発

http://d.hatena.ne.jp/end0tknr/ から移転しました

svn diff と diffstat で、変更,更新を考慮したSLOCを考える

新規アプリは単純に wc -l で行数(ステップ数)を数えれば良いですが
変更がある場合、単純にdiffを取得すると 差分は2行として数えられます。


$ svn diff -r 1144:1140 https://example.com/repos/xing/trunk | diffstat -f 4                                 
 lib/Xing/Model/Summary/HExportStream.pm |    9     3     6     0 +++------
 lib/Xing/Model/Summary/HJuchuu.pm       |   16     8     8     0 ++++++++--------
 tmpl/HSummary/SummaryList.html          |   12     6     6     0 ++++++------
 3 files changed, 17 insertions(+), 20 deletions(-)

※上記の「9 3 6」の値は、3が追加で、6が削除分です


$ diffstat --help                                                                                                          
Usage: diffstat [options] [files]

Reads from one or more input files which contain output from 'diff',
producing a histogram of total lines changed for each file referenced.
If no filename is given on the command line, reads from standard input.

  -c      prefix each line with comment (#)
  -e FILE redirect standard error to FILE
  -f NUM  format (0=concise, 1=normal, 2=filled, 4=values)
  -h      print this message
  -k      do not merge filenames
  -l      list filenames only
  -n NUM  specify minimum width for the filenames (default: auto)
  -o FILE redirect standard output to FILE
  -p NUM  specify number of pathname-separators to strip (default: common)
  -r NUM  specify rounding for histogram (0=none, 1=simple, 2=adjusted)
  -t      print a table (comma-separated-values) rather than histogram
  -u      do not sort the input list
  -v      makes output more verbose
  -V      prints the version number
  -w NUM  specify maximum width of the output (default: 80)