diff options
author | Richard Lowe <richlowe@richlowe.net> | 2011-12-07 04:57:40 +0000 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2011-12-07 00:08:52 -0500 |
commit | 5a21453af5fefd7780d16d0b543dab9c084bca63 (patch) | |
tree | 2c9300744599f131f92affca57b1592d23bc09db /usr/src | |
parent | f13d7e675e5c3a29fd4b5430119ef3454f7e165e (diff) | |
download | illumos-joyent-5a21453af5fefd7780d16d0b543dab9c084bca63.tar.gz |
webrev: Detect and handle renames
While gathering the list of _really_ changed files, record the name they
used to have such that we can deal with renames.
Git does not really support renames, and calculates this at runtime also
providing a 'score' indicating the likelyhood of being a rename. We
currently only treat as renames those situations with a score > 75 (out
of 100).
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/tools/scripts/webrev.sh | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/usr/src/tools/scripts/webrev.sh b/usr/src/tools/scripts/webrev.sh index f55df21969..2244203e80 100644 --- a/usr/src/tools/scripts/webrev.sh +++ b/usr/src/tools/scripts/webrev.sh @@ -1799,35 +1799,50 @@ function git_wxfile TMPFLIST=/tmp/$$.active $PERL -e 'my (%files, %realfiles, $msg); - my $state = 1; # 0|comments, 1|files my $branch = $ARGV[0]; - - open(F, "git diff -M --name-only $branch |"); + + open(F, "git diff -M --name-status $branch |"); while (<F>) { chomp; - $realfiles{$_} = 1; + if (/^R(\d+)\s+([^ ]+)\s+([^ ]+)/) { # rename + if ($1 >= 75) { # Probably worth treating as a rename + $realfiles{$3} = $2 + } else { + $realfiles{$3} = $3; + $realfiles{$2} = $2; + } + } else { + my $f = (split /\s+/, $_)[1]; + $realfiles{$f} = $f; + } } close(F); - - open(F, "git whatchanged --pretty=format:\"%B\" $branch.. |"); + + my $state = 1; # 0|comments, 1|files + open(F, "git whatchanged --pretty=format:%B $branch.. |"); while (<F>) { chomp; if (/^:[0-9]{6}/) { my $fname = (split /\t/, $_)[1]; + next if !defined($realfiles{$fname}); # No real change $state = 1; $files{$fname} = $msg; } else { if ($state == 1) { - $state = 0; - $msg = /^\n/ ? "" : "\n"; + $state = 0; + $msg = /^\n/ ? "" : "\n"; } $msg .= "$_\n" if ($_); } } close(F); - + for (sort keys %files) { - print "$_\n$files{$_}\n" if defined $realfiles{$_}; + if ($realfiles{$_} ne $_) { + print "$_ $realfiles{$_}\n$files{$_}\n"; + } else { + print "$_\n$files{$_}\n" + } }' ${parent} > $TMPFLIST wxfile=$TMPFLIST |