citusdata / pg_shard

ATTENTION: pg_shard is superseded by Citus, its more powerful replacement
https://github.com/citusdata/citus
GNU Lesser General Public License v3.0
1.06k stars 63 forks source link

Fix authorship information #20

Closed jasonmp85 closed 9 years ago

jasonmp85 commented 9 years ago

I think GitHub uses something like git blame -w to show blame information, so adding spaces wasn't sufficient. Trying again with // as the character added to "touch" a line.

jasonmp85 commented 9 years ago

For what it's worth I set up a shell like so:

export GIT_AUTHOR_NAME='Original Author'
export GIT_AUTHOR_EMAIL=author@example.com
export GIT_COMMITTER_NAME='Jason Petersen'
export GIT_COMMITTER_EMAIL=me@example.com

Then I used a checkout of the old repo adjacent to a checkout of the new repo. I ran this:

git ls-files -z | xargs -P 7 -0 -t -L 1 -I % sh -c "git blame -C -C -C --line-porcelain % | grep -E '^\t|committer-mail' | sed -E 's/committer-mail <([^>]*)>/\1/g' | author-touch.rb $GIT_AUTHOR_EMAIL > ../pg_shard/% "

The author-touch.rb in there is in my path and is the simple little script below:

#!/usr/bin/env ruby

author = ARGV.shift.dup

if author.nil?
  puts "Please specify an author email as the first argument"
  exit -1
end

author.chomp!

STDIN.each_slice(2) do |email, line|
  email.chomp!
  line.gsub!(/^\t/, '');
  line.chomp!
  if email == author
    puts "#{line}//\n"
  else
    puts line
  end
end