Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (27 sloc) 838 Bytes
#!/usr/bin/env ruby
# -*- encoding: UTF-8 -*-
def get_diff_files(git_dir, rev1, rev2)
#puts "git --git-dir #{git_dir} diff --name-only #{rev1} #{rev2}"
diff = `git --git-dir #{git_dir} diff --name-only #{rev1} #{rev2}`
end
def export_files(file_list, rev2, destination, git_dir)
working_dir = git_dir.sub(/\.git$/,'');
file_count = file_list.split("\n").length
count = 1;
file_list.each do |f|
f.chomp!
out = [destination,f].join('/')
mkdir = "mkdir -p #{File.dirname(out)}"
cmd = "git --git-dir #{git_dir} show #{rev2}:#{f} >> #{out}"
puts "#{count}/#{file_count}: #{out}"
system(mkdir)
system(cmd)
count += 1
end
end
if __FILE__ == $0
git_dir, rev1, rev2, destination = ARGV
diffs = get_diff_files git_dir, rev1, rev2
puts diff
export_files diffs, rev2, destination, git_dir
end