diff options
author | Noe Rubinstein <nrubinstein@avencall.com> | 2012-02-13 12:06:27 +0100 |
---|---|---|
committer | Noe Rubinstein <nrubinstein@avencall.com> | 2012-02-13 12:06:27 +0100 |
commit | 1454bb92cdb6331afd065b7340b8267738e62772 (patch) | |
tree | bae56e11ad3a4b1232be4b14298138543d24e09d | |
parent | 3a5483aeef9f8da21646e5d6013b1bbc8edd40e4 (diff) |
new scripts
-rwxr-xr-x | find_nitpicking.rb | 34 | ||||
-rwxr-xr-x | fix_linux_indent.rb | 2 | ||||
-rwxr-xr-x | git_checkpatch.sh | 3 |
3 files changed, 38 insertions, 1 deletions
diff --git a/find_nitpicking.rb b/find_nitpicking.rb new file mode 100755 index 0000000..486c523 --- /dev/null +++ b/find_nitpicking.rb @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +def eqon(a,b) + (yield a) == (yield b) +end + +s = ARGF.read + +def section start; /#{start}.+?(?=(?:#{start}|\z))/m; end +def line start; /^#{start}.+/; end +def lines start; /(?:#{line start}\n)+/m; end +hunks = section /^diff/ +hunk = section /^@@[^\n]*@@/ +minus = lines '-' +plus = lines '\+' +minusplus = /(?:#{minus }|#{plus})+/m + +s.gsub!(hunks) { |hs| + r = hs.gsub(hunk) { |h| + h.scan(minusplus).reject { |c| + eqon(minus, plus) { |r| + c.scan(r).map{ |l| + l.gsub(/^./,"").gsub(/\s+/m,"") + } + } + }.empty? ? "" : h + # }.empty? ? h : "" # uncomment this to see what nitpicking would get removed + } + + r.scan(hunk).empty? ? "" : r +} + +puts s + diff --git a/fix_linux_indent.rb b/fix_linux_indent.rb index 8d2da60..01dc12c 100755 --- a/fix_linux_indent.rb +++ b/fix_linux_indent.rb @@ -6,6 +6,8 @@ spl = spaces.scan(/\t/).length + (spaces.scan(/ /).length + 7) / 8 start = rand(0xFFFFFFFFFFFFFFFFFFFF).to_s(36) stop = rand(0xFFFFFFFFFFFFFFFFFFFF).to_s(36) input = '{' * spl + '//' + start + "\n" + str + "\n//" + stop + "\n}" * spl +indent = 'scripts/Lindent' +indent = 'indent' unless File.exist? indent io = IO.popen("indent -linux", "r+") io.print input io.close_write diff --git a/git_checkpatch.sh b/git_checkpatch.sh index 3982925..caa72d0 100755 --- a/git_checkpatch.sh +++ b/git_checkpatch.sh @@ -6,8 +6,9 @@ git checkout -b test_checkpatch git reset --soft v2.6.34 git commit --allow-empty -a -m "huge commit" git format-patch --stdout HEAD\^ > /tmp/patch -~/linux-2.6/scripts/checkpatch.pl /tmp/patch > /tmp/checkpatch || : git checkout - git branch -D test_checkpatch git reset --soft `git symbolic-ref HEAD`'@{1}' +~/linux-2.6/scripts/checkpatch.pl /tmp/patch > /tmp/checkpatch || : + |