rugged 0.17.0.b7 → 0.18.0.b1
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/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/lib/rugged.rb
CHANGED
data/lib/rugged/index.rb
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Rugged
|
|
2
|
+
class Remote
|
|
3
|
+
# Push a list of refspecs to the given remote.
|
|
4
|
+
#
|
|
5
|
+
# refspecs - A list of refspecs that should be pushed to the remote.
|
|
6
|
+
#
|
|
7
|
+
# Returns a hash containing the pushed refspecs as keys and
|
|
8
|
+
# any error messages or +nil+ as values.
|
|
9
|
+
def push(refspecs)
|
|
10
|
+
@owner.push(self, refspecs)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/rugged/repository.rb
CHANGED
|
@@ -146,13 +146,13 @@ module Rugged
|
|
|
146
146
|
Branch.create(self, name, target)
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
-
# Get the
|
|
149
|
+
# Get the blob at a path for a specific revision.
|
|
150
150
|
#
|
|
151
151
|
# revision - The String SHA1.
|
|
152
152
|
# path - The String file path.
|
|
153
153
|
#
|
|
154
154
|
# Returns a String.
|
|
155
|
-
def
|
|
155
|
+
def blob_at(revision, path)
|
|
156
156
|
tree = Rugged::Commit.lookup(self, revision).tree
|
|
157
157
|
begin
|
|
158
158
|
blob_data = tree.path(path)
|
|
@@ -160,7 +160,7 @@ module Rugged
|
|
|
160
160
|
return nil
|
|
161
161
|
end
|
|
162
162
|
blob = Rugged::Blob.lookup(self, blob_data[:oid])
|
|
163
|
-
(blob.type == :blob) ? blob
|
|
163
|
+
(blob.type == :blob) ? blob : nil
|
|
164
164
|
end
|
|
165
165
|
end
|
|
166
166
|
end
|
data/lib/rugged/version.rb
CHANGED
data/test/blob_test.rb
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
require "test_helper"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
|
|
6
|
-
@repo = Rugged::Repository.new(@path)
|
|
7
|
-
@oid = "fa49b077972391ad58037050f2a75f74e3671e92"
|
|
8
|
-
end
|
|
3
|
+
class BlobTest < Rugged::TestCase
|
|
4
|
+
include Rugged::RepositoryAccess
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
def test_read_blob_data
|
|
7
|
+
oid = "fa49b077972391ad58037050f2a75f74e3671e92"
|
|
8
|
+
blob = @repo.lookup(oid)
|
|
12
9
|
assert_equal 9, blob.size
|
|
13
10
|
assert_equal "new file\n", blob.content
|
|
14
11
|
assert_equal :blob, blob.type
|
|
15
|
-
assert_equal
|
|
12
|
+
assert_equal oid, blob.oid
|
|
16
13
|
end
|
|
14
|
+
end
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
rm_loose(oid)
|
|
21
|
-
end
|
|
16
|
+
class BlobWriteTest < Rugged::TestCase
|
|
17
|
+
include Rugged::TempRepositoryAccess
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
def test_fetch_blob_content_with_nulls
|
|
24
20
|
content = "100644 example_helper.rb\x00\xD3\xD5\xED\x9DA4_"+
|
|
25
21
|
"\xE3\xC3\nK\xCD<!\xEA-_\x9E\xDC=40000 examples\x00"+
|
|
26
22
|
"\xAE\xCB\xE9d!|\xB9\xA6\x96\x024],U\xEE\x99\xA2\xEE\xD4\x92"
|
|
@@ -30,7 +26,9 @@ context "Rugged::Blob tests" do
|
|
|
30
26
|
oid = @repo.write(content, 'tree')
|
|
31
27
|
blob = @repo.lookup(oid)
|
|
32
28
|
assert_equal content, blob.read_raw.data
|
|
33
|
-
rm_loose(oid)
|
|
34
29
|
end
|
|
35
30
|
|
|
31
|
+
def test_write_blob_data
|
|
32
|
+
Rugged::Blob.create(@repo, "a new blob content")
|
|
33
|
+
end
|
|
36
34
|
end
|
data/test/branch_test.rb
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
require "test_helper"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@path = temp_repo("testrepo.git")
|
|
7
|
-
@repo = Rugged::Repository.new(@path)
|
|
8
|
-
end
|
|
4
|
+
class BranchTest < Rugged::TestCase
|
|
5
|
+
include Rugged::TempRepositoryAccess
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
def test_list_all_names
|
|
11
8
|
assert_equal [
|
|
12
9
|
"master",
|
|
13
10
|
"origin/HEAD",
|
|
@@ -16,40 +13,26 @@ context "Rugged::Branch.each_name" do
|
|
|
16
13
|
], Rugged::Branch.each_name(@repo).sort
|
|
17
14
|
end
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
def test_list_only_local_branches
|
|
20
17
|
assert_equal ["master"], Rugged::Branch.each_name(@repo, :local).sort
|
|
21
18
|
end
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
def test_list_only_remote_branches
|
|
24
21
|
assert_equal [
|
|
25
22
|
"origin/HEAD",
|
|
26
23
|
"origin/master",
|
|
27
24
|
"origin/packed",
|
|
28
25
|
], Rugged::Branch.each_name(@repo, :remote).sort
|
|
29
26
|
end
|
|
30
|
-
end
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
setup do
|
|
34
|
-
@path = temp_repo("testrepo.git")
|
|
35
|
-
@repo = Rugged::Repository.new(@path)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
test "returns the latest commit of the branch" do
|
|
28
|
+
def test_get_latest_commit_in_branch
|
|
39
29
|
tip = Rugged::Branch.lookup(@repo, "master").tip
|
|
40
30
|
|
|
41
31
|
assert_kind_of Rugged::Commit, tip
|
|
42
32
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", tip.oid
|
|
43
33
|
end
|
|
44
|
-
end
|
|
45
34
|
|
|
46
|
-
|
|
47
|
-
setup do
|
|
48
|
-
@path = temp_repo("testrepo.git")
|
|
49
|
-
@repo = Rugged::Repository.new(@path)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
test "can look up local branches" do
|
|
35
|
+
def test_lookup_local_branch
|
|
53
36
|
branch = Rugged::Branch.lookup(@repo, "master")
|
|
54
37
|
refute_nil branch
|
|
55
38
|
|
|
@@ -58,7 +41,7 @@ context "Rugged::Branch.lookup" do
|
|
|
58
41
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", branch.tip.oid
|
|
59
42
|
end
|
|
60
43
|
|
|
61
|
-
|
|
44
|
+
def test_lookup_remote_branches
|
|
62
45
|
branch = Rugged::Branch.lookup(@repo, "origin/packed", :remote)
|
|
63
46
|
refute_nil branch
|
|
64
47
|
|
|
@@ -67,7 +50,7 @@ context "Rugged::Branch.lookup" do
|
|
|
67
50
|
assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", branch.tip.oid
|
|
68
51
|
end
|
|
69
52
|
|
|
70
|
-
|
|
53
|
+
def test_lookup_unicode_branch_name
|
|
71
54
|
new_branch = @repo.create_branch("Ångström", "5b5b025afb0b4c913b4c338a42934a3863bf3644")
|
|
72
55
|
refute_nil new_branch
|
|
73
56
|
|
|
@@ -76,28 +59,14 @@ context "Rugged::Branch.lookup" do
|
|
|
76
59
|
|
|
77
60
|
assert_equal new_branch, retrieved_branch
|
|
78
61
|
end
|
|
79
|
-
end
|
|
80
62
|
|
|
81
|
-
|
|
82
|
-
setup do
|
|
83
|
-
@path = temp_repo("testrepo.git")
|
|
84
|
-
@repo = Rugged::Repository.new(@path)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
test "deletes a branch from the repository" do
|
|
63
|
+
def test_delete_branch
|
|
88
64
|
branch = @repo.create_branch("test_branch")
|
|
89
65
|
branch.delete!
|
|
90
66
|
assert_nil Rugged::Branch.lookup(@repo, "test_branch")
|
|
91
67
|
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context "Rugged::Repository.move" do
|
|
95
|
-
setup do
|
|
96
|
-
@path = temp_repo("testrepo.git")
|
|
97
|
-
@repo = Rugged::Repository.new(@path)
|
|
98
|
-
end
|
|
99
68
|
|
|
100
|
-
|
|
69
|
+
def test_rename_branch
|
|
101
70
|
branch = @repo.create_branch("test_branch")
|
|
102
71
|
|
|
103
72
|
branch.move('other_branch')
|
|
@@ -105,15 +74,8 @@ context "Rugged::Repository.move" do
|
|
|
105
74
|
assert_nil Rugged::Branch.lookup(@repo, "test_branch")
|
|
106
75
|
refute_nil Rugged::Branch.lookup(@repo, "other_branch")
|
|
107
76
|
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
context "Rugged::Repository#create_branch" do
|
|
111
|
-
setup do
|
|
112
|
-
@path = temp_repo("testrepo.git")
|
|
113
|
-
@repo = Rugged::Repository.new(@path)
|
|
114
|
-
end
|
|
115
77
|
|
|
116
|
-
|
|
78
|
+
def test_create_new_branch
|
|
117
79
|
new_branch = @repo.create_branch("test_branch", "5b5b025afb0b4c913b4c338a42934a3863bf3644")
|
|
118
80
|
|
|
119
81
|
refute_nil new_branch
|
|
@@ -126,7 +88,7 @@ context "Rugged::Repository#create_branch" do
|
|
|
126
88
|
refute_nil @repo.branches.find { |p| p.name == "test_branch" }
|
|
127
89
|
end
|
|
128
90
|
|
|
129
|
-
|
|
91
|
+
def test_create_unicode_branch
|
|
130
92
|
branch_name = "A\314\212ngstro\314\210m"
|
|
131
93
|
new_branch = @repo.create_branch(branch_name, "5b5b025afb0b4c913b4c338a42934a3863bf3644")
|
|
132
94
|
|
|
@@ -140,7 +102,7 @@ context "Rugged::Repository#create_branch" do
|
|
|
140
102
|
refute_nil @repo.branches.find { |p| p.name == branch_name }
|
|
141
103
|
end
|
|
142
104
|
|
|
143
|
-
|
|
105
|
+
def test_create_branch_short_sha
|
|
144
106
|
new_branch = @repo.create_branch("test_branch", "5b5b025")
|
|
145
107
|
|
|
146
108
|
refute_nil new_branch
|
|
@@ -151,7 +113,7 @@ context "Rugged::Repository#create_branch" do
|
|
|
151
113
|
assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644", new_branch.tip.oid
|
|
152
114
|
end
|
|
153
115
|
|
|
154
|
-
|
|
116
|
+
def test_create_branch_from_tag
|
|
155
117
|
new_branch = @repo.create_branch("test_branch", "refs/tags/v0.9")
|
|
156
118
|
|
|
157
119
|
refute_nil new_branch
|
|
@@ -162,7 +124,7 @@ context "Rugged::Repository#create_branch" do
|
|
|
162
124
|
assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644", new_branch.tip.oid
|
|
163
125
|
end
|
|
164
126
|
|
|
165
|
-
|
|
127
|
+
def test_create_branch_from_head
|
|
166
128
|
new_branch = @repo.create_branch("test_branch")
|
|
167
129
|
|
|
168
130
|
refute_nil new_branch
|
|
@@ -173,7 +135,7 @@ context "Rugged::Repository#create_branch" do
|
|
|
173
135
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", new_branch.tip.oid
|
|
174
136
|
end
|
|
175
137
|
|
|
176
|
-
|
|
138
|
+
def test_create_branch_explicit_head
|
|
177
139
|
new_branch = @repo.create_branch("test_branch", "HEAD")
|
|
178
140
|
|
|
179
141
|
refute_nil new_branch
|
|
@@ -184,8 +146,9 @@ context "Rugged::Repository#create_branch" do
|
|
|
184
146
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", new_branch.tip.oid
|
|
185
147
|
end
|
|
186
148
|
|
|
187
|
-
|
|
188
|
-
new_branch = @repo.create_branch("test_branch",
|
|
149
|
+
def test_create_branch_from_commit
|
|
150
|
+
new_branch = @repo.create_branch("test_branch",
|
|
151
|
+
Rugged::Commit.lookup(@repo, "5b5b025afb0b4c913b4c338a42934a3863bf3644"))
|
|
189
152
|
|
|
190
153
|
refute_nil new_branch
|
|
191
154
|
assert_equal "test_branch", new_branch.name
|
|
@@ -195,31 +158,33 @@ context "Rugged::Repository#create_branch" do
|
|
|
195
158
|
assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644", new_branch.tip.oid
|
|
196
159
|
end
|
|
197
160
|
|
|
198
|
-
|
|
199
|
-
assert_raises Rugged::InvalidError do
|
|
200
|
-
@repo.create_branch("test_branch",
|
|
161
|
+
def test_create_branch_from_tree_fails
|
|
162
|
+
assert_raises ArgumentError, Rugged::InvalidError do
|
|
163
|
+
@repo.create_branch("test_branch",
|
|
164
|
+
Rugged::Tree.lookup(@repo, "f60079018b664e4e79329a7ef9559c8d9e0378d1"))
|
|
201
165
|
end
|
|
202
|
-
|
|
166
|
+
end
|
|
203
167
|
|
|
204
|
-
|
|
205
|
-
assert_raises Rugged::InvalidError do
|
|
206
|
-
@repo.create_branch("test_branch",
|
|
168
|
+
def test_create_branch_from_blob_fails
|
|
169
|
+
assert_raises ArgumentError, Rugged::InvalidError do
|
|
170
|
+
@repo.create_branch("test_branch",
|
|
171
|
+
Rugged::Blob.lookup(@repo, "1385f264afb75a56a5bec74243be9b367ba4ca08"))
|
|
207
172
|
end
|
|
208
173
|
end
|
|
209
174
|
|
|
210
|
-
|
|
175
|
+
def test_create_branch_from_unknown_ref_fails
|
|
211
176
|
assert_raises Rugged::ReferenceError do
|
|
212
177
|
@repo.create_branch("test_branch", "i_do_not_exist")
|
|
213
178
|
end
|
|
214
179
|
end
|
|
215
180
|
|
|
216
|
-
|
|
181
|
+
def test_create_branch_from_unknown_commit_fails
|
|
217
182
|
assert_raises Rugged::ReferenceError do
|
|
218
183
|
@repo.create_branch("test_branch", "dd15de908706711b51b7acb24faab726d2b3cb16")
|
|
219
184
|
end
|
|
220
185
|
end
|
|
221
186
|
|
|
222
|
-
|
|
187
|
+
def test_create_branch_from_non_canonical_fails
|
|
223
188
|
assert_raises Rugged::ReferenceError do
|
|
224
189
|
@repo.create_branch("test_branch", "packed")
|
|
225
190
|
end
|
data/test/commit_test.rb
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
require "test_helper"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
|
|
6
|
-
@repo = Rugged::Repository.new(@path)
|
|
7
|
-
end
|
|
3
|
+
class TestCommit < Rugged::TestCase
|
|
4
|
+
include Rugged::RepositoryAccess
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
def test_read_commit_data
|
|
10
7
|
oid = "8496071c1b46c854b31185ea97743be6a8774479"
|
|
11
8
|
obj = @repo.lookup(oid)
|
|
12
9
|
|
|
@@ -30,7 +27,7 @@ context "Rugged::Commit tests" do
|
|
|
30
27
|
assert_equal [], obj.parents
|
|
31
28
|
end
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
def test_commit_with_multiple_parents
|
|
34
31
|
oid = "a4a7dce85cf63874e984719f4fdd239f5145052f"
|
|
35
32
|
obj = @repo.lookup(oid)
|
|
36
33
|
parents = obj.parents.map {|c| c.oid }
|
|
@@ -38,7 +35,7 @@ context "Rugged::Commit tests" do
|
|
|
38
35
|
assert parents.include?("c47800c7266a2be04c571c04d5a6614691ea99bd")
|
|
39
36
|
end
|
|
40
37
|
|
|
41
|
-
|
|
38
|
+
def test_get_parent_oids
|
|
42
39
|
oid = "a4a7dce85cf63874e984719f4fdd239f5145052f"
|
|
43
40
|
obj = @repo.lookup(oid)
|
|
44
41
|
parents = obj.parent_oids
|
|
@@ -46,24 +43,65 @@ context "Rugged::Commit tests" do
|
|
|
46
43
|
assert parents.include?("c47800c7266a2be04c571c04d5a6614691ea99bd")
|
|
47
44
|
end
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
def test_get_tree_oid
|
|
50
47
|
oid = "8496071c1b46c854b31185ea97743be6a8774479"
|
|
51
48
|
obj = @repo.lookup(oid)
|
|
52
49
|
|
|
53
50
|
assert_equal obj.tree_oid, "181037049a54a1eb5fab404658a3a250b44335d7"
|
|
54
51
|
end
|
|
52
|
+
end
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
class CommitWriteTest < Rugged::TestCase
|
|
55
|
+
include Rugged::TempRepositoryAccess
|
|
56
|
+
|
|
57
|
+
def test_write_a_commit
|
|
57
58
|
person = {:name => 'Scott', :email => 'schacon@gmail.com', :time => Time.now }
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
Rugged::Commit.create(@repo,
|
|
61
|
+
:message => "This is the commit message\n\nThis commit is created from Rugged",
|
|
62
|
+
:committer => person,
|
|
63
|
+
:author => person,
|
|
64
|
+
:parents => [@repo.head.target],
|
|
65
|
+
:tree => "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_write_commit_with_time_offset
|
|
69
|
+
person = {:name => 'Jake', :email => 'jake@github.com', :time => Time.now, :time_offset => 3600}
|
|
70
|
+
|
|
71
|
+
oid = Rugged::Commit.create(@repo,
|
|
60
72
|
:message => "This is the commit message\n\nThis commit is created from Rugged",
|
|
61
73
|
:committer => person,
|
|
62
74
|
:author => person,
|
|
63
75
|
:parents => [@repo.head.target],
|
|
64
76
|
:tree => "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b")
|
|
65
77
|
|
|
66
|
-
|
|
78
|
+
commit = @repo.lookup(oid)
|
|
79
|
+
assert_equal 3600, commit.committer[:time_offset]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_write_invalid_parents
|
|
83
|
+
person = {:name => 'Jake', :email => 'jake@github.com', :time => Time.now, :time_offset => 3600}
|
|
84
|
+
|
|
85
|
+
assert_raises TypeError do
|
|
86
|
+
Rugged::Commit.create(@repo,
|
|
87
|
+
:message => "This is the commit message\n\nThis commit is created from Rugged",
|
|
88
|
+
:committer => person,
|
|
89
|
+
:author => person,
|
|
90
|
+
:parents => [:invalid_parent],
|
|
91
|
+
:tree => "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b")
|
|
92
|
+
end
|
|
67
93
|
end
|
|
68
94
|
|
|
95
|
+
def test_write_empty_email
|
|
96
|
+
person = {:name => 'Jake', :email => '', :time => Time.now}
|
|
97
|
+
|
|
98
|
+
assert_raises Rugged::InvalidError do
|
|
99
|
+
Rugged::Commit.create(@repo,
|
|
100
|
+
:message => "This is the commit message\n\nThis commit is created from Rugged",
|
|
101
|
+
:committer => person,
|
|
102
|
+
:author => person,
|
|
103
|
+
:parents => [@repo.head.target],
|
|
104
|
+
:tree => "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b")
|
|
105
|
+
end
|
|
106
|
+
end
|
|
69
107
|
end
|
data/test/config_test.rb
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
require "test_helper"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@repo = Rugged::Repository.new(temp_repo('testrepo.git'))
|
|
6
|
-
end
|
|
3
|
+
class ConfigTest < Rugged::TestCase
|
|
4
|
+
include Rugged::RepositoryAccess
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
def test_read_config_file
|
|
9
7
|
config = @repo.config
|
|
10
8
|
assert_equal 'false', config['core.bare']
|
|
11
9
|
assert_nil config['not.exist']
|
|
12
10
|
end
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
def test_read_config_from_path
|
|
15
13
|
config = Rugged::Config.new(File.join(@repo.path, 'config'))
|
|
16
14
|
assert_equal 'false', config['core.bare']
|
|
17
15
|
end
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
def test_read_global_config_file
|
|
20
18
|
config = Rugged::Config.global
|
|
21
|
-
|
|
19
|
+
assert config['user.name'] != nil
|
|
22
20
|
assert_nil config['core.bare']
|
|
23
21
|
end
|
|
22
|
+
end
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
class ConfigWriteTest < Rugged::TestCase
|
|
25
|
+
include Rugged::TempRepositoryAccess
|
|
26
|
+
|
|
27
|
+
def test_write_config_values
|
|
26
28
|
config = @repo.config
|
|
27
29
|
config['custom.value'] = 'my value'
|
|
28
30
|
|
|
@@ -33,12 +35,11 @@ context "Rugged::Config tests" do
|
|
|
33
35
|
assert_match(/value = my value/, content)
|
|
34
36
|
end
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
def test_delete_config_values
|
|
37
39
|
config = @repo.config
|
|
38
40
|
config.delete('core.bare')
|
|
39
41
|
|
|
40
42
|
config2 = @repo.config
|
|
41
43
|
assert_nil config2.get('core.bare')
|
|
42
44
|
end
|
|
43
|
-
|
|
44
45
|
end
|