amp-git 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +45 -0
- data/VERSION +1 -1
- data/lib/amp-git.rb +34 -44
- data/lib/amp-git/amp_plugin.rb +16 -0
- data/lib/amp-git/encoding/binary_delta.rb +5 -4
- data/lib/amp-git/repo_format/changeset.rb +6 -6
- data/lib/amp-git/repo_format/commit_object.rb +2 -2
- data/lib/amp-git/repo_format/index.rb +1 -0
- data/lib/amp-git/repo_format/node_id.rb +15 -0
- data/lib/amp-git/repo_format/packfile.rb +6 -7
- data/lib/amp-git/repo_format/packfile_index.rb +2 -2
- data/lib/amp-git/repo_format/tag_object.rb +1 -1
- data/lib/amp-git/repo_format/tree_object.rb +1 -1
- data/spec/repo_format/node_id_spec.rb +48 -0
- data/spec/repo_format/spec_helper.rb +1 -0
- data/spec/spec_helper.rb +0 -2
- data/test/index_tests/test_index.rb +1 -1
- data/test/packfile_tests/test_packfile.rb +6 -6
- data/test/packfile_tests/test_packfile_index_v2.rb +1 -1
- data/test/packfile_tests/test_packfile_with_index.rb +6 -6
- data/test/test_commit_object.rb +3 -3
- data/test/test_helper.rb +2 -10
- data/test/test_tag_object.rb +2 -2
- data/test/test_tree_object.rb +3 -4
- metadata +10 -4
- data/lib/amp_plugin.rb +0 -1
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
remote: http://gems.github.com/
|
4
|
+
specs:
|
5
|
+
amp-core (0.1.0)
|
6
|
+
amp-front (0.1.0)
|
7
|
+
builder (2.1.2)
|
8
|
+
cucumber (0.9.4)
|
9
|
+
builder (~> 2.1.2)
|
10
|
+
diff-lcs (~> 1.1.2)
|
11
|
+
gherkin (~> 2.2.9)
|
12
|
+
json (~> 1.4.6)
|
13
|
+
term-ansicolor (~> 1.0.5)
|
14
|
+
devver-construct (1.1.0)
|
15
|
+
diff-lcs (1.1.2)
|
16
|
+
gemcutter (0.6.1)
|
17
|
+
gherkin (2.2.9)
|
18
|
+
json (~> 1.4.6)
|
19
|
+
term-ansicolor (~> 1.0.5)
|
20
|
+
git (1.2.5)
|
21
|
+
jeweler (1.4.0)
|
22
|
+
gemcutter (>= 0.1.0)
|
23
|
+
git (>= 1.2.5)
|
24
|
+
rubyforge (>= 2.0.0)
|
25
|
+
json (1.4.6)
|
26
|
+
json_pure (1.4.6)
|
27
|
+
minitest (1.7.2)
|
28
|
+
rspec (1.3.1)
|
29
|
+
rubyforge (2.0.4)
|
30
|
+
json_pure (>= 1.1.7)
|
31
|
+
term-ansicolor (1.0.5)
|
32
|
+
yard (0.6.1)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
amp-core (>= 0.1.0)
|
39
|
+
amp-front (>= 0.1.0)
|
40
|
+
cucumber
|
41
|
+
devver-construct
|
42
|
+
jeweler
|
43
|
+
minitest
|
44
|
+
rspec (< 2.0.0)
|
45
|
+
yard
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/amp-git.rb
CHANGED
@@ -1,49 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
puts 'Loading amp-git...'
|
2
|
+
|
3
|
+
require 'zlib'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
# Must require the GitPicker or it won't be found.
|
7
|
+
require 'amp-git/repository.rb'
|
8
|
+
|
9
|
+
module Amp
|
10
|
+
module Git
|
11
|
+
autoload :Changeset, 'amp-git/repo_format/changeset.rb'
|
12
|
+
autoload :WorkingDirectoryChangeset, 'amp-git/repo_format/changeset.rb'
|
13
|
+
autoload :VersionedFile, 'amp-git/repo_format/versioned_file.rb'
|
14
|
+
autoload :VersionedWorkingFile, 'amp-git/repo_format/versioned_file.rb'
|
15
|
+
end
|
16
|
+
module Core
|
17
|
+
module Repositories
|
4
18
|
module Git
|
5
|
-
|
6
|
-
autoload :
|
7
|
-
autoload :
|
8
|
-
autoload :
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
autoload :TagObject, "amp-git/repo_format/tag_object.rb"
|
22
|
-
autoload :PackFile, "amp-git/repo_format/packfile.rb"
|
23
|
-
autoload :PackFileIndex, "amp-git/repo_format/packfile_index.rb"
|
24
|
-
autoload :PackFileIndexV1, "amp-git/repo_format/packfile_index.rb"
|
25
|
-
autoload :PackFileIndexV2, "amp-git/repo_format/packfile_index.rb"
|
26
|
-
autoload :Index, "amp-git/repo_format/index.rb"
|
27
|
-
module Encoding
|
28
|
-
autoload :BinaryDelta, "amp-git/encoding/binary_delta.rb"
|
29
|
-
end
|
30
|
-
end
|
19
|
+
include Support
|
20
|
+
autoload :LocalRepository, 'amp-git/repositories/local_repository.rb'
|
21
|
+
autoload :NodeId, 'amp-git/repo_format/node_id.rb'
|
22
|
+
autoload :StagingArea, 'amp-git/repo_format/staging_area.rb'
|
23
|
+
autoload :RawObject, 'amp-git/repo_format/raw_object.rb'
|
24
|
+
autoload :LooseObject, 'amp-git/repo_format/loose_object.rb'
|
25
|
+
autoload :TreeObject, 'amp-git/repo_format/tree_object.rb'
|
26
|
+
autoload :CommitObject, 'amp-git/repo_format/commit_object.rb'
|
27
|
+
autoload :TagObject, 'amp-git/repo_format/tag_object.rb'
|
28
|
+
autoload :PackFile, 'amp-git/repo_format/packfile.rb'
|
29
|
+
autoload :PackFileIndex, 'amp-git/repo_format/packfile_index.rb'
|
30
|
+
autoload :PackFileIndexV1, 'amp-git/repo_format/packfile_index.rb'
|
31
|
+
autoload :PackFileIndexV2, 'amp-git/repo_format/packfile_index.rb'
|
32
|
+
autoload :Index, 'amp-git/repo_format/index.rb'
|
33
|
+
module Encoding
|
34
|
+
autoload :BinaryDelta, 'amp-git/encoding/binary_delta.rb'
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
34
|
-
require 'zlib'
|
35
|
-
require 'stringio'
|
36
|
-
}
|
37
|
-
class << self
|
38
|
-
attr_reader :loader
|
39
|
-
end
|
40
|
-
def initialize(opts = {})
|
41
|
-
@opts = opts
|
42
|
-
end
|
43
|
-
|
44
|
-
def load!
|
45
|
-
puts "Loading amp-git..."
|
46
|
-
require 'zlib'
|
47
|
-
self.class.loader.call
|
48
38
|
end
|
49
|
-
end
|
39
|
+
end
|
@@ -59,6 +59,7 @@ module Amp
|
|
59
59
|
raise DeltaError.new("Expected input data to be #{@base_length} bytes, but was #{original.size} bytes.")
|
60
60
|
end
|
61
61
|
output = StringIO.new
|
62
|
+
output.string.force_encoding('BINARY') if output.string.respond_to?(:force_encoding)
|
62
63
|
@hunks.each do |hunk|
|
63
64
|
hunk.apply(output, original)
|
64
65
|
end
|
@@ -80,7 +81,7 @@ module Amp
|
|
80
81
|
def read_little_endian_base128(fp)
|
81
82
|
result = shift = 0
|
82
83
|
begin
|
83
|
-
byte = Support::
|
84
|
+
byte = Support::HexString.from_bin(fp.read(1)).ord
|
84
85
|
result |= (byte & 0x7f) << shift
|
85
86
|
shift += 7
|
86
87
|
end while byte & 0x80 > 0
|
@@ -95,7 +96,7 @@ module Amp
|
|
95
96
|
# a copy from an input stream, or an "insert" which inserts specified
|
96
97
|
# data.
|
97
98
|
def self.parse(fp)
|
98
|
-
opcode = Support::
|
99
|
+
opcode = Support::HexString.from_bin(fp.read(1)).ord
|
99
100
|
if opcode & 0x80 == 0
|
100
101
|
InsertHunk.new(opcode, fp)
|
101
102
|
else
|
@@ -140,13 +141,13 @@ module Amp
|
|
140
141
|
@offset = @length = 0
|
141
142
|
shift = 0
|
142
143
|
0.upto(3) do
|
143
|
-
@offset |= Support::
|
144
|
+
@offset |= Support::HexString.from_bin(fp.read(1)).ord << shift if opcode & 0x01 > 0
|
144
145
|
opcode >>= 1
|
145
146
|
shift += 8
|
146
147
|
end
|
147
148
|
shift = 0
|
148
149
|
0.upto(2) do
|
149
|
-
@length |= Support::
|
150
|
+
@length |= Support::HexString.from_bin(fp.read(1)).ord << shift if opcode & 0x01 > 0
|
150
151
|
opcode >>= 1
|
151
152
|
shift += 8
|
152
153
|
end
|
@@ -28,14 +28,14 @@ module Amp
|
|
28
28
|
attr_reader :revision
|
29
29
|
alias_method :repository, :repo
|
30
30
|
|
31
|
-
def initialize(repo,
|
31
|
+
def initialize(repo, short_name)
|
32
32
|
@repo = repo
|
33
33
|
if short_name.kind_of?(Integer)
|
34
|
-
@revision =
|
35
|
-
@node_id = convert_rev_to_node(
|
34
|
+
@revision = short_name
|
35
|
+
@node_id = convert_rev_to_node(short_name)
|
36
36
|
else
|
37
|
-
@revision = convert_node_to_rev(
|
38
|
-
@node_id =
|
37
|
+
@revision = convert_node_to_rev(short_name)
|
38
|
+
@node_id = short_name
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -200,7 +200,7 @@ module Amp
|
|
200
200
|
|
201
201
|
end
|
202
202
|
|
203
|
-
class WorkingDirectoryChangeset < Amp::Repositories::AbstractChangeset
|
203
|
+
class WorkingDirectoryChangeset < Amp::Core::Repositories::AbstractChangeset
|
204
204
|
|
205
205
|
attr_accessor :repo
|
206
206
|
alias_method :repository, :repo
|
@@ -63,9 +63,9 @@ module Amp
|
|
63
63
|
lines.each_with_index do |line, idx|
|
64
64
|
case line
|
65
65
|
when /^tree (.{40})/
|
66
|
-
@tree_ref =
|
66
|
+
@tree_ref = NodeId.from_hex($1)
|
67
67
|
when /^parent (.{40})/
|
68
|
-
@parent_refs <<
|
68
|
+
@parent_refs << NodeId.from_hex($1)
|
69
69
|
when /^author #{AUTHOR_MATCH}/
|
70
70
|
@author = "#{$1} <#{$2}>"
|
71
71
|
@date = Time.at($3.to_i)
|
@@ -91,6 +91,7 @@ module Amp
|
|
91
91
|
header = fp.read(ENTRY_HEADER_SIZE).unpack(ENTRY_HEADER_FORMAT)
|
92
92
|
self.ctime, self.ctime_ns, self.mtime, self.mtime_ns, self.dev, self.inode,
|
93
93
|
self.mode, self.uid, self.gid, self.size, self.hash_id, flags = header
|
94
|
+
self.hash_id = NodeId.from_bin(self.hash_id)
|
94
95
|
self.assume_valid = flags & 0x8000 > 0
|
95
96
|
self.update_needed = flags & 0x4000 > 0
|
96
97
|
self.stage = (flags & 0x3000) >> 12
|
@@ -0,0 +1,15 @@
|
|
1
|
+
##################################################################
|
2
|
+
# Licensing Information #
|
3
|
+
# #
|
4
|
+
# The following code is licensed, as standalone code, under #
|
5
|
+
# the Ruby License, unless otherwise directed within the code. #
|
6
|
+
# #
|
7
|
+
# For information on the license of this code when distributed #
|
8
|
+
# with and used in conjunction with the other modules in the #
|
9
|
+
# Amp project, please see the root-level LICENSE file. #
|
10
|
+
# #
|
11
|
+
##################################################################
|
12
|
+
|
13
|
+
module Amp::Core::Repositories::Git
|
14
|
+
NodeId = Amp::Core::Support::HexString
|
15
|
+
end
|
@@ -96,10 +96,10 @@ module Amp
|
|
96
96
|
# @param [IO, #read] fp the IO stream to read from
|
97
97
|
# @return [Integer] the offset read
|
98
98
|
def read_offset(fp)
|
99
|
-
byte = Support::
|
99
|
+
byte = Support::HexString.from_bin(fp.read(1)).ord
|
100
100
|
tot = byte & 0x7f
|
101
101
|
while (byte & 0x80) > 0
|
102
|
-
byte = Support::
|
102
|
+
byte = Support::HexString.from_bin(fp.read(1)).ord
|
103
103
|
tot = ((tot + 1) << 7) | (byte & 0x7f)
|
104
104
|
break if (byte & 0x80) == 0
|
105
105
|
end
|
@@ -114,12 +114,12 @@ module Amp
|
|
114
114
|
# @return [Array(Integer, Integer)] the type and size of the entry packed
|
115
115
|
# into a tuple.
|
116
116
|
def read_header(fp)
|
117
|
-
tags = Support::
|
117
|
+
tags = Support::HexString.from_bin(fp.read(1)).ord
|
118
118
|
type = (tags & 0x70) >> 4
|
119
119
|
size = tags & 0xF
|
120
120
|
shift = 4
|
121
121
|
while tags & 0x80 > 0
|
122
|
-
tags = Support::
|
122
|
+
tags = Support::HexString.from_bin(fp.read(1)).ord
|
123
123
|
size += (tags & 0x7F) << shift
|
124
124
|
shift += 7
|
125
125
|
end
|
@@ -161,8 +161,7 @@ module Amp
|
|
161
161
|
def calculate_hash!
|
162
162
|
prefix = PREFIX_NAME_LOOKUP[self.type]
|
163
163
|
# add special cases for refs
|
164
|
-
self.hash_id =
|
165
|
-
self.hash_id.force_encoding("ASCII-8BIT") if RUBY_VERSION >= "1.9"
|
164
|
+
self.hash_id = NodeId.sha1("#{prefix} #{self.size}\0#{self.content}")
|
166
165
|
end
|
167
166
|
|
168
167
|
##
|
@@ -238,7 +237,7 @@ module Amp
|
|
238
237
|
# packfile.
|
239
238
|
def object_for_hash(given_hash)
|
240
239
|
@opener.open(name, "r") do |fp|
|
241
|
-
given_hash.force_encoding("ASCII-8BIT") if
|
240
|
+
given_hash.force_encoding("ASCII-8BIT") if given_hash.respond_to?(:force_encoding)
|
242
241
|
entry = nil
|
243
242
|
if index
|
244
243
|
starting_at = index.offset_for_hash(given_hash)
|
@@ -83,7 +83,7 @@ module Amp
|
|
83
83
|
# uses fanout logic to determine the indices in which the desired
|
84
84
|
# hash might be found. This range can be searched to find the hash.
|
85
85
|
def search_range_for_hash(hash)
|
86
|
-
byte = Support::
|
86
|
+
byte = Support::HexString.from_bin(hash).ord
|
87
87
|
min = byte > 0 ? (fanout[byte - 1]) : 0
|
88
88
|
max = fanout[byte]
|
89
89
|
min...max
|
@@ -162,7 +162,7 @@ module Amp
|
|
162
162
|
# TODO: binary search!
|
163
163
|
range.each do |idx|
|
164
164
|
sha1 = @fp.read(SHA1_SIZE).unpack(SHA1_FORMAT).first # sha1s are 20 bytes
|
165
|
-
return offset_for_index(idx) if sha1 == hsh
|
165
|
+
return offset_for_index(idx) if sha1 == hsh.to_bin
|
166
166
|
end
|
167
167
|
raise PackFileIndexLookupError.new("Couldn't find the hash #{hsh.inspect} in the packfile index.")
|
168
168
|
end
|
@@ -86,7 +86,7 @@ module Amp
|
|
86
86
|
scanner = StringScanner.new(@content)
|
87
87
|
until scanner.eos?
|
88
88
|
break unless scanner.scan(/(\d+) (\S+?)\x00(.{20})/m)
|
89
|
-
new_entry = TreeEntry.new(scanner[2], scanner[1].to_i(8), scanner[3])
|
89
|
+
new_entry = TreeEntry.new(scanner[2], scanner[1].to_i(8), NodeId.from_bin(scanner[3]))
|
90
90
|
@pairs[new_entry.name] = new_entry
|
91
91
|
end
|
92
92
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
##################################################################
|
2
|
+
# Licensing Information #
|
3
|
+
# #
|
4
|
+
# The following code is licensed, as standalone code, under #
|
5
|
+
# the Ruby License, unless otherwise directed within the code. #
|
6
|
+
# #
|
7
|
+
# For information on the license of this code when distributed #
|
8
|
+
# with and used in conjunction with the other modules in the #
|
9
|
+
# Amp project, please see the root-level LICENSE file. #
|
10
|
+
# #
|
11
|
+
##################################################################
|
12
|
+
|
13
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
14
|
+
|
15
|
+
describe Amp::Core::Repositories::Git::NodeId do
|
16
|
+
Subject = Amp::Core::Repositories::Git::NodeId
|
17
|
+
it 'created from binary' do
|
18
|
+
Subject.from_bin('A').should be
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'created from hex' do
|
22
|
+
Subject.from_hex('41').should be
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'created from sha1' do
|
26
|
+
Subject.sha1('A').should be
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'is compareable' do
|
30
|
+
Subject.from_bin('A').should == Subject.from_bin('A')
|
31
|
+
end
|
32
|
+
|
33
|
+
let :single do
|
34
|
+
Subject.from_bin('A')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'can be represented as binary' do
|
38
|
+
single.to_bin.should == 'A'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'can be represented as hex' do
|
42
|
+
single.to_hex.should == '41'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'stringifies as hex' do
|
46
|
+
single.to_s.should == '41'
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
data/spec/spec_helper.rb
CHANGED
@@ -60,7 +60,7 @@ class TestGitIndex < AmpTestCase
|
|
60
60
|
assert_equal 0x01f5, rakefile_info.uid
|
61
61
|
assert_equal 0x14, rakefile_info.gid
|
62
62
|
assert_equal 0x05c5, rakefile_info.size
|
63
|
-
assert_equal "53bbb0b38868a1bd2059a1174f54de63764013af",
|
63
|
+
assert_equal "53bbb0b38868a1bd2059a1174f54de63764013af", rakefile_info.hash_id.to_hex
|
64
64
|
assert_false rakefile_info.assume_valid
|
65
65
|
assert_false rakefile_info.update_needed
|
66
66
|
assert_equal 0, rakefile_info.stage
|
@@ -46,11 +46,11 @@ class TestPackfile < AmpTestCase
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_commit_lookup
|
49
|
-
some_commit_obj = @packfile.object_for_hash(
|
49
|
+
some_commit_obj = @packfile.object_for_hash(NodeId.from_hex("862a669a8ddf39a4c60be6bd40c97dc242b6128e"))
|
50
50
|
assert_not_nil some_commit_obj
|
51
51
|
assert_kind_of CommitObject, some_commit_obj
|
52
|
-
assert_equal "2ac9f8fa1628a094cced3534b63084d5f480d10a",
|
53
|
-
assert_equal ["840c43e100120cd282cf9b334b08aa5fbe2634a0"], some_commit_obj.parent_refs
|
52
|
+
assert_equal NodeId.from_hex("2ac9f8fa1628a094cced3534b63084d5f480d10a"), some_commit_obj.tree_ref
|
53
|
+
assert_equal [NodeId.from_hex("840c43e100120cd282cf9b334b08aa5fbe2634a0")], some_commit_obj.parent_refs
|
54
54
|
assert_equal "Michael Edgar <michael.j.edgar@dartmouth.edu>", some_commit_obj.author
|
55
55
|
assert_equal "Michael Edgar <michael.j.edgar@dartmouth.edu>", some_commit_obj.committer
|
56
56
|
assert_equal Time.at(1273260273), some_commit_obj.date
|
@@ -59,16 +59,16 @@ class TestPackfile < AmpTestCase
|
|
59
59
|
|
60
60
|
# The previous test gets the first commit. no searching going on. This gets a further one.
|
61
61
|
def test_further_lookup
|
62
|
-
some_commit_obj = @packfile.object_for_hash(
|
62
|
+
some_commit_obj = @packfile.object_for_hash(NodeId.from_hex("958cd2af1c2676e9e90c7ea45bfe384acdcf42e0"))
|
63
63
|
assert_not_nil some_commit_obj
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_tree_lookup
|
67
|
-
some_tree_obj = @packfile.object_for_hash(
|
67
|
+
some_tree_obj = @packfile.object_for_hash(NodeId.from_hex("2ac9f8fa1628a094cced3534b63084d5f480d10a"))
|
68
68
|
assert_not_nil some_tree_obj
|
69
69
|
entry_names = %w(.document .gitignore LICENSE README.md Rakefile VERSION lib spec yard-struct.gemspec).sort
|
70
70
|
assert_equal entry_names, some_tree_obj.entry_names.sort
|
71
|
-
lookedup_entry = TreeObject::TreeEntry.new("Rakefile", 0100644,
|
71
|
+
lookedup_entry = TreeObject::TreeEntry.new("Rakefile", 0100644, NodeId.from_hex("53bbb0b38868a1bd2059a1174f54de63764013af"))
|
72
72
|
assert_equal lookedup_entry, some_tree_obj.tree_lookup("Rakefile")
|
73
73
|
end
|
74
74
|
|
@@ -84,7 +84,7 @@ class TestPackfileIndexV2 < AmpTestCase
|
|
84
84
|
["004EB28B17D7FC33C7B90D2B37E79566038E29C1", 0x001a82fe],
|
85
85
|
["00D917561EB69F243B326DAAA13F7C09D505DB9C", 0x0003518e]]
|
86
86
|
pairs.each do |hsh, expected|
|
87
|
-
assert_equal expected, @index.offset_for_hash(
|
87
|
+
assert_equal expected, @index.offset_for_hash(NodeId.from_hex(hsh))
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -47,11 +47,11 @@ class TestPackfileWithIndex < AmpTestCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_commit_lookup
|
50
|
-
some_commit_obj = @packfile.object_for_hash(
|
50
|
+
some_commit_obj = @packfile.object_for_hash(NodeId.from_hex("862a669a8ddf39a4c60be6bd40c97dc242b6128e"))
|
51
51
|
assert_not_nil some_commit_obj
|
52
52
|
assert_kind_of CommitObject, some_commit_obj
|
53
|
-
assert_equal "2ac9f8fa1628a094cced3534b63084d5f480d10a",
|
54
|
-
assert_equal ["840c43e100120cd282cf9b334b08aa5fbe2634a0"], some_commit_obj.parent_refs
|
53
|
+
assert_equal NodeId.from_hex("2ac9f8fa1628a094cced3534b63084d5f480d10a"), some_commit_obj.tree_ref
|
54
|
+
assert_equal [NodeId.from_hex("840c43e100120cd282cf9b334b08aa5fbe2634a0")], some_commit_obj.parent_refs
|
55
55
|
assert_equal "Michael Edgar <michael.j.edgar@dartmouth.edu>", some_commit_obj.author
|
56
56
|
assert_equal "Michael Edgar <michael.j.edgar@dartmouth.edu>", some_commit_obj.committer
|
57
57
|
assert_equal Time.at(1273260273), some_commit_obj.date
|
@@ -60,16 +60,16 @@ class TestPackfileWithIndex < AmpTestCase
|
|
60
60
|
|
61
61
|
# The previous test gets the first commit. no searching going on. This gets a further one.
|
62
62
|
def test_further_lookup
|
63
|
-
some_commit_obj = @packfile.object_for_hash(
|
63
|
+
some_commit_obj = @packfile.object_for_hash(NodeId.from_hex("958cd2af1c2676e9e90c7ea45bfe384acdcf42e0"))
|
64
64
|
assert_not_nil some_commit_obj
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_tree_lookup
|
68
|
-
some_tree_obj = @packfile.object_for_hash(
|
68
|
+
some_tree_obj = @packfile.object_for_hash(NodeId.from_hex("2ac9f8fa1628a094cced3534b63084d5f480d10a"))
|
69
69
|
assert_not_nil some_tree_obj
|
70
70
|
entry_names = %w(.document .gitignore LICENSE README.md Rakefile VERSION lib spec yard-struct.gemspec).sort
|
71
71
|
assert_equal entry_names, some_tree_obj.entry_names.sort
|
72
|
-
lookedup_entry = TreeObject::TreeEntry.new("Rakefile", 0100644,
|
72
|
+
lookedup_entry = TreeObject::TreeEntry.new("Rakefile", 0100644, NodeId.from_hex("53bbb0b38868a1bd2059a1174f54de63764013af"))
|
73
73
|
assert_equal lookedup_entry, some_tree_obj.tree_lookup("Rakefile")
|
74
74
|
end
|
75
75
|
|
data/test/test_commit_object.rb
CHANGED
@@ -23,7 +23,7 @@ class TestGitCommitObject < AmpTestCase
|
|
23
23
|
"Michael Edgar <michael.j.edgar@dartmouth.edu> 1273865360 -0400\n\n"+
|
24
24
|
"Removed the gemspec from the repo\n"
|
25
25
|
@commit_obj = Amp::Core::Repositories::Git::CommitObject.new(
|
26
|
-
Amp::Core::
|
26
|
+
Amp::Core::Repositories::Git::NodeId.sha1(@content), nil, @content)
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_correct_type
|
@@ -35,11 +35,11 @@ class TestGitCommitObject < AmpTestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_tree_ref
|
38
|
-
assert_equal
|
38
|
+
assert_equal NodeId.from_hex("ecb7b4460825bed7c0bc6d17004816d15ae32c5e"), @commit_obj.tree_ref
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_parent_refs
|
42
|
-
assert_equal [
|
42
|
+
assert_equal [NodeId.from_hex("8c27219d73786aa2e91d5ae964624ef36696c307")], @commit_obj.parent_refs
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_author
|
data/test/test_helper.rb
CHANGED
@@ -8,8 +8,6 @@ require 'test/unit'
|
|
8
8
|
require 'minitest/unit'
|
9
9
|
require 'tmpdir'
|
10
10
|
|
11
|
-
Amp::Plugins::Core.new.load!
|
12
|
-
Amp::Plugins::Git.new.load!
|
13
11
|
class AmpTestCase < MiniTest::Unit::TestCase
|
14
12
|
def setup
|
15
13
|
super
|
@@ -27,14 +25,8 @@ class AmpTestCase < MiniTest::Unit::TestCase
|
|
27
25
|
FileUtils.rm_rf @tempdir if defined?(@tempdir) && @tempdir && File.exist?(@tempdir)
|
28
26
|
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def unhexlify(input)
|
35
|
-
Amp::Core::Support::StringUtils.unhexlify(input)
|
36
|
-
end
|
37
|
-
|
28
|
+
NodeId = Amp::Core::Repositories::Git::NodeId unless const_defined?(:NodeId)
|
29
|
+
|
38
30
|
# taken from rubygems
|
39
31
|
def write_file(path)
|
40
32
|
path = File.join(@tempdir, path)
|
data/test/test_tag_object.rb
CHANGED
@@ -33,7 +33,7 @@ nLE/L9aUXdWeTFPron96DLA=
|
|
33
33
|
-----END PGP SIGNATURE-----
|
34
34
|
EOF
|
35
35
|
@tag_obj = Amp::Core::Repositories::Git::TagObject.new(
|
36
|
-
|
36
|
+
NodeId.sha1(@content), nil, @content)
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_correct_type
|
@@ -45,7 +45,7 @@ EOF
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_object
|
48
|
-
assert_equal
|
48
|
+
assert_equal NodeId.from_hex("437b1b20df4b356c9342dac8d38849f24ef44f27"), @tag_obj.object_ref
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_reffed_type
|
data/test/test_tree_object.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
##################################################################
|
2
1
|
# Licensing Information #
|
3
2
|
# #
|
4
3
|
# The following code is licensed, as standalone code, under #
|
@@ -21,7 +20,7 @@ class TestGitTreeObject < AmpTestCase
|
|
21
20
|
"\xE3\xC3\nK\xCD<!\xEA-_\x9E\xDC=40000 examples\x00"+
|
22
21
|
"\xAE\xCB\xE9d!|\xB9\xA6\x96\x024],U\xEE\x99\xA2\xEE\xD4\x92"
|
23
22
|
@tree_obj = Amp::Core::Repositories::Git::TreeObject.new(
|
24
|
-
|
23
|
+
NodeId.sha1(@content), nil,@content)
|
25
24
|
end
|
26
25
|
|
27
26
|
def test_correct_type
|
@@ -47,8 +46,8 @@ class TestGitTreeObject < AmpTestCase
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def test_parses_refs
|
50
|
-
expected_first = "\xD3\xD5\xED\x9DA4_\xE3\xC3\nK\xCD<!\xEA-_\x9E\xDC="
|
51
|
-
expected_second = "\xAE\xCB\xE9d!|\xB9\xA6\x96\x024],U\xEE\x99\xA2\xEE\xD4\x92"
|
49
|
+
expected_first = NodeId.from_bin("\xD3\xD5\xED\x9DA4_\xE3\xC3\nK\xCD<!\xEA-_\x9E\xDC=")
|
50
|
+
expected_second = NodeId.from_bin("\xAE\xCB\xE9d!|\xB9\xA6\x96\x024],U\xEE\x99\xA2\xEE\xD4\x92")
|
52
51
|
assert_equal expected_first, @tree_obj.tree_lookup("example_helper.rb").ref
|
53
52
|
assert_equal expected_second, @tree_obj.tree_lookup("examples").ref
|
54
53
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Michael Edgar
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-11 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- .document
|
124
124
|
- .gitignore
|
125
125
|
- Gemfile
|
126
|
+
- Gemfile.lock
|
126
127
|
- LICENSE
|
127
128
|
- README.rdoc
|
128
129
|
- Rakefile
|
@@ -131,11 +132,13 @@ files:
|
|
131
132
|
- features/step_definitions/amp-git_steps.rb
|
132
133
|
- features/support/env.rb
|
133
134
|
- lib/amp-git.rb
|
135
|
+
- lib/amp-git/amp_plugin.rb
|
134
136
|
- lib/amp-git/encoding/binary_delta.rb
|
135
137
|
- lib/amp-git/repo_format/changeset.rb
|
136
138
|
- lib/amp-git/repo_format/commit_object.rb
|
137
139
|
- lib/amp-git/repo_format/index.rb
|
138
140
|
- lib/amp-git/repo_format/loose_object.rb
|
141
|
+
- lib/amp-git/repo_format/node_id.rb
|
139
142
|
- lib/amp-git/repo_format/packfile.rb
|
140
143
|
- lib/amp-git/repo_format/packfile_index.rb
|
141
144
|
- lib/amp-git/repo_format/raw_object.rb
|
@@ -145,8 +148,9 @@ files:
|
|
145
148
|
- lib/amp-git/repo_format/versioned_file.rb
|
146
149
|
- lib/amp-git/repositories/local_repository.rb
|
147
150
|
- lib/amp-git/repository.rb
|
148
|
-
- lib/amp_plugin.rb
|
149
151
|
- spec/amp-git_spec.rb
|
152
|
+
- spec/repo_format/node_id_spec.rb
|
153
|
+
- spec/repo_format/spec_helper.rb
|
150
154
|
- spec/repository_spec.rb
|
151
155
|
- spec/spec.opts
|
152
156
|
- spec/spec_helper.rb
|
@@ -199,6 +203,8 @@ specification_version: 3
|
|
199
203
|
summary: The git plugin for Amp.
|
200
204
|
test_files:
|
201
205
|
- spec/amp-git_spec.rb
|
206
|
+
- spec/repo_format/node_id_spec.rb
|
207
|
+
- spec/repo_format/spec_helper.rb
|
202
208
|
- spec/repository_spec.rb
|
203
209
|
- spec/spec_helper.rb
|
204
210
|
- test/index_tests/test_helper.rb
|
data/lib/amp_plugin.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'amp-git'))
|