git-object-browser 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -0
- data/htdocs/{css → common/css}/angular-ui.min.css +0 -0
- data/htdocs/{css → common/css}/bootstrap-responsive.css +0 -0
- data/htdocs/{css → common/css}/bootstrap-responsive.min.css +0 -0
- data/htdocs/{css → common/css}/bootstrap.css +0 -0
- data/htdocs/{css → common/css}/bootstrap.min.css +0 -0
- data/htdocs/{css → common/css}/font-awesome-ie7.css +0 -0
- data/htdocs/{css → common/css}/font-awesome.css +0 -0
- data/htdocs/{css → common/css}/main.css +0 -0
- data/htdocs/{font → common/font}/fontawesome-webfont.eot +0 -0
- data/htdocs/{font → common/font}/fontawesome-webfont.svg +0 -0
- data/htdocs/{font → common/font}/fontawesome-webfont.ttf +0 -0
- data/htdocs/{font → common/font}/fontawesome-webfont.woff +0 -0
- data/htdocs/{img → common/img}/glyphicons-halflings-white.png +0 -0
- data/htdocs/{img → common/img}/glyphicons-halflings.png +0 -0
- data/htdocs/common/js/main.js +495 -0
- data/htdocs/{js → common/js}/vendor/angular-bootstrap-prettify.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular-bootstrap.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular-cookies.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular-loader.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular-resource.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular-sanitize.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular-ui-ieshiv.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular-ui.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular.js +0 -0
- data/htdocs/{js → common/js}/vendor/angular.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/bootstrap.js +0 -0
- data/htdocs/{js → common/js}/vendor/bootstrap.min.js +0 -0
- data/htdocs/{js → common/js}/vendor/html5shiv.js +0 -0
- data/htdocs/{js → common/js}/vendor/jquery-1.8.2.min.js +0 -0
- data/htdocs/{templates → common/templates}/directory.html +2 -2
- data/htdocs/common/templates/error.html +6 -0
- data/htdocs/{templates → common/templates}/file.html +0 -0
- data/htdocs/{templates → common/templates}/git.html +0 -0
- data/htdocs/{templates → common/templates}/index.html +1 -1
- data/htdocs/{templates → common/templates}/index_entry.html +0 -0
- data/htdocs/{templates → common/templates}/info_refs.html +2 -2
- data/htdocs/{templates → common/templates}/loading.html +0 -0
- data/htdocs/{templates → common/templates}/notfound.html +1 -2
- data/htdocs/{templates → common/templates}/object.html +1 -1
- data/htdocs/{templates → common/templates}/objects.html +3 -3
- data/htdocs/{templates → common/templates}/pack_file.html +1 -1
- data/htdocs/common/templates/pack_index.html +39 -0
- data/htdocs/{templates → common/templates}/packed_object.html +4 -4
- data/htdocs/{templates → common/templates}/packed_refs.html +2 -2
- data/htdocs/{templates → common/templates}/ref.html +0 -0
- data/htdocs/common/templates/reflog.html +29 -0
- data/htdocs/config.js +6 -0
- data/htdocs/default.js +7 -0
- data/htdocs/index.html +52 -20
- data/lib/git-object-browser.rb +12 -4
- data/lib/git-object-browser/dumper/directories_dumper.rb +42 -0
- data/lib/git-object-browser/dumper/index_dumper.rb +20 -7
- data/lib/git-object-browser/dumper/info_refs_dumper.rb +37 -0
- data/lib/git-object-browser/dumper/main.rb +188 -81
- data/lib/git-object-browser/dumper/objects_dumper.rb +46 -0
- data/lib/git-object-browser/dumper/pack_indexes_dumper.rb +85 -0
- data/lib/git-object-browser/dumper/packed_objects_dumper.rb +36 -0
- data/lib/git-object-browser/dumper/packed_refs_dumper.rb +37 -0
- data/lib/git-object-browser/dumper/plain_files_dumper.rb +74 -0
- data/lib/git-object-browser/dumper/refs_dumper.rb +46 -0
- data/lib/git-object-browser/main.rb +22 -6
- data/lib/git-object-browser/models/directory.rb +5 -3
- data/lib/git-object-browser/models/git_date.rb +26 -0
- data/lib/git-object-browser/models/git_object.rb +1 -1
- data/lib/git-object-browser/models/pack_file.rb +1 -1
- data/lib/git-object-browser/models/pack_index.rb +139 -25
- data/lib/git-object-browser/models/packed_object.rb +1 -1
- data/lib/git-object-browser/models/reflog.rb +54 -0
- data/lib/git-object-browser/models/wrapped_object.rb +40 -0
- data/lib/git-object-browser/server/git_servlet.rb +130 -100
- data/lib/git-object-browser/server/main.rb +1 -1
- data/lib/git-object-browser/version.rb +1 -1
- metadata +62 -50
- data/htdocs/js/main.js +0 -285
- data/htdocs/templates/pack_index.html +0 -37
- data/lib/git-object-browser/dumper/object_dumper.rb +0 -20
- data/lib/git-object-browser/dumper/pack_index_dumper.rb +0 -21
- data/lib/git-object-browser/dumper/packed_object_dumper.rb +0 -19
@@ -6,17 +6,30 @@ module GitObjectBrowser
|
|
6
6
|
|
7
7
|
class IndexDumper
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
@
|
11
|
-
@
|
9
|
+
def initialize(root, outdir)
|
10
|
+
@root = root
|
11
|
+
@outdir = outdir
|
12
12
|
end
|
13
13
|
|
14
|
+
|
14
15
|
def dump
|
15
|
-
|
16
|
+
index_file = File.join(@root, "index")
|
17
|
+
out_file = File.join(@outdir, "index.json")
|
18
|
+
|
19
|
+
return unless File.exist?(index_file)
|
20
|
+
|
21
|
+
puts "Write: index\n"
|
22
|
+
File.open(index_file) do |input|
|
23
|
+
File.open(out_file, "w") do |output|
|
24
|
+
dump_object(input, output)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
16
28
|
|
17
|
-
|
18
|
-
|
19
|
-
|
29
|
+
def dump_object(input, output)
|
30
|
+
obj = GitObjectBrowser::Models::Index.new(input).parse
|
31
|
+
wrapped = GitObjectBrowser::Models::WrappedObject.new(nil, 'index', obj)
|
32
|
+
output << JSON.pretty_generate(wrapped.to_hash)
|
20
33
|
end
|
21
34
|
|
22
35
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module GitObjectBrowser
|
4
|
+
|
5
|
+
module Dumper
|
6
|
+
|
7
|
+
class InfoRefsDumper
|
8
|
+
|
9
|
+
def initialize(root, outdir)
|
10
|
+
@root = root
|
11
|
+
@outdir = outdir
|
12
|
+
end
|
13
|
+
|
14
|
+
def dump
|
15
|
+
src_file = File.join(@root, "info/refs")
|
16
|
+
dst_file = File.join(@outdir, "info/refs.json")
|
17
|
+
|
18
|
+
return unless File.exist?(src_file)
|
19
|
+
|
20
|
+
puts "Write: info/refs\n"
|
21
|
+
File.open(src_file) do |input|
|
22
|
+
File.open(dst_file, "w") do |output|
|
23
|
+
dump_object(input, output)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def dump_object(input, output)
|
29
|
+
obj = GitObjectBrowser::Models::InfoRefs.new(input)
|
30
|
+
wrapped = GitObjectBrowser::Models::WrappedObject.new(nil, 'info/refs', obj)
|
31
|
+
output << JSON.pretty_generate(wrapped.to_hash)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -1,124 +1,231 @@
|
|
1
1
|
module GitObjectBrowser
|
2
2
|
module Dumper
|
3
3
|
|
4
|
-
|
4
|
+
HTDOCS_DIR = File.join(File.dirname(__FILE__), '../../../htdocs')
|
5
5
|
|
6
6
|
class Main
|
7
7
|
|
8
|
-
def self.execute(target)
|
9
|
-
|
8
|
+
def self.execute(target, outdir, step, diff_dir)
|
9
|
+
outdir = File.expand_path(outdir)
|
10
|
+
|
11
|
+
if outdir =~ %r{(?:^|/).git(?:/|$)} && outdir !~ %r{/.git/dump/?\z}
|
12
|
+
raise 'Dump directory must be .git/dump if you dump into the .git directory.'
|
13
|
+
end
|
14
|
+
|
15
|
+
if File.exist?(outdir)
|
16
|
+
Dir.chdir(outdir) do
|
17
|
+
if !Dir.glob('*').empty? && Dir.glob('json/**/_git.json').empty?
|
18
|
+
raise 'dump directory exists but it may not be the old dump directory. json/**/_git.json doesn\'t exist.'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
if diff_dir
|
24
|
+
diff_dir = File.expand_path(diff_dir)
|
25
|
+
raise "#{ diff_dir } must be directory." unless File.directory?(diff_dir)
|
26
|
+
raise "#{ diff_dir }/_git.json doesn't exist" unless File.exist?(File.join(diff_dir, '_git.json'))
|
27
|
+
end
|
28
|
+
|
29
|
+
new(target, outdir, step, diff_dir).dump
|
10
30
|
end
|
11
31
|
|
12
|
-
def initialize(target)
|
32
|
+
def initialize(target, outdir, step, diff_dir)
|
13
33
|
@target = target
|
14
|
-
@outdir =
|
34
|
+
@outdir = outdir
|
35
|
+
@step = step
|
36
|
+
@diff_dir = diff_dir
|
37
|
+
|
38
|
+
if @step
|
39
|
+
(@diff_dir, @step) = find_next_dir if @step == :next
|
40
|
+
@json_dir = File.join(@outdir, 'json', @step)
|
41
|
+
else
|
42
|
+
@json_dir = File.join(@outdir, 'json')
|
43
|
+
end
|
15
44
|
end
|
16
45
|
|
46
|
+
def find_next_dir
|
47
|
+
json_dir = File.join(@outdir, 'json')
|
48
|
+
FileUtils.mkdir_p(json_dir) unless File.exist?(json_dir)
|
49
|
+
dir = Dir.open(json_dir).map do |dir|
|
50
|
+
if dir =~ /\Astep(\d+)\z/
|
51
|
+
[dir, $1.to_i]
|
52
|
+
else
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
end.compact.sort {|a,b| a[1] <=> b[1] }.last
|
56
|
+
if dir
|
57
|
+
return [File.join(json_dir, dir[0]), "step#{dir[1] + 1}"]
|
58
|
+
else
|
59
|
+
return [nil, "step1"]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
private :find_next_dir
|
63
|
+
|
17
64
|
def dump
|
18
|
-
Dir.mkdir(@outdir) unless File.exist?(@outdir)
|
19
|
-
dump_index
|
20
65
|
dump_objects
|
21
|
-
|
66
|
+
copy_htdocs
|
67
|
+
create_config
|
68
|
+
create_diff_data
|
69
|
+
create_note
|
70
|
+
if @step
|
71
|
+
puts "-- Complete: #{ @step }"
|
72
|
+
else
|
73
|
+
puts "-- Complete"
|
74
|
+
end
|
22
75
|
end
|
23
76
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
77
|
+
def create_config
|
78
|
+
puts "-- Create config files"
|
79
|
+
unless File.exist?(File.join(@outdir, 'config.js'))
|
80
|
+
puts "Write: config.js"
|
81
|
+
FileUtils.copy_entry(File.join(HTDOCS_DIR, 'config.js'),
|
82
|
+
File.join(@outdir, 'config.js'))
|
83
|
+
end
|
27
84
|
|
28
|
-
|
85
|
+
puts "Write: default.js"
|
86
|
+
default_file = File.join(@outdir, 'default.js')
|
87
|
+
if File.exist?(default_file)
|
88
|
+
conf = File.read(default_file)
|
89
|
+
create = false
|
90
|
+
else
|
91
|
+
conf = File.read(File.join(HTDOCS_DIR, 'default.js'))
|
92
|
+
create = true
|
93
|
+
end
|
94
|
+
if conf =~ /var config = (\{.+\});/m
|
95
|
+
json = $1
|
96
|
+
else
|
97
|
+
json = '{}'
|
98
|
+
end
|
99
|
+
conf = JSON.parse(json)
|
100
|
+
if create
|
101
|
+
conf['loadNote'] = true
|
102
|
+
conf['loadDiff'] = true
|
103
|
+
end
|
104
|
+
conf['steps'] = [] unless conf['steps'].is_a? Array
|
105
|
+
conf['steps'] << { 'name' => @step, 'label' => @step }
|
29
106
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
dumper.dump
|
35
|
-
end
|
107
|
+
File.open(default_file, 'w') do |io|
|
108
|
+
io << "// Edit config.js instead of this file.\n"
|
109
|
+
io << "// This file will be rewritten by git object-browser command.\n"
|
110
|
+
io << "var config = " + JSON.pretty_generate(conf) + ";\n"
|
36
111
|
end
|
37
112
|
end
|
38
113
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
114
|
+
def create_diff_data
|
115
|
+
return unless @step
|
116
|
+
unless @diff_dir
|
117
|
+
puts "-- Create empty diff data"
|
118
|
+
puts "Write: _diff.json"
|
119
|
+
File.open(File.join(@json_dir, '_diff.json'), 'w') do |io|
|
120
|
+
io << '[]'
|
44
121
|
end
|
122
|
+
return
|
45
123
|
end
|
46
|
-
return if obj_files.empty?
|
47
124
|
|
48
|
-
|
49
|
-
|
125
|
+
puts "-- Create diff data"
|
126
|
+
old_files = []
|
127
|
+
Dir.chdir(@diff_dir) do
|
128
|
+
Dir.glob("**/*").each do |file|
|
129
|
+
next unless File.file?(file)
|
130
|
+
next if File.directory?(file.sub(/\.json\z/, ''))
|
131
|
+
next if %w{_git.json _diff.json}.include?(file)
|
132
|
+
old_files << file
|
133
|
+
end
|
134
|
+
end
|
50
135
|
|
51
|
-
|
52
|
-
|
53
|
-
|
136
|
+
new_files = []
|
137
|
+
Dir.chdir(@json_dir) do
|
138
|
+
Dir.glob("**/*").each do |file|
|
139
|
+
next unless File.file?(file)
|
140
|
+
next if File.directory?(file.sub(/\.json\z/, ''))
|
141
|
+
next if %w{_git.json _diff.json}.include?(file)
|
142
|
+
new_files << file
|
143
|
+
end
|
144
|
+
end
|
54
145
|
|
55
|
-
|
56
|
-
Dir.mkdir(parent) unless File.exist?(parent)
|
146
|
+
diff_files = []
|
57
147
|
|
58
|
-
|
59
|
-
|
60
|
-
File.
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
148
|
+
common_files = old_files & new_files
|
149
|
+
common_files.each do |file|
|
150
|
+
a = File.join(@diff_dir, file)
|
151
|
+
b = File.join(@json_dir, file)
|
152
|
+
unless FileUtils.cmp(a, b)
|
153
|
+
diff_files << file.sub(/\.json\z/, '')
|
65
154
|
end
|
66
155
|
end
|
67
156
|
|
157
|
+
removed_files = old_files - new_files
|
158
|
+
removed_files.each do |file|
|
159
|
+
diff_files << file.sub(/\.json\z/, '')
|
160
|
+
end
|
161
|
+
|
162
|
+
added_files = new_files - old_files
|
163
|
+
added_files.each do |file|
|
164
|
+
diff_files << file.sub(/\.json\z/, '')
|
165
|
+
end
|
166
|
+
|
167
|
+
puts "Write: _diff.json"
|
168
|
+
File.open(File.join(@json_dir, '_diff.json'), 'w') do |io|
|
169
|
+
io << JSON.pretty_generate(diff_files)
|
170
|
+
end
|
68
171
|
end
|
69
172
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
173
|
+
def dump_objects
|
174
|
+
if File.exist?(@json_dir)
|
175
|
+
puts "-- Remove old JSON files"
|
176
|
+
if @step
|
177
|
+
puts "Remove: json/#{ @step }"
|
178
|
+
else
|
179
|
+
puts "Remove: json/*"
|
75
180
|
end
|
181
|
+
FileUtils.rm_r(@json_dir)
|
76
182
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
183
|
+
puts "-- Dump objects"
|
184
|
+
FileUtils.mkdir_p(@json_dir)
|
185
|
+
[IndexDumper,
|
186
|
+
ObjectsDumper,
|
187
|
+
RefsDumper,
|
188
|
+
DirectoriesDumper,
|
189
|
+
PlainFilesDumper,
|
190
|
+
PackIndexesDumper,
|
191
|
+
PackedRefsDumper,
|
192
|
+
InfoRefsDumper,
|
193
|
+
].each do |dumper|
|
194
|
+
dumper.new(@target, @json_dir).dump
|
195
|
+
end
|
196
|
+
end
|
197
|
+
private :dump_objects
|
198
|
+
|
199
|
+
def copy_htdocs
|
200
|
+
puts "-- Copy htdocs"
|
201
|
+
Dir.chdir(HTDOCS_DIR) do
|
202
|
+
Dir.glob('*').each do |file|
|
203
|
+
next if %w{config.js default.js}.include?(file)
|
204
|
+
if File.directory?(file)
|
205
|
+
puts "Copy: #{file}/*"
|
206
|
+
else
|
207
|
+
puts "Copy: #{file}"
|
103
208
|
end
|
209
|
+
FileUtils.copy_entry(file, File.join(@outdir, file))
|
104
210
|
end
|
105
211
|
end
|
106
212
|
end
|
107
213
|
|
108
|
-
def
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
File.
|
118
|
-
|
214
|
+
def create_note
|
215
|
+
if @step
|
216
|
+
FileUtils.mkdir_p(File.join(@outdir, 'notes'))
|
217
|
+
path = File.join(@outdir, 'notes', "#{ @step }.html")
|
218
|
+
msg = "Create: notes/#{ @step }.html"
|
219
|
+
else
|
220
|
+
path = File.join(@outdir, 'note.html')
|
221
|
+
msg = "Create: note.html"
|
222
|
+
end
|
223
|
+
unless File.exist?(path)
|
224
|
+
puts "-- Create note"
|
225
|
+
puts msg
|
226
|
+
File.open(path, 'w') {}
|
119
227
|
end
|
120
228
|
end
|
121
|
-
|
122
229
|
end
|
123
230
|
end
|
124
231
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module GitObjectBrowser
|
4
|
+
|
5
|
+
module Dumper
|
6
|
+
|
7
|
+
class ObjectsDumper
|
8
|
+
|
9
|
+
def initialize(root, outdir)
|
10
|
+
@root = root
|
11
|
+
@outdir = outdir
|
12
|
+
end
|
13
|
+
|
14
|
+
def dump
|
15
|
+
obj_files = []
|
16
|
+
Dir.chdir(@root) do
|
17
|
+
Dir.glob("objects/**/*") do |path|
|
18
|
+
obj_files << path if File.file?(path) && path =~ %r{/[a-z0-9]{38}$}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
return if obj_files.empty?
|
22
|
+
|
23
|
+
obj_files.each do |path|
|
24
|
+
outfile = File.join(@outdir, "#{ path }.json")
|
25
|
+
next if File.exist?(outfile)
|
26
|
+
|
27
|
+
FileUtils.mkdir_p(File.dirname(outfile))
|
28
|
+
|
29
|
+
puts "Write: #{path}\n"
|
30
|
+
obj_file = File.join(@root, path)
|
31
|
+
File.open(obj_file) do |input|
|
32
|
+
File.open(outfile, "w") do |output|
|
33
|
+
dump_object(input, output, path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def dump_object(input, output, path)
|
40
|
+
obj = GitObjectBrowser::Models::GitObject.new(input).parse
|
41
|
+
wrapped = GitObjectBrowser::Models::WrappedObject.new(nil, path, obj)
|
42
|
+
output << JSON.pretty_generate(wrapped.to_hash)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module GitObjectBrowser
|
4
|
+
|
5
|
+
module Dumper
|
6
|
+
|
7
|
+
class PackIndexesDumper
|
8
|
+
|
9
|
+
def initialize(root, outdir)
|
10
|
+
@root = root
|
11
|
+
@outdir = outdir
|
12
|
+
end
|
13
|
+
|
14
|
+
def dump
|
15
|
+
index_files = []
|
16
|
+
Dir.chdir(@root) do
|
17
|
+
Dir.glob('objects/pack/pack-*.idx') do |path|
|
18
|
+
next unless path =~ %r{/pack-[0-9a-f]{40}\.idx}
|
19
|
+
index_files << path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
return if index_files.empty?
|
23
|
+
|
24
|
+
# digest, sha1 order, offset order
|
25
|
+
index_files.each do |path|
|
26
|
+
dump_digest(path)
|
27
|
+
dump_ordered(path, 'sha1')
|
28
|
+
dump_ordered(path, 'offset')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def dump_digest(path)
|
33
|
+
outfile = File.join(@outdir, "#{ path }.json")
|
34
|
+
infile = File.join(@root, path)
|
35
|
+
FileUtils.mkdir_p(File.dirname(outfile))
|
36
|
+
puts "Write: #{path}\n"
|
37
|
+
|
38
|
+
File.open(infile) do |input|
|
39
|
+
File.open(outfile, 'w') do |output|
|
40
|
+
dump_object(input, output, path, 'digest', nil)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def dump_object(input, output, path, order, page)
|
46
|
+
obj = GitObjectBrowser::Models::PackIndex.new(input).parse(order, page)
|
47
|
+
wrapped = GitObjectBrowser::Models::WrappedObject.new(nil, path, obj)
|
48
|
+
output << JSON.pretty_generate(wrapped.to_hash)
|
49
|
+
end
|
50
|
+
|
51
|
+
def dump_ordered(path, order)
|
52
|
+
FileUtils.mkdir_p(File.join(@outdir, "#{ path }/#{ order }"))
|
53
|
+
page = 1
|
54
|
+
loop do
|
55
|
+
outfile = File.join(@outdir, "#{ path }/#{ order }/#{ page }.json")
|
56
|
+
infile = File.join(@root, path)
|
57
|
+
obj = nil
|
58
|
+
File.open(infile) do |input|
|
59
|
+
obj = GitObjectBrowser::Models::PackIndex.new(input).parse(order, page)
|
60
|
+
end
|
61
|
+
break if obj.empty?
|
62
|
+
|
63
|
+
packpath = path.sub(/\.idx\z/, '.pack')
|
64
|
+
packfile = File.join(@root, packpath)
|
65
|
+
File.open(packfile) do |input|
|
66
|
+
obj.load_object_types(input)
|
67
|
+
end
|
68
|
+
|
69
|
+
puts "Write: #{ path }/#{ order }/#{ page }\n"
|
70
|
+
File.open(outfile, 'w') do |output|
|
71
|
+
wrapped = GitObjectBrowser::Models::WrappedObject.new(nil, path, obj)
|
72
|
+
output << JSON.pretty_generate(wrapped.to_hash)
|
73
|
+
end
|
74
|
+
|
75
|
+
if order == 'offset'
|
76
|
+
dumper = GitObjectBrowser::Dumper::PackedObjectsDumper.new(@root, @outdir)
|
77
|
+
dumper.dump(packpath, obj)
|
78
|
+
end
|
79
|
+
page += 1
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|