rugged 0.17.0.b7 → 0.18.0.b1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +88 -32
- data/ext/rugged/extconf.rb +4 -2
- data/ext/rugged/rugged.c +72 -10
- data/ext/rugged/rugged.h +14 -10
- data/ext/rugged/rugged_blob.c +8 -10
- data/ext/rugged/rugged_branch.c +11 -14
- data/ext/rugged/rugged_commit.c +31 -24
- data/ext/rugged/rugged_config.c +2 -2
- data/ext/rugged/rugged_index.c +133 -198
- data/ext/rugged/rugged_note.c +372 -0
- data/ext/rugged/rugged_object.c +50 -22
- data/ext/rugged/rugged_reference.c +122 -130
- data/ext/rugged/rugged_remote.c +72 -29
- data/ext/rugged/rugged_repo.c +402 -20
- data/ext/rugged/rugged_revwalk.c +7 -3
- data/ext/rugged/rugged_settings.c +110 -0
- data/ext/rugged/rugged_signature.c +23 -7
- data/ext/rugged/rugged_tag.c +32 -16
- data/ext/rugged/rugged_tree.c +44 -15
- data/lib/rugged.rb +1 -0
- data/lib/rugged/index.rb +8 -0
- data/lib/rugged/remote.rb +13 -0
- data/lib/rugged/repository.rb +3 -3
- data/lib/rugged/version.rb +1 -1
- data/test/blob_test.rb +13 -15
- data/test/branch_test.rb +32 -67
- data/test/commit_test.rb +50 -12
- data/test/config_test.rb +12 -11
- data/test/coverage/HEAD.json +1 -1
- data/test/coverage/cover.rb +40 -21
- data/test/errors_test.rb +34 -0
- data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
- data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
- data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
- data/test/fixtures/testrepo.git/logs/refs/notes/commits +1 -0
- data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +1 -0
- data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
- data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +1 -0
- data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
- data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
- data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +3 -0
- data/test/fixtures/testrepo.git/refs/notes/commits +1 -0
- data/test/index_test.rb +65 -69
- data/test/lib_test.rb +76 -11
- data/test/note_test.rb +158 -0
- data/test/object_test.rb +8 -11
- data/test/reference_test.rb +77 -85
- data/test/remote_test.rb +86 -8
- data/test/repo_pack_test.rb +9 -7
- data/test/repo_reset_test.rb +80 -0
- data/test/repo_test.rb +176 -53
- data/test/tag_test.rb +44 -7
- data/test/test_helper.rb +63 -35
- data/test/tree_test.rb +34 -13
- data/test/walker_test.rb +14 -14
- data/vendor/libgit2/Makefile.embed +1 -1
- data/vendor/libgit2/deps/http-parser/http_parser.c +974 -578
- data/vendor/libgit2/deps/http-parser/http_parser.h +106 -70
- data/vendor/libgit2/deps/regex/regcomp.c +7 -6
- data/vendor/libgit2/deps/regex/regex_internal.c +1 -1
- data/vendor/libgit2/deps/regex/regex_internal.h +12 -3
- data/vendor/libgit2/deps/regex/regexec.c +5 -5
- data/vendor/libgit2/include/git2.h +5 -1
- data/vendor/libgit2/include/git2/attr.h +4 -2
- data/vendor/libgit2/include/git2/blob.h +39 -12
- data/vendor/libgit2/include/git2/branch.h +123 -35
- data/vendor/libgit2/include/git2/checkout.h +206 -48
- data/vendor/libgit2/include/git2/clone.h +72 -27
- data/vendor/libgit2/include/git2/commit.h +20 -17
- data/vendor/libgit2/include/git2/common.h +67 -1
- data/vendor/libgit2/include/git2/config.h +81 -60
- data/vendor/libgit2/include/git2/cred_helpers.h +53 -0
- data/vendor/libgit2/include/git2/diff.h +459 -150
- data/vendor/libgit2/include/git2/errors.h +9 -1
- data/vendor/libgit2/include/git2/graph.h +41 -0
- data/vendor/libgit2/include/git2/ignore.h +7 -6
- data/vendor/libgit2/include/git2/index.h +323 -97
- data/vendor/libgit2/include/git2/indexer.h +27 -59
- data/vendor/libgit2/include/git2/inttypes.h +4 -0
- data/vendor/libgit2/include/git2/merge.h +13 -3
- data/vendor/libgit2/include/git2/message.h +14 -8
- data/vendor/libgit2/include/git2/net.h +9 -7
- data/vendor/libgit2/include/git2/notes.h +88 -29
- data/vendor/libgit2/include/git2/object.h +16 -6
- data/vendor/libgit2/include/git2/odb.h +80 -17
- data/vendor/libgit2/include/git2/odb_backend.h +47 -11
- data/vendor/libgit2/include/git2/oid.h +26 -17
- data/vendor/libgit2/include/git2/pack.h +62 -8
- data/vendor/libgit2/include/git2/push.h +131 -0
- data/vendor/libgit2/include/git2/refdb.h +103 -0
- data/vendor/libgit2/include/git2/refdb_backend.h +109 -0
- data/vendor/libgit2/include/git2/reflog.h +30 -21
- data/vendor/libgit2/include/git2/refs.h +215 -193
- data/vendor/libgit2/include/git2/refspec.h +22 -2
- data/vendor/libgit2/include/git2/remote.h +158 -37
- data/vendor/libgit2/include/git2/repository.h +150 -31
- data/vendor/libgit2/include/git2/reset.h +43 -9
- data/vendor/libgit2/include/git2/revparse.h +48 -4
- data/vendor/libgit2/include/git2/revwalk.h +25 -10
- data/vendor/libgit2/include/git2/signature.h +20 -12
- data/vendor/libgit2/include/git2/stash.h +121 -0
- data/vendor/libgit2/include/git2/status.h +122 -53
- data/vendor/libgit2/include/git2/strarray.h +17 -11
- data/vendor/libgit2/include/git2/submodule.h +42 -7
- data/vendor/libgit2/include/git2/tag.h +72 -59
- data/vendor/libgit2/include/git2/threads.h +4 -2
- data/vendor/libgit2/include/git2/trace.h +68 -0
- data/vendor/libgit2/include/git2/transport.h +328 -0
- data/vendor/libgit2/include/git2/tree.h +149 -120
- data/vendor/libgit2/include/git2/types.h +13 -12
- data/vendor/libgit2/include/git2/version.h +3 -3
- data/vendor/libgit2/src/amiga/map.c +2 -2
- data/vendor/libgit2/src/attr.c +58 -48
- data/vendor/libgit2/src/attr.h +4 -18
- data/vendor/libgit2/src/attr_file.c +30 -6
- data/vendor/libgit2/src/attr_file.h +6 -8
- data/vendor/libgit2/src/attrcache.h +24 -0
- data/vendor/libgit2/src/blob.c +30 -7
- data/vendor/libgit2/src/blob.h +1 -1
- data/vendor/libgit2/src/branch.c +361 -68
- data/vendor/libgit2/src/branch.h +17 -0
- data/vendor/libgit2/src/bswap.h +1 -1
- data/vendor/libgit2/src/buf_text.c +291 -0
- data/vendor/libgit2/src/buf_text.h +122 -0
- data/vendor/libgit2/src/buffer.c +27 -101
- data/vendor/libgit2/src/buffer.h +54 -39
- data/vendor/libgit2/src/cache.c +15 -6
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +3 -1
- data/vendor/libgit2/src/checkout.c +1165 -222
- data/vendor/libgit2/src/checkout.h +24 -0
- data/vendor/libgit2/src/clone.c +171 -86
- data/vendor/libgit2/src/commit.c +44 -45
- data/vendor/libgit2/src/commit.h +3 -3
- data/vendor/libgit2/src/commit_list.c +194 -0
- data/vendor/libgit2/src/commit_list.h +49 -0
- data/vendor/libgit2/src/common.h +44 -10
- data/vendor/libgit2/src/compress.c +1 -1
- data/vendor/libgit2/src/compress.h +1 -1
- data/vendor/libgit2/src/config.c +211 -124
- data/vendor/libgit2/src/config.h +23 -4
- data/vendor/libgit2/src/config_cache.c +2 -2
- data/vendor/libgit2/src/config_file.c +129 -53
- data/vendor/libgit2/src/config_file.h +10 -8
- data/vendor/libgit2/src/crlf.c +66 -67
- data/vendor/libgit2/src/date.c +12 -12
- data/vendor/libgit2/src/delta-apply.c +14 -1
- data/vendor/libgit2/src/delta-apply.h +18 -1
- data/vendor/libgit2/src/delta.c +40 -107
- data/vendor/libgit2/src/delta.h +19 -17
- data/vendor/libgit2/src/diff.c +347 -496
- data/vendor/libgit2/src/diff.h +27 -1
- data/vendor/libgit2/src/diff_output.c +564 -249
- data/vendor/libgit2/src/diff_output.h +15 -8
- data/vendor/libgit2/src/diff_tform.c +687 -0
- data/vendor/libgit2/src/errors.c +27 -36
- data/vendor/libgit2/src/fetch.c +13 -351
- data/vendor/libgit2/src/fetch.h +13 -3
- data/vendor/libgit2/src/fetchhead.c +295 -0
- data/vendor/libgit2/src/fetchhead.h +34 -0
- data/vendor/libgit2/src/filebuf.c +42 -15
- data/vendor/libgit2/src/filebuf.h +4 -2
- data/vendor/libgit2/src/fileops.c +466 -113
- data/vendor/libgit2/src/fileops.h +154 -28
- data/vendor/libgit2/src/filter.c +3 -75
- data/vendor/libgit2/src/filter.h +1 -29
- data/vendor/libgit2/src/fnmatch.c +1 -1
- data/vendor/libgit2/src/fnmatch.h +1 -1
- data/vendor/libgit2/src/global.c +54 -10
- data/vendor/libgit2/src/global.h +10 -1
- data/vendor/libgit2/src/graph.c +178 -0
- data/vendor/libgit2/src/hash.c +25 -52
- data/vendor/libgit2/src/hash.h +21 -9
- data/vendor/libgit2/src/{sha1/sha1.c → hash/hash_generic.c} +20 -12
- data/vendor/libgit2/src/hash/hash_generic.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +45 -0
- data/vendor/libgit2/src/hash/hash_win32.c +291 -0
- data/vendor/libgit2/src/hash/hash_win32.h +140 -0
- data/vendor/libgit2/src/hashsig.c +368 -0
- data/vendor/libgit2/src/hashsig.h +72 -0
- data/vendor/libgit2/src/ignore.c +22 -15
- data/vendor/libgit2/src/ignore.h +6 -1
- data/vendor/libgit2/src/index.c +770 -171
- data/vendor/libgit2/src/index.h +13 -5
- data/vendor/libgit2/src/indexer.c +286 -431
- data/vendor/libgit2/src/iterator.c +854 -466
- data/vendor/libgit2/src/iterator.h +134 -109
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +296 -0
- data/vendor/libgit2/src/merge.h +22 -0
- data/vendor/libgit2/src/message.c +1 -1
- data/vendor/libgit2/src/message.h +1 -1
- data/vendor/libgit2/src/mwindow.c +35 -30
- data/vendor/libgit2/src/mwindow.h +2 -2
- data/vendor/libgit2/src/netops.c +162 -98
- data/vendor/libgit2/src/netops.h +50 -15
- data/vendor/libgit2/src/notes.c +109 -58
- data/vendor/libgit2/src/notes.h +2 -1
- data/vendor/libgit2/src/object.c +46 -57
- data/vendor/libgit2/src/object.h +1 -8
- data/vendor/libgit2/src/odb.c +151 -40
- data/vendor/libgit2/src/odb.h +5 -1
- data/vendor/libgit2/src/odb_loose.c +4 -5
- data/vendor/libgit2/src/odb_pack.c +122 -80
- data/vendor/libgit2/src/offmap.h +65 -0
- data/vendor/libgit2/src/oid.c +12 -4
- data/vendor/libgit2/src/oidmap.h +1 -1
- data/vendor/libgit2/src/pack-objects.c +88 -61
- data/vendor/libgit2/src/pack-objects.h +8 -8
- data/vendor/libgit2/src/pack.c +293 -28
- data/vendor/libgit2/src/pack.h +49 -4
- data/vendor/libgit2/src/path.c +103 -14
- data/vendor/libgit2/src/path.h +23 -7
- data/vendor/libgit2/src/pathspec.c +168 -0
- data/vendor/libgit2/src/pathspec.h +40 -0
- data/vendor/libgit2/src/pool.c +29 -4
- data/vendor/libgit2/src/pool.h +8 -1
- data/vendor/libgit2/src/posix.c +26 -27
- data/vendor/libgit2/src/posix.h +2 -3
- data/vendor/libgit2/src/pqueue.c +23 -1
- data/vendor/libgit2/src/pqueue.h +23 -1
- data/vendor/libgit2/src/push.c +653 -0
- data/vendor/libgit2/src/push.h +51 -0
- data/vendor/libgit2/src/refdb.c +185 -0
- data/vendor/libgit2/src/refdb.h +46 -0
- data/vendor/libgit2/src/refdb_fs.c +1024 -0
- data/vendor/libgit2/src/refdb_fs.h +15 -0
- data/vendor/libgit2/src/reflog.c +77 -45
- data/vendor/libgit2/src/reflog.h +1 -3
- data/vendor/libgit2/src/refs.c +366 -1326
- data/vendor/libgit2/src/refs.h +22 -13
- data/vendor/libgit2/src/refspec.c +46 -7
- data/vendor/libgit2/src/refspec.h +11 -1
- data/vendor/libgit2/src/remote.c +758 -120
- data/vendor/libgit2/src/remote.h +10 -5
- data/vendor/libgit2/src/repo_template.h +6 -6
- data/vendor/libgit2/src/repository.c +315 -96
- data/vendor/libgit2/src/repository.h +5 -3
- data/vendor/libgit2/src/reset.c +99 -81
- data/vendor/libgit2/src/revparse.c +157 -84
- data/vendor/libgit2/src/revwalk.c +68 -470
- data/vendor/libgit2/src/revwalk.h +44 -0
- data/vendor/libgit2/src/sha1_lookup.c +1 -1
- data/vendor/libgit2/src/sha1_lookup.h +1 -1
- data/vendor/libgit2/src/signature.c +68 -200
- data/vendor/libgit2/src/signature.h +1 -1
- data/vendor/libgit2/src/stash.c +663 -0
- data/vendor/libgit2/src/status.c +101 -79
- data/vendor/libgit2/src/strmap.h +1 -1
- data/vendor/libgit2/src/submodule.c +67 -51
- data/vendor/libgit2/src/submodule.h +1 -1
- data/vendor/libgit2/src/tag.c +35 -29
- data/vendor/libgit2/src/tag.h +1 -1
- data/vendor/libgit2/src/thread-utils.c +1 -1
- data/vendor/libgit2/src/thread-utils.h +2 -2
- data/vendor/libgit2/src/trace.c +39 -0
- data/vendor/libgit2/src/trace.h +56 -0
- data/vendor/libgit2/src/transport.c +81 -34
- data/vendor/libgit2/src/transports/cred.c +60 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +49 -0
- data/vendor/libgit2/src/transports/git.c +234 -127
- data/vendor/libgit2/src/transports/http.c +761 -433
- data/vendor/libgit2/src/transports/local.c +460 -64
- data/vendor/libgit2/src/transports/smart.c +345 -0
- data/vendor/libgit2/src/transports/smart.h +179 -0
- data/vendor/libgit2/src/{pkt.c → transports/smart_pkt.c} +131 -12
- data/vendor/libgit2/src/transports/smart_protocol.c +856 -0
- data/vendor/libgit2/src/transports/winhttp.c +1136 -0
- data/vendor/libgit2/src/tree-cache.c +2 -2
- data/vendor/libgit2/src/tree-cache.h +1 -1
- data/vendor/libgit2/src/tree.c +239 -166
- data/vendor/libgit2/src/tree.h +11 -2
- data/vendor/libgit2/src/tsort.c +39 -23
- data/vendor/libgit2/src/unix/map.c +1 -1
- data/vendor/libgit2/src/unix/posix.h +12 -2
- data/vendor/libgit2/src/unix/realpath.c +30 -0
- data/vendor/libgit2/src/util.c +250 -13
- data/vendor/libgit2/src/util.h +71 -14
- data/vendor/libgit2/src/vector.c +123 -60
- data/vendor/libgit2/src/vector.h +24 -22
- data/vendor/libgit2/src/win32/dir.c +1 -1
- data/vendor/libgit2/src/win32/dir.h +1 -1
- data/vendor/libgit2/src/win32/error.c +77 -0
- data/vendor/libgit2/src/win32/error.h +13 -0
- data/vendor/libgit2/src/win32/findfile.c +143 -54
- data/vendor/libgit2/src/win32/findfile.h +10 -6
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/mingw-compat.h +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +10 -1
- data/vendor/libgit2/src/win32/posix.h +10 -1
- data/vendor/libgit2/src/win32/posix_w32.c +132 -63
- data/vendor/libgit2/src/win32/precompiled.c +1 -1
- data/vendor/libgit2/src/win32/pthread.c +1 -1
- data/vendor/libgit2/src/win32/pthread.h +1 -1
- data/vendor/libgit2/src/win32/utf-conv.c +5 -5
- data/vendor/libgit2/src/win32/utf-conv.h +3 -3
- data/vendor/libgit2/src/win32/version.h +20 -0
- metadata +308 -252
- data/test/fixtures/testrepo.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/test/fixtures/testrepo.git/objects/7f/043268ea43ce18e3540acaabf9e090c91965b0 +0 -0
- data/test/fixtures/testrepo.git/objects/a3/e05719b428a2d0ed7a55c4ce53dcc5768c6d5e +0 -0
- data/test/index_test.rb~ +0 -218
- data/vendor/libgit2/src/pkt.h +0 -91
- data/vendor/libgit2/src/ppc/sha1.c +0 -70
- data/vendor/libgit2/src/ppc/sha1.h +0 -26
- data/vendor/libgit2/src/protocol.c +0 -110
- data/vendor/libgit2/src/protocol.h +0 -21
- data/vendor/libgit2/src/sha1.h +0 -33
- data/vendor/libgit2/src/transport.h +0 -148
data/test/note_test.rb
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class NoteTest < Rugged::TestCase
|
4
|
+
include Rugged::RepositoryAccess
|
5
|
+
|
6
|
+
def test_read_note_for_object
|
7
|
+
oid = "36060c58702ed4c2a40832c51758d5344201d89a"
|
8
|
+
obj = @repo.lookup(oid)
|
9
|
+
notes = obj.notes
|
10
|
+
assert_equal "note text\n", notes[:message]
|
11
|
+
assert_equal "94eca2de348d5f672faf56b0decafa5937e3235e", notes[:oid]
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_read_note_for_object_from_ref
|
15
|
+
oid = "36060c58702ed4c2a40832c51758d5344201d89a"
|
16
|
+
obj = @repo.lookup(oid)
|
17
|
+
notes = obj.notes('refs/notes/commits')
|
18
|
+
assert_equal "note text\n", notes[:message]
|
19
|
+
assert_equal "94eca2de348d5f672faf56b0decafa5937e3235e", notes[:oid]
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_object_without_note
|
23
|
+
oid = "8496071c1b46c854b31185ea97743be6a8774479"
|
24
|
+
obj = @repo.lookup(oid)
|
25
|
+
assert_nil obj.notes
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_nil_ref_lookup
|
29
|
+
oid = "36060c58702ed4c2a40832c51758d5344201d89a"
|
30
|
+
obj = @repo.lookup(oid)
|
31
|
+
assert_nil obj.notes('refs/notes/missing')
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_iterate_over_notes
|
35
|
+
@repo.each_note('refs/notes/commits') do |note_blob, annotated_object|
|
36
|
+
assert_equal "note text\n", note_blob.content
|
37
|
+
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", annotated_object.oid
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_each_note_enumerable
|
42
|
+
enum = @repo.each_note('refs/notes/commits')
|
43
|
+
assert enum.kind_of? Enumerable
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_default_ref
|
47
|
+
assert_equal 'refs/notes/commits', @repo.default_notes_ref
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class NoteWriteTest < Rugged::TestCase
|
52
|
+
include Rugged::TempRepositoryAccess
|
53
|
+
|
54
|
+
def test_create_note
|
55
|
+
person = {:name => 'Scott', :email => 'schacon@gmail.com', :time => Time.now }
|
56
|
+
|
57
|
+
oid = "8496071c1b46c854b31185ea97743be6a8774479"
|
58
|
+
message ="This is the note message\n\nThis note is created from Rugged"
|
59
|
+
obj = @repo.lookup(oid)
|
60
|
+
|
61
|
+
note_oid = obj.create_note(
|
62
|
+
:message => message,
|
63
|
+
:committer => person,
|
64
|
+
:author => person,
|
65
|
+
:ref => 'refs/notes/test'
|
66
|
+
)
|
67
|
+
|
68
|
+
assert_equal '38c3a690c474d8dcdb13088205a464a60312eec4', note_oid
|
69
|
+
# note is actually a blob
|
70
|
+
blob = @repo.lookup(note_oid)
|
71
|
+
assert_equal blob.oid, note_oid
|
72
|
+
assert_equal blob.content, message
|
73
|
+
assert_equal blob.type, :blob
|
74
|
+
|
75
|
+
note = obj.notes('refs/notes/test')
|
76
|
+
assert_equal note[:oid], note_oid
|
77
|
+
assert_equal note[:message], message
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_create_note_on_object_with_notes_raises
|
81
|
+
person = {:name => 'Scott', :email => 'schacon@gmail.com', :time => Time.now }
|
82
|
+
oid = "8496071c1b46c854b31185ea97743be6a8774479"
|
83
|
+
message ="This is the note message\n\nThis note is created from Rugged"
|
84
|
+
obj = @repo.lookup(oid)
|
85
|
+
obj.create_note(
|
86
|
+
:message => message,
|
87
|
+
:committer => person,
|
88
|
+
:author => person,
|
89
|
+
:ref => 'refs/notes/test'
|
90
|
+
)
|
91
|
+
|
92
|
+
assert_raises Rugged::RepositoryError do
|
93
|
+
obj.create_note(
|
94
|
+
:message => message,
|
95
|
+
:committer => person,
|
96
|
+
:author => person,
|
97
|
+
:ref => 'refs/notes/test'
|
98
|
+
)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_overwrite_object_note
|
103
|
+
person = {:name => 'Scott', :email => 'schacon@gmail.com', :time => Time.now }
|
104
|
+
oid = "8496071c1b46c854b31185ea97743be6a8774479"
|
105
|
+
message ="This is the note message\n\nThis note is created from Rugged"
|
106
|
+
obj = @repo.lookup(oid)
|
107
|
+
obj.create_note(
|
108
|
+
:message => message,
|
109
|
+
:committer => person,
|
110
|
+
:author => person,
|
111
|
+
:ref => 'refs/notes/test'
|
112
|
+
)
|
113
|
+
|
114
|
+
obj.create_note(
|
115
|
+
:message => 'new message',
|
116
|
+
:committer => person,
|
117
|
+
:author => person,
|
118
|
+
:ref => 'refs/notes/test',
|
119
|
+
:force => true
|
120
|
+
)
|
121
|
+
|
122
|
+
note = obj.notes('refs/notes/test')
|
123
|
+
assert_equal note[:message], 'new message'
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_remove_note
|
127
|
+
oid = "36060c58702ed4c2a40832c51758d5344201d89a"
|
128
|
+
person = {:name => 'Scott', :email => 'schacon@gmail.com', :time => Time.now }
|
129
|
+
message ="This is the note message\n\nThis note is created from Rugged"
|
130
|
+
obj = @repo.lookup(oid)
|
131
|
+
|
132
|
+
obj.create_note(
|
133
|
+
:message => message,
|
134
|
+
:committer => person,
|
135
|
+
:author => person,
|
136
|
+
:ref => 'refs/notes/test'
|
137
|
+
)
|
138
|
+
|
139
|
+
assert obj.remove_note(
|
140
|
+
:committer => person,
|
141
|
+
:author => person,
|
142
|
+
:ref => 'refs/notes/test'
|
143
|
+
)
|
144
|
+
|
145
|
+
assert_nil obj.notes('refs/notes/test')
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_remove_missing_note
|
149
|
+
person = {:name => 'Scott', :email => 'schacon@gmail.com', :time => Time.now }
|
150
|
+
oid = "36060c58702ed4c2a40832c51758d5344201d89a"
|
151
|
+
obj = @repo.lookup(oid)
|
152
|
+
refute obj.remove_note(
|
153
|
+
:committer => person,
|
154
|
+
:author => person,
|
155
|
+
:ref => 'refs/notes/test'
|
156
|
+
)
|
157
|
+
end
|
158
|
+
end
|
data/test/object_test.rb
CHANGED
@@ -1,43 +1,40 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
require 'base64'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
@path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
|
7
|
-
@repo = Rugged::Repository.new(@path)
|
8
|
-
end
|
4
|
+
class ObjectTest < Rugged::TestCase
|
5
|
+
include Rugged::RepositoryAccess
|
9
6
|
|
10
|
-
|
7
|
+
def test_fail_to_lookup_inexistant_object
|
11
8
|
assert_raises Rugged::OdbError do
|
12
9
|
@repo.lookup("a496071c1b46c854b31185ea97743be6a8774479")
|
13
10
|
end
|
14
11
|
end
|
15
12
|
|
16
|
-
|
13
|
+
def test_lookup_object
|
17
14
|
obj = @repo.lookup("8496071c1b46c854b31185ea97743be6a8774479")
|
18
15
|
assert_equal :commit, obj.type
|
19
16
|
assert_equal '8496071c1b46c854b31185ea97743be6a8774479', obj.oid
|
20
17
|
end
|
21
18
|
|
22
|
-
|
19
|
+
def test_objects_are_the_same
|
23
20
|
obj = @repo.lookup("8496071c1b46c854b31185ea97743be6a8774479")
|
24
21
|
obj2 = @repo.lookup("8496071c1b46c854b31185ea97743be6a8774479")
|
25
22
|
assert_equal obj, obj2
|
26
23
|
end
|
27
24
|
|
28
|
-
|
25
|
+
def test_read_raw_data
|
29
26
|
obj = @repo.lookup("8496071c1b46c854b31185ea97743be6a8774479")
|
30
27
|
assert obj.read_raw
|
31
28
|
end
|
32
29
|
|
33
|
-
|
30
|
+
def test_lookup_by_rev
|
34
31
|
obj = @repo.rev_parse("v1.0")
|
35
32
|
assert "0c37a5391bbff43c37f0d0371823a5509eed5b1d", obj.oid
|
36
33
|
obj = @repo.rev_parse("v1.0^1")
|
37
34
|
assert "8496071c1b46c854b31185ea97743be6a8774479", obj.oid
|
38
35
|
end
|
39
36
|
|
40
|
-
|
37
|
+
def test_lookup_oid_by_rev
|
41
38
|
oid = @repo.rev_parse_oid("v1.0")
|
42
39
|
assert "0c37a5391bbff43c37f0d0371823a5509eed5b1d", oid
|
43
40
|
@repo.rev_parse_oid("v1.0^1")
|
data/test/reference_test.rb
CHANGED
@@ -1,63 +1,49 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require File.expand_path "../test_helper", __FILE__
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@path = File.dirname(__FILE__) + '/fixtures/testrepo.git'
|
9
|
-
@repo = Rugged::Repository.new(@path)
|
10
|
-
end
|
4
|
+
class ReferenceTest < Rugged::TestCase
|
5
|
+
include Rugged::RepositoryAccess
|
11
6
|
|
12
|
-
|
13
|
-
FileUtils.remove_entry_secure(@path + '/refs/heads/unit_test', true)
|
14
|
-
FileUtils.remove_entry_secure(@path + "/refs/heads/#{UNICODE_REF_NAME}", true)
|
15
|
-
end
|
16
|
-
|
17
|
-
test "can list references" do
|
18
|
-
refs = @repo.refs.map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
19
|
-
assert_equal "heads/master:heads/packed:tags/v0.9:tags/v1.0", refs
|
20
|
-
end
|
7
|
+
UNICODE_REF_NAME = "A\314\212ngstro\314\210m"
|
21
8
|
|
22
|
-
|
23
|
-
Rugged::Reference.create(@repo, "refs/heads/#{UNICODE_REF_NAME}", "refs/heads/master")
|
9
|
+
def test_list_references
|
24
10
|
refs = @repo.refs.map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
25
|
-
assert_equal "heads
|
11
|
+
assert_equal "heads/master:heads/packed:notes/commits:tags/v0.9:tags/v1.0", refs
|
26
12
|
end
|
27
13
|
|
28
|
-
|
14
|
+
def test_can_filter_refs_with_regex
|
29
15
|
refs = @repo.refs(/tags/).map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
30
16
|
assert_equal "tags/v0.9:tags/v1.0", refs
|
31
17
|
end
|
32
18
|
|
33
|
-
|
19
|
+
def test_can_filter_refs_with_string
|
34
20
|
refs = @repo.refs('0.9').map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
35
21
|
assert_equal "tags/v0.9", refs
|
36
22
|
end
|
37
23
|
|
38
|
-
|
24
|
+
def test_can_open_reference
|
39
25
|
ref = Rugged::Reference.lookup(@repo, "refs/heads/master")
|
40
26
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", ref.target
|
41
27
|
assert_equal :direct, ref.type
|
42
28
|
assert_equal "refs/heads/master", ref.name
|
43
29
|
end
|
44
30
|
|
45
|
-
|
31
|
+
def test_looking_up_missing_ref_returns_nil
|
46
32
|
ref = Rugged::Reference.lookup(@repo, "lol/wut")
|
47
33
|
assert_equal nil, ref
|
48
34
|
end
|
49
35
|
|
50
|
-
|
36
|
+
def test_load_reflog
|
51
37
|
ref = Rugged::Reference.lookup(@repo, "refs/heads/master")
|
52
38
|
log = ref.log
|
53
39
|
e = log[1]
|
54
|
-
assert_equal e[:
|
55
|
-
assert_equal e[:
|
40
|
+
assert_equal e[:id_old], "8496071c1b46c854b31185ea97743be6a8774479"
|
41
|
+
assert_equal e[:id_new], "5b5b025afb0b4c913b4c338a42934a3863bf3644"
|
56
42
|
assert_equal e[:message], "commit: another commit"
|
57
43
|
assert_equal e[:committer][:email], "schacon@gmail.com"
|
58
44
|
end
|
59
45
|
|
60
|
-
|
46
|
+
def test_reference_exists
|
61
47
|
exists = Rugged::Reference.exist?(@repo, "refs/heads/master")
|
62
48
|
assert exists
|
63
49
|
|
@@ -65,14 +51,37 @@ context "Rugged::Reference stuff" do
|
|
65
51
|
assert !exists
|
66
52
|
end
|
67
53
|
|
68
|
-
|
54
|
+
def test_load_packed_ref
|
69
55
|
ref = Rugged::Reference.lookup(@repo, "refs/heads/packed")
|
70
56
|
assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", ref.target
|
71
57
|
assert_equal :direct, ref.type
|
72
58
|
assert_equal "refs/heads/packed", ref.name
|
73
59
|
end
|
74
60
|
|
75
|
-
|
61
|
+
def test_resolve_head
|
62
|
+
ref = Rugged::Reference.lookup(@repo, "HEAD")
|
63
|
+
assert_equal "refs/heads/master", ref.target
|
64
|
+
assert_equal :symbolic, ref.type
|
65
|
+
|
66
|
+
head = ref.resolve
|
67
|
+
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", head.target
|
68
|
+
assert_equal :direct, head.type
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class ReferenceWriteTest < Rugged::TestCase
|
73
|
+
include Rugged::TempRepositoryAccess
|
74
|
+
|
75
|
+
def test_list_unicode_refs
|
76
|
+
Rugged::Reference.create(@repo,
|
77
|
+
"refs/heads/#{ReferenceTest::UNICODE_REF_NAME}",
|
78
|
+
"refs/heads/master")
|
79
|
+
|
80
|
+
refs = @repo.refs.map { |r| r.name.gsub("refs/", '') }
|
81
|
+
assert refs.include? "heads/#{ReferenceTest::UNICODE_REF_NAME}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_create_symbolic_ref
|
76
85
|
ref = Rugged::Reference.create(@repo, "refs/heads/unit_test", "refs/heads/master")
|
77
86
|
assert_equal "refs/heads/master", ref.target
|
78
87
|
assert_equal :symbolic, ref.type
|
@@ -80,101 +89,84 @@ context "Rugged::Reference stuff" do
|
|
80
89
|
ref.delete!
|
81
90
|
end
|
82
91
|
|
83
|
-
|
84
|
-
ref = Rugged::Reference.create(@repo,
|
92
|
+
def test_create_ref_from_oid
|
93
|
+
ref = Rugged::Reference.create(@repo,
|
94
|
+
"refs/heads/unit_test",
|
95
|
+
"36060c58702ed4c2a40832c51758d5344201d89a")
|
96
|
+
|
85
97
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", ref.target
|
86
98
|
assert_equal :direct, ref.type
|
87
99
|
assert_equal "refs/heads/unit_test", ref.name
|
88
100
|
ref.delete!
|
89
101
|
end
|
90
102
|
|
91
|
-
|
92
|
-
ref = Rugged::Reference.create(@repo,
|
103
|
+
def test_rename_ref
|
104
|
+
ref = Rugged::Reference.create(@repo,
|
105
|
+
"refs/heads/unit_test",
|
106
|
+
"36060c58702ed4c2a40832c51758d5344201d89a")
|
107
|
+
|
93
108
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", ref.target
|
94
109
|
assert_equal :direct, ref.type
|
95
110
|
assert_equal "refs/heads/unit_test", ref.name
|
96
111
|
|
97
|
-
ref.rename "refs/heads/rug_new_name"
|
98
|
-
assert_equal "refs/heads/rug_new_name",
|
99
|
-
|
112
|
+
new_ref = ref.rename "refs/heads/rug_new_name"
|
113
|
+
assert_equal "refs/heads/rug_new_name", new_ref.name
|
114
|
+
new_ref.delete!
|
100
115
|
end
|
101
116
|
|
102
|
-
|
103
|
-
ref = Rugged::Reference.create(@repo,
|
117
|
+
def test_set_ref_target
|
118
|
+
ref = Rugged::Reference.create(@repo,
|
119
|
+
"refs/heads/unit_test",
|
120
|
+
"36060c58702ed4c2a40832c51758d5344201d89a")
|
121
|
+
|
104
122
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", ref.target
|
105
123
|
assert_equal :direct, ref.type
|
106
124
|
assert_equal "refs/heads/unit_test", ref.name
|
107
125
|
|
108
|
-
ref.
|
109
|
-
assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644",
|
110
|
-
|
126
|
+
new_ref = ref.set_target "5b5b025afb0b4c913b4c338a42934a3863bf3644"
|
127
|
+
assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644", new_ref.target
|
128
|
+
new_ref.delete!
|
111
129
|
end
|
112
130
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
assert_equal :symbolic, ref.type
|
131
|
+
def test_write_and_read_unicode_refs
|
132
|
+
ref1 = Rugged::Reference.create(@repo, "refs/heads/Ångström", "refs/heads/master")
|
133
|
+
ref2 = Rugged::Reference.create(@repo, "refs/heads/foobar", "refs/heads/Ångström")
|
117
134
|
|
118
|
-
|
119
|
-
assert_equal "
|
120
|
-
assert_equal :direct, head.type
|
135
|
+
assert_equal "refs/heads/Ångström", ref1.name
|
136
|
+
assert_equal "refs/heads/Ångström", ref2.target
|
121
137
|
end
|
122
138
|
end
|
123
139
|
|
124
|
-
|
125
|
-
|
126
|
-
@path = temp_repo 'testrepo.git'
|
127
|
-
@repo = Rugged::Repository.new(@path)
|
128
|
-
end
|
140
|
+
class ReflogTest < Rugged::TestCase
|
141
|
+
include Rugged::TempRepositoryAccess
|
129
142
|
|
130
|
-
|
131
|
-
|
132
|
-
|
143
|
+
def setup
|
144
|
+
super
|
145
|
+
@ref = Rugged::Reference.create(@repo,
|
146
|
+
"refs/heads/test-reflog",
|
147
|
+
"36060c58702ed4c2a40832c51758d5344201d89a")
|
133
148
|
end
|
134
|
-
end
|
135
149
|
|
136
|
-
|
137
|
-
setup do
|
138
|
-
@path = temp_repo 'testrepo.git'
|
139
|
-
@repo = Rugged::Repository.new(@path)
|
140
|
-
end
|
141
|
-
|
142
|
-
it "returns the reference target name with UTF-8 encoding" do
|
143
|
-
Rugged::Reference.create(@repo, "refs/heads/Ångström", "refs/heads/master")
|
144
|
-
|
145
|
-
ref = Rugged::Reference.create(@repo, "refs/heads/foobar", "refs/heads/Ångström")
|
146
|
-
assert_equal "refs/heads/Ångström", ref.target
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "Rugged::Reference#log!" do
|
151
|
-
setup do
|
152
|
-
@path = temp_repo 'testrepo.git'
|
153
|
-
@repo = Rugged::Repository.new(@path)
|
154
|
-
|
155
|
-
@ref = Rugged::Reference.create(@repo, "refs/heads/test-reflog", "36060c58702ed4c2a40832c51758d5344201d89a")
|
156
|
-
end
|
157
|
-
|
158
|
-
it "creates reflog entries" do
|
150
|
+
def test_create_reflog_entries
|
159
151
|
@ref.log!({ :name => "foo", :email => "foo@bar", :time => Time.now })
|
160
152
|
@ref.log!({ :name => "foo", :email => "foo@bar", :time => Time.now }, "commit: bla bla")
|
161
153
|
|
162
154
|
reflog = @ref.log
|
163
155
|
assert_equal reflog.size, 2
|
164
156
|
|
165
|
-
assert_equal reflog[0][:
|
166
|
-
assert_equal reflog[0][:
|
157
|
+
assert_equal reflog[0][:id_old], "0000000000000000000000000000000000000000"
|
158
|
+
assert_equal reflog[0][:id_new], "36060c58702ed4c2a40832c51758d5344201d89a"
|
167
159
|
assert_equal reflog[0][:message], nil
|
168
160
|
assert_equal reflog[0][:committer][:name], "foo"
|
169
161
|
assert_equal reflog[0][:committer][:email], "foo@bar"
|
170
162
|
assert_kind_of Time, reflog[0][:committer][:time]
|
171
163
|
|
172
|
-
assert_equal reflog[1][:
|
173
|
-
assert_equal reflog[1][:
|
164
|
+
assert_equal reflog[1][:id_old], "36060c58702ed4c2a40832c51758d5344201d89a"
|
165
|
+
assert_equal reflog[1][:id_new], "36060c58702ed4c2a40832c51758d5344201d89a"
|
174
166
|
assert_equal reflog[1][:message], "commit: bla bla"
|
175
167
|
assert_equal reflog[1][:committer][:name], "foo"
|
176
168
|
assert_equal reflog[1][:committer][:email], "foo@bar"
|
177
169
|
assert_kind_of Time, reflog[1][:committer][:time]
|
178
|
-
|
179
170
|
end
|
180
171
|
end
|
172
|
+
|