Sha256: 7da9cc5a674c256d0dece5a7dd5d29bb8dfd592acf54a0b40b1a24a012e6ce73
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
# -*- coding: utf-8 -*- module GitObjectBrowser module Dumper class ReflogDumper def initialize(root, outdir) @root = root @outdir = outdir end def dump files = [] Dir.chdir(@root) do Dir.glob("logs/**/*") do |path| files << path if File.file?(path) end end return if files.empty? files.each do |path| file = File.join(@root, path) next unless File.exist?(file) outfile = File.join(@outdir, "#{ path }.json") FileUtils.mkdir_p(File.dirname(outfile)) puts "Write: #{path}\n" File.open(file) do |input| File.open(outfile, "w") do |output| dump_object(input, output, path) end end end end def dump_object(input, output, path) obj = GitObjectBrowser::Models::Reflog.new(input).parse wrapped = GitObjectBrowser::Models::WrappedObject.new(nil, path, obj) output << JSON.pretty_generate(wrapped.to_hash) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems