summaryrefslogtreecommitdiff
path: root/tool/change_maker.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-24 06:10:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-24 06:10:09 +0000
commitc5652b900823a00e1f7cccfbad62b9354e812d0f (patch)
tree7e87516e92eebe3d398da3c2877fcbbcf35897ca /tool/change_maker.rb
parente16c316b52948396eac43ee9d79383274c616256 (diff)
downloadruby-c5652b900823a00e1f7cccfbad62b9354e812d0f.tar.gz
* tool/change_maker.rb: use external diff for -p option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/change_maker.rb')
-rwxr-xr-xtool/change_maker.rb29
1 files changed, 16 insertions, 13 deletions
diff --git a/tool/change_maker.rb b/tool/change_maker.rb
index d039de9909..b83b98428c 100755
--- a/tool/change_maker.rb
+++ b/tool/change_maker.rb
@@ -1,26 +1,29 @@
#! ./miniruby
-if File.directory?(".svn")
- cmd = "svn diff"
-elsif File.directory?(".git")
- cmd = "git diff"
-else
- abort "does not seem to be under a vcs"
-end
-
def diff2index(cmd, *argv)
+ lines = []
path = nil
`#{cmd} #{argv.join(" ")}`.split(/\n/).each do |line|
case line
when /^Index: (\S*)/, /^diff --git [a-z]\/(\S*) [a-z]\/\1/
path = $1
- when /^@@.*@@ +([A-Za-z_][A-Za-z_0-9 ]*[A-Za-z_0-9])/
- puts "* #{path} (#{$1}):"
+ when /^@@\s*-\d+,\d+ +\+(\d+),\d+\s*@@(?: +([A-Za-z_][A-Za-z_0-9 ]*[A-Za-z_0-9]))?/
+ line = $1.to_i
+ ent = "* #{path}"
+ ent << " (#{$2})" if $2
+ lines << "#{ent}:"
end
end
- !!path
+ lines.uniq!
+ lines.empty? ? nil : lines
end
-if !diff2index(cmd, ARGV) and /^git/ =~ cmd
- diff2index(cmd, "--cached", ARGV)
+if File.directory?(".svn")
+ cmd = "svn diff --diff-cmd=diff -x-pU0"
+ puts diff2index(cmd, ARGV)
+elsif File.directory?(".git")
+ cmd = "git diff"
+ puts diff2index(cmd, ARGV) || diff2index(cmd, "--cached", ARGV)
+else
+ abort "does not seem to be under a vcs"
end