rugged 0.18.0.gh.de28323 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -4
- data/Rakefile +1 -1
- data/ext/rugged/extconf.rb +10 -0
- data/ext/rugged/rugged.c +153 -86
- data/ext/rugged/rugged.h +44 -33
- data/ext/rugged/rugged_blob.c +288 -60
- data/ext/rugged/rugged_branch.c +82 -57
- data/ext/rugged/rugged_commit.c +83 -86
- data/ext/rugged/rugged_config.c +68 -68
- data/ext/rugged/rugged_diff.c +509 -0
- data/ext/rugged/rugged_diff_delta.c +94 -0
- data/ext/rugged/rugged_diff_hunk.c +100 -0
- data/ext/rugged/rugged_diff_line.c +79 -0
- data/ext/rugged/rugged_diff_patch.c +169 -0
- data/ext/rugged/rugged_index.c +539 -8
- data/ext/rugged/rugged_note.c +74 -80
- data/ext/rugged/rugged_object.c +63 -8
- data/ext/rugged/rugged_reference.c +231 -145
- data/ext/rugged/rugged_remote.c +509 -53
- data/ext/rugged/rugged_repo.c +572 -236
- data/ext/rugged/rugged_revwalk.c +59 -36
- data/ext/rugged/rugged_settings.c +7 -9
- data/ext/rugged/rugged_signature.c +7 -11
- data/ext/rugged/rugged_tag.c +93 -39
- data/ext/rugged/rugged_tree.c +321 -58
- data/lib/rugged.rb +1 -0
- data/lib/rugged/commit.rb +16 -1
- data/lib/rugged/console.rb +9 -0
- data/lib/rugged/diff.rb +19 -0
- data/lib/rugged/diff/delta.rb +54 -0
- data/lib/rugged/diff/hunk.rb +23 -0
- data/lib/rugged/diff/line.rb +29 -0
- data/lib/rugged/diff/patch.rb +28 -0
- data/lib/rugged/repository.rb +36 -39
- data/lib/rugged/version.rb +1 -1
- data/test/blob_test.rb +308 -1
- data/test/branch_test.rb +7 -0
- data/test/commit_test.rb +7 -10
- data/test/coverage/cover.rb +9 -1
- data/test/diff_test.rb +777 -0
- data/test/fixtures/archive.tar.gz +0 -0
- data/test/fixtures/attr/attr0 +1 -0
- data/test/fixtures/attr/attr1 +29 -0
- data/test/fixtures/attr/attr2 +21 -0
- data/test/fixtures/attr/attr3 +4 -0
- data/test/fixtures/attr/binfile +1 -0
- data/test/fixtures/attr/dir/file +0 -0
- data/test/fixtures/attr/file +1 -0
- data/test/fixtures/attr/gitattributes +29 -0
- data/test/fixtures/attr/gitignore +2 -0
- data/test/fixtures/attr/ign +1 -0
- data/test/fixtures/attr/macro_bad +1 -0
- data/test/fixtures/attr/macro_test +1 -0
- data/test/fixtures/attr/root_test1 +1 -0
- data/test/fixtures/attr/root_test2 +6 -0
- data/test/fixtures/attr/root_test3 +19 -0
- data/test/fixtures/attr/root_test4.txt +14 -0
- data/test/fixtures/attr/sub/abc +37 -0
- data/test/fixtures/attr/sub/dir/file +0 -0
- data/test/fixtures/attr/sub/file +1 -0
- data/test/fixtures/attr/sub/ign/file +1 -0
- data/test/fixtures/attr/sub/ign/sub/file +1 -0
- data/test/fixtures/attr/sub/sub/dir +0 -0
- data/test/fixtures/attr/sub/sub/file +1 -0
- data/test/fixtures/attr/sub/sub/subsub.txt +1 -0
- data/test/fixtures/attr/sub/subdir_test1 +2 -0
- data/test/fixtures/attr/sub/subdir_test2.txt +1 -0
- data/test/fixtures/diff/another.txt +38 -0
- data/test/fixtures/diff/readme.txt +36 -0
- data/test/fixtures/mergedrepo/conflicts-one.txt +5 -0
- data/test/fixtures/mergedrepo/conflicts-two.txt +5 -0
- data/test/fixtures/mergedrepo/one.txt +10 -0
- data/test/fixtures/mergedrepo/two.txt +12 -0
- data/test/fixtures/status/current_file +1 -0
- data/test/fixtures/status/ignored_file +1 -0
- data/test/fixtures/status/modified_file +2 -0
- data/test/fixtures/status/new_file +1 -0
- data/test/fixtures/status/staged_changes +2 -0
- data/test/fixtures/status/staged_changes_modified_file +3 -0
- data/test/fixtures/status/staged_delete_modified_file +1 -0
- data/test/fixtures/status/staged_new_file +1 -0
- data/test/fixtures/status/staged_new_file_modified_file +2 -0
- data/test/fixtures/status/subdir.txt +2 -0
- data/test/fixtures/status/subdir/current_file +1 -0
- data/test/fixtures/status/subdir/modified_file +2 -0
- data/test/fixtures/status/subdir/new_file +1 -0
- data/test/fixtures/status//350/277/231 +1 -0
- data/test/fixtures/testrepo.git/config +5 -0
- data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
- data/test/fixtures/text_file.md +464 -0
- data/test/fixtures/unsymlinked.git/HEAD +1 -0
- data/test/fixtures/unsymlinked.git/config +6 -0
- data/test/fixtures/unsymlinked.git/description +1 -0
- data/test/fixtures/unsymlinked.git/info/exclude +2 -0
- data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
- data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
- data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
- data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
- data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
- data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
- data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
- data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
- data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
- data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +2 -0
- data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
- data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
- data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
- data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
- data/test/fixtures/unsymlinked.git/refs/heads/exe-file +1 -0
- data/test/fixtures/unsymlinked.git/refs/heads/master +1 -0
- data/test/fixtures/unsymlinked.git/refs/heads/reg-file +1 -0
- data/test/index_test.rb +120 -0
- data/test/reference_test.rb +38 -3
- data/test/remote_test.rb +224 -3
- data/test/repo_reset_test.rb +2 -0
- data/test/repo_test.rb +147 -10
- data/test/test_helper.rb +5 -2
- data/vendor/libgit2/include/git2/attr.h +3 -3
- data/vendor/libgit2/include/git2/blob.h +11 -17
- data/vendor/libgit2/include/git2/branch.h +3 -2
- data/vendor/libgit2/include/git2/checkout.h +7 -0
- data/vendor/libgit2/include/git2/clone.h +3 -0
- data/vendor/libgit2/include/git2/commit.h +61 -66
- data/vendor/libgit2/include/git2/common.h +73 -42
- data/vendor/libgit2/include/git2/config.h +57 -71
- data/vendor/libgit2/include/git2/cred_helpers.h +2 -2
- data/vendor/libgit2/include/git2/diff.h +179 -30
- data/vendor/libgit2/include/git2/errors.h +3 -3
- data/vendor/libgit2/include/git2/index.h +225 -146
- data/vendor/libgit2/include/git2/indexer.h +2 -22
- data/vendor/libgit2/include/git2/inttypes.h +9 -9
- data/vendor/libgit2/include/git2/merge.h +123 -5
- data/vendor/libgit2/include/git2/odb.h +59 -38
- data/vendor/libgit2/include/git2/odb_backend.h +45 -104
- data/vendor/libgit2/include/git2/oid.h +30 -19
- data/vendor/libgit2/include/git2/pack.h +21 -3
- data/vendor/libgit2/include/git2/refdb.h +0 -35
- data/vendor/libgit2/include/git2/refs.h +93 -31
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +60 -20
- data/vendor/libgit2/include/git2/repository.h +48 -70
- data/vendor/libgit2/include/git2/reset.h +3 -3
- data/vendor/libgit2/include/git2/revparse.h +22 -0
- data/vendor/libgit2/include/git2/stash.h +1 -1
- data/vendor/libgit2/include/git2/status.h +131 -56
- data/vendor/libgit2/include/git2/strarray.h +2 -2
- data/vendor/libgit2/include/git2/submodule.h +16 -16
- data/vendor/libgit2/include/git2/sys/commit.h +46 -0
- data/vendor/libgit2/include/git2/sys/config.h +71 -0
- data/vendor/libgit2/include/git2/sys/index.h +179 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +86 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +158 -0
- data/vendor/libgit2/include/git2/sys/refs.h +38 -0
- data/vendor/libgit2/include/git2/sys/repository.h +106 -0
- data/vendor/libgit2/include/git2/tag.h +44 -18
- data/vendor/libgit2/include/git2/trace.h +1 -2
- data/vendor/libgit2/include/git2/transport.h +74 -0
- data/vendor/libgit2/include/git2/tree.h +12 -22
- data/vendor/libgit2/include/git2/types.h +33 -0
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/array.h +66 -0
- data/vendor/libgit2/src/attr.c +26 -13
- data/vendor/libgit2/src/attr_file.c +3 -2
- data/vendor/libgit2/src/attr_file.h +3 -3
- data/vendor/libgit2/src/attrcache.h +4 -4
- data/vendor/libgit2/src/blob.c +13 -9
- data/vendor/libgit2/src/blob.h +2 -2
- data/vendor/libgit2/src/branch.c +67 -49
- data/vendor/libgit2/src/cache.c +224 -54
- data/vendor/libgit2/src/cache.h +33 -20
- data/vendor/libgit2/src/checkout.c +145 -85
- data/vendor/libgit2/src/clone.c +62 -50
- data/vendor/libgit2/src/commit.c +74 -40
- data/vendor/libgit2/src/commit.h +2 -3
- data/vendor/libgit2/src/commit_list.c +14 -8
- data/vendor/libgit2/src/config.c +119 -36
- data/vendor/libgit2/src/config.h +3 -0
- data/vendor/libgit2/src/config_cache.c +24 -7
- data/vendor/libgit2/src/config_file.c +9 -6
- data/vendor/libgit2/src/crlf.c +4 -2
- data/vendor/libgit2/src/date.c +3 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/diff.c +681 -303
- data/vendor/libgit2/src/diff.h +34 -2
- data/vendor/libgit2/src/diff_driver.c +405 -0
- data/vendor/libgit2/src/diff_driver.h +49 -0
- data/vendor/libgit2/src/diff_file.c +447 -0
- data/vendor/libgit2/src/diff_file.h +58 -0
- data/vendor/libgit2/src/diff_patch.c +995 -0
- data/vendor/libgit2/src/diff_patch.h +46 -0
- data/vendor/libgit2/src/diff_print.c +430 -0
- data/vendor/libgit2/src/diff_tform.c +464 -203
- data/vendor/libgit2/src/diff_xdiff.c +166 -0
- data/vendor/libgit2/src/diff_xdiff.h +28 -0
- data/vendor/libgit2/src/fetch.c +11 -4
- data/vendor/libgit2/src/fileops.c +85 -61
- data/vendor/libgit2/src/fileops.h +4 -0
- data/vendor/libgit2/src/global.c +10 -2
- data/vendor/libgit2/src/global.h +0 -8
- data/vendor/libgit2/src/hash/hash_generic.h +3 -3
- data/vendor/libgit2/src/hash/hash_win32.h +4 -4
- data/vendor/libgit2/src/hashsig.c +0 -1
- data/vendor/libgit2/src/ignore.c +68 -28
- data/vendor/libgit2/src/ignore.h +10 -1
- data/vendor/libgit2/src/index.c +666 -84
- data/vendor/libgit2/src/index.h +6 -0
- data/vendor/libgit2/src/indexer.c +10 -28
- data/vendor/libgit2/src/iterator.c +427 -283
- data/vendor/libgit2/src/iterator.h +58 -4
- data/vendor/libgit2/src/merge.c +1892 -32
- data/vendor/libgit2/src/merge.h +132 -5
- data/vendor/libgit2/src/merge_file.c +174 -0
- data/vendor/libgit2/src/merge_file.h +71 -0
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/notes.c +45 -48
- data/vendor/libgit2/src/object.c +89 -127
- data/vendor/libgit2/src/object.h +0 -1
- data/vendor/libgit2/src/object_api.c +129 -0
- data/vendor/libgit2/src/odb.c +156 -59
- data/vendor/libgit2/src/odb.h +5 -2
- data/vendor/libgit2/src/odb_loose.c +31 -17
- data/vendor/libgit2/src/odb_pack.c +39 -43
- data/vendor/libgit2/src/oid.c +62 -27
- data/vendor/libgit2/src/oid.h +33 -0
- data/vendor/libgit2/src/oidmap.h +4 -6
- data/vendor/libgit2/src/pack-objects.c +54 -22
- data/vendor/libgit2/src/pack.c +98 -56
- data/vendor/libgit2/src/pack.h +3 -1
- data/vendor/libgit2/src/pathspec.c +26 -1
- data/vendor/libgit2/src/pathspec.h +14 -0
- data/vendor/libgit2/src/pool.c +5 -0
- data/vendor/libgit2/src/posix.c +2 -2
- data/vendor/libgit2/src/posix.h +3 -0
- data/vendor/libgit2/src/push.c +13 -10
- data/vendor/libgit2/src/refdb.c +82 -62
- data/vendor/libgit2/src/refdb.h +16 -16
- data/vendor/libgit2/src/refdb_fs.c +386 -133
- data/vendor/libgit2/src/reflog.c +3 -1
- data/vendor/libgit2/src/refs.c +247 -221
- data/vendor/libgit2/src/refs.h +2 -1
- data/vendor/libgit2/src/refspec.c +18 -1
- data/vendor/libgit2/src/refspec.h +3 -1
- data/vendor/libgit2/src/remote.c +434 -253
- data/vendor/libgit2/src/remote.h +5 -3
- data/vendor/libgit2/src/repository.c +197 -111
- data/vendor/libgit2/src/repository.h +26 -5
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revparse.c +84 -79
- data/vendor/libgit2/src/revwalk.c +1 -1
- data/vendor/libgit2/src/signature.c +22 -10
- data/vendor/libgit2/src/stash.c +5 -2
- data/vendor/libgit2/src/status.c +311 -107
- data/vendor/libgit2/src/status.h +23 -0
- data/vendor/libgit2/src/submodule.c +21 -13
- data/vendor/libgit2/src/tag.c +42 -31
- data/vendor/libgit2/src/tag.h +2 -3
- data/vendor/libgit2/src/thread-utils.h +105 -3
- data/vendor/libgit2/src/trace.c +1 -2
- data/vendor/libgit2/src/trace.h +3 -3
- data/vendor/libgit2/src/transport.c +18 -6
- data/vendor/libgit2/src/transports/cred.c +103 -1
- data/vendor/libgit2/src/transports/local.c +19 -9
- data/vendor/libgit2/src/transports/smart_protocol.c +32 -12
- data/vendor/libgit2/src/transports/ssh.c +519 -0
- data/vendor/libgit2/src/transports/winhttp.c +3 -1
- data/vendor/libgit2/src/tree.c +26 -28
- data/vendor/libgit2/src/tree.h +3 -3
- data/vendor/libgit2/src/unix/posix.h +2 -0
- data/vendor/libgit2/src/util.c +43 -6
- data/vendor/libgit2/src/util.h +40 -12
- data/vendor/libgit2/src/vector.c +3 -5
- data/vendor/libgit2/src/vector.h +9 -0
- data/vendor/libgit2/src/win32/dir.c +1 -1
- data/vendor/libgit2/src/win32/error.c +2 -0
- data/vendor/libgit2/src/win32/findfile.c +3 -6
- data/vendor/libgit2/src/win32/posix_w32.c +85 -59
- data/vendor/libgit2/src/win32/pthread.c +16 -8
- data/vendor/libgit2/src/win32/pthread.h +7 -4
- metadata +407 -306
- data/test/coverage/HEAD.json +0 -1
- data/vendor/libgit2/include/git2/refdb_backend.h +0 -109
- data/vendor/libgit2/src/diff_output.c +0 -1819
- data/vendor/libgit2/src/diff_output.h +0 -93
@@ -0,0 +1 @@
|
|
1
|
+
ref: refs/heads/master
|
@@ -0,0 +1 @@
|
|
1
|
+
Unnamed repository; edit this file 'description' to name the repository.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
a8595ccca04f40818ae0155c8f9c77a230e597b6
|
@@ -0,0 +1 @@
|
|
1
|
+
7fccd75616ec188b8f1b23d67506a334cc34a49d
|
@@ -0,0 +1 @@
|
|
1
|
+
806999882bf91d24241e4077906b9017605eb1f3
|
data/test/index_test.rb
CHANGED
@@ -49,6 +49,17 @@ class IndexTest < Rugged::TestCase
|
|
49
49
|
assert_equal 1, @index.count
|
50
50
|
end
|
51
51
|
|
52
|
+
def test_remove_dir
|
53
|
+
@index.remove_dir 'does-not-exist'
|
54
|
+
assert_equal 2, @index.count
|
55
|
+
|
56
|
+
@index.remove_dir '', 2
|
57
|
+
assert_equal 2, @index.count
|
58
|
+
|
59
|
+
@index.remove_dir ''
|
60
|
+
assert_equal 0, @index.count
|
61
|
+
end
|
62
|
+
|
52
63
|
def test_get_entry_data
|
53
64
|
e = @index[0]
|
54
65
|
assert_equal 'README', e[:path]
|
@@ -184,6 +195,18 @@ class IndexWorkdirTest < Rugged::TestCase
|
|
184
195
|
end
|
185
196
|
end
|
186
197
|
|
198
|
+
class IndexConflictsTest < Rugged::SandboxedTestCase
|
199
|
+
def setup
|
200
|
+
super
|
201
|
+
|
202
|
+
@repo = sandbox_init("mergedrepo")
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_conflicts
|
206
|
+
assert @repo.index.conflicts?
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
187
210
|
class IndexRepositoryTest < Rugged::TestCase
|
188
211
|
include Rugged::TempRepositoryAccess
|
189
212
|
|
@@ -211,3 +234,100 @@ class IndexRepositoryTest < Rugged::TestCase
|
|
211
234
|
assert_nil @repo.lookup(new_tree_sha)['second.txt']
|
212
235
|
end
|
213
236
|
end
|
237
|
+
|
238
|
+
class IndexAddAllTest < Rugged::SandboxedTestCase
|
239
|
+
def setup
|
240
|
+
super
|
241
|
+
|
242
|
+
@repo = Rugged::Repository.init_at(File.join(@_sandbox_path, "add-all"))
|
243
|
+
|
244
|
+
Dir.chdir(@repo.workdir) do
|
245
|
+
File.open("file.foo", "w") { |f| f.write "a file" }
|
246
|
+
File.open("file.bar", "w") { |f| f.write "another file" }
|
247
|
+
File.open("file.zzz", "w") { |f| f.write "yet another one" }
|
248
|
+
File.open("other.zzz", "w") { |f| f.write "yet another one" }
|
249
|
+
File.open("more.zzz", "w") { |f| f.write "yet another one" }
|
250
|
+
File.open(".gitignore", "w") { |f| f.write "*.foo\n" }
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_add_all_lifecycle
|
255
|
+
Dir.chdir(@repo.workdir) do
|
256
|
+
@repo.index.add_all("file.*")
|
257
|
+
|
258
|
+
assert @repo.index["file.bar"]
|
259
|
+
assert @repo.index["file.zzz"]
|
260
|
+
refute @repo.index["file.foo"]
|
261
|
+
refute @repo.index["other.zzz"]
|
262
|
+
refute @repo.index["more.zzz"]
|
263
|
+
|
264
|
+
@repo.index.add_all("*.zzz")
|
265
|
+
|
266
|
+
assert @repo.index["file.bar"]
|
267
|
+
assert @repo.index["file.zzz"]
|
268
|
+
assert @repo.index["other.zzz"]
|
269
|
+
assert @repo.index["more.zzz"]
|
270
|
+
refute @repo.index["file.foo"]
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_add_all_dry_run
|
275
|
+
Dir.chdir(@repo.workdir) do
|
276
|
+
yielded = []
|
277
|
+
@repo.index.add_all do |path, pathspec|
|
278
|
+
yielded << path
|
279
|
+
false
|
280
|
+
end
|
281
|
+
|
282
|
+
assert_equal [".gitignore", "file.bar", "file.zzz", "more.zzz", "other.zzz"], yielded
|
283
|
+
|
284
|
+
yielded.each do |path|
|
285
|
+
refute @repo.index[path]
|
286
|
+
end
|
287
|
+
|
288
|
+
yielded = []
|
289
|
+
@repo.index.add_all(["file.*", "*.zzz"]) do |path, pathspec|
|
290
|
+
yielded << [path, pathspec]
|
291
|
+
false
|
292
|
+
end
|
293
|
+
|
294
|
+
assert_equal [
|
295
|
+
["file.bar", "file.*"],
|
296
|
+
["file.zzz", "file.*"],
|
297
|
+
["more.zzz", "*.zzz"],
|
298
|
+
["other.zzz", "*.zzz"]
|
299
|
+
], yielded
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_update_all
|
304
|
+
Dir.chdir(@repo.workdir) do
|
305
|
+
@repo.index.add_all("file.*")
|
306
|
+
|
307
|
+
File.open("file.bar", "w") { |f| f.write "new content for file" }
|
308
|
+
@repo.index.update_all("file.*")
|
309
|
+
|
310
|
+
assert @repo.index["file.bar"]
|
311
|
+
assert_equal "new content for file", @repo.lookup(@repo.index["file.bar"][:oid]).content
|
312
|
+
|
313
|
+
refute @repo.index["other.zzz"], "#update_all should only update files in the index"
|
314
|
+
refute @repo.index["more.zzz"], "#update_all should only update files in the index"
|
315
|
+
|
316
|
+
File.unlink("file.bar")
|
317
|
+
@repo.index.update_all
|
318
|
+
|
319
|
+
refute @repo.index["file.bar"], "#update_all should remove index entries that are removed from the workdir"
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
def test_remove_all
|
324
|
+
Dir.chdir(@repo.workdir) do
|
325
|
+
@repo.index.add_all("file.*")
|
326
|
+
@repo.index.remove_all("*.zzz")
|
327
|
+
|
328
|
+
assert @repo.index["file.bar"]
|
329
|
+
refute @repo.index["file.zzz"]
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|
data/test/reference_test.rb
CHANGED
@@ -1,23 +1,39 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
require
|
2
|
+
require "test_helper"
|
3
3
|
|
4
4
|
class ReferenceTest < Rugged::TestCase
|
5
5
|
include Rugged::RepositoryAccess
|
6
6
|
|
7
7
|
UNICODE_REF_NAME = "A\314\212ngstro\314\210m"
|
8
8
|
|
9
|
+
def test_reference_validity
|
10
|
+
valid = "refs/foobar"
|
11
|
+
invalid = "refs/~nope^*"
|
12
|
+
|
13
|
+
assert Rugged::Reference.valid_name?(valid)
|
14
|
+
assert !Rugged::Reference.valid_name?(invalid)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_each_can_handle_exceptions
|
18
|
+
assert_raises Exception do
|
19
|
+
Rugged::Reference.each(@repo) do
|
20
|
+
raise Exception.new("fail")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
9
25
|
def test_list_references
|
10
26
|
refs = @repo.refs.map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
11
27
|
assert_equal "heads/master:heads/packed:notes/commits:tags/v0.9:tags/v1.0", refs
|
12
28
|
end
|
13
29
|
|
14
30
|
def test_can_filter_refs_with_regex
|
15
|
-
refs = @repo.refs(/tags
|
31
|
+
refs = @repo.refs('refs/tags/*').map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
16
32
|
assert_equal "tags/v0.9:tags/v1.0", refs
|
17
33
|
end
|
18
34
|
|
19
35
|
def test_can_filter_refs_with_string
|
20
|
-
refs = @repo.refs('0.9').map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
36
|
+
refs = @repo.refs('*0.9*').map { |r| r.name.gsub("refs/", '') }.sort.join(':')
|
21
37
|
assert_equal "tags/v0.9", refs
|
22
38
|
end
|
23
39
|
|
@@ -26,6 +42,18 @@ class ReferenceTest < Rugged::TestCase
|
|
26
42
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", ref.target
|
27
43
|
assert_equal :direct, ref.type
|
28
44
|
assert_equal "refs/heads/master", ref.name
|
45
|
+
assert_nil ref.peel
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_can_open_a_symbolic_reference
|
49
|
+
ref = Rugged::Reference.lookup(@repo, "HEAD")
|
50
|
+
assert_equal "refs/heads/master", ref.target
|
51
|
+
assert_equal :symbolic, ref.type
|
52
|
+
|
53
|
+
resolved = ref.resolve
|
54
|
+
assert_equal :direct, resolved.type
|
55
|
+
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", resolved.target
|
56
|
+
assert_equal resolved.target, ref.peel
|
29
57
|
end
|
30
58
|
|
31
59
|
def test_looking_up_missing_ref_returns_nil
|
@@ -67,6 +95,13 @@ class ReferenceTest < Rugged::TestCase
|
|
67
95
|
assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", head.target
|
68
96
|
assert_equal :direct, head.type
|
69
97
|
end
|
98
|
+
|
99
|
+
def test_reference_to_tag
|
100
|
+
ref = Rugged::Reference.lookup(@repo, "refs/tags/v1.0")
|
101
|
+
|
102
|
+
assert_equal "0c37a5391bbff43c37f0d0371823a5509eed5b1d", ref.target
|
103
|
+
assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644", ref.peel
|
104
|
+
end
|
70
105
|
end
|
71
106
|
|
72
107
|
class ReferenceWriteTest < Rugged::TestCase
|
data/test/remote_test.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
require 'net/http'
|
3
3
|
|
4
|
-
class
|
4
|
+
class RemoteNetworkTest < Rugged::TestCase
|
5
5
|
include Rugged::RepositoryAccess
|
6
6
|
|
7
|
-
def
|
7
|
+
def test_remote_network_connect
|
8
8
|
begin
|
9
9
|
Net::HTTP.new('github.com').head('/')
|
10
10
|
rescue SocketError => msg
|
@@ -19,11 +19,31 @@ class RemoteTest < Rugged::TestCase
|
|
19
19
|
|
20
20
|
assert !remote.connected?
|
21
21
|
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class RemoteTest < Rugged::TestCase
|
25
|
+
include Rugged::RepositoryAccess
|
26
|
+
|
27
|
+
class TestException < StandardError
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_list_remote_names
|
31
|
+
remote_names = Rugged::Remote.names(@repo)
|
32
|
+
assert_equal [ "test_remote", "libgit2" ], remote_names
|
33
|
+
end
|
22
34
|
|
23
35
|
def test_list_remotes
|
24
36
|
remotes = @repo.remotes
|
25
37
|
assert remotes.kind_of? Enumerable
|
26
|
-
assert_equal [ "libgit2" ], remotes.
|
38
|
+
assert_equal [ "test_remote", "libgit2" ], remotes.map(&:name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_remotes_each_protect
|
42
|
+
assert_raises TestException do
|
43
|
+
@repo.remotes.each do |remote|
|
44
|
+
raise TestException
|
45
|
+
end
|
46
|
+
end
|
27
47
|
end
|
28
48
|
|
29
49
|
def test_remote_new_name
|
@@ -38,6 +58,80 @@ class RemoteTest < Rugged::TestCase
|
|
38
58
|
end
|
39
59
|
end
|
40
60
|
|
61
|
+
def test_url_set
|
62
|
+
new_url = 'git://github.com/libgit2/TestGitRepository.git'
|
63
|
+
remote = Rugged::Remote.new(@repo, 'git://github.com/libgit2/libgit2.git')
|
64
|
+
remote.url = new_url
|
65
|
+
assert_equal new_url, remote.url
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_url_set_invalid
|
69
|
+
url = 'upstream'
|
70
|
+
remote = Rugged::Remote.new(@repo, 'git://github.com/libgit2/libgit2.git')
|
71
|
+
assert_raises ArgumentError do
|
72
|
+
remote.url = url
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_push_url
|
77
|
+
assert_equal 'git://github.com/libgit2/TestEmptyRepository.git',
|
78
|
+
Rugged::Remote.lookup(@repo, 'test_remote').push_url
|
79
|
+
|
80
|
+
assert_nil Rugged::Remote.lookup(@repo, 'libgit2').push_url
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_push_url_set
|
84
|
+
new_url = 'git://github.com/libgit2/TestGitRepository.git'
|
85
|
+
remote = Rugged::Remote.new(@repo, 'git://github.com/libgit2/libgit2.git')
|
86
|
+
|
87
|
+
assert_nil remote.push_url
|
88
|
+
remote.push_url = new_url
|
89
|
+
assert_equal new_url, remote.push_url
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_push_url_set_invalid
|
93
|
+
new_url = 'upstream'
|
94
|
+
remote = Rugged::Remote.new(@repo, 'git://github.com/libgit2/libgit2.git')
|
95
|
+
assert_raises ArgumentError do
|
96
|
+
remote.push_url = new_url
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_fetch_refspecs
|
101
|
+
remote = Rugged::Remote.lookup(@repo, 'test_remote')
|
102
|
+
assert_equal ['+refs/heads/*:refs/remotes/test_remote/*'], remote.fetch_refspecs
|
103
|
+
|
104
|
+
assert_empty Rugged::Remote.lookup(@repo, 'libgit2').fetch_refspecs
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_push_refspecs
|
108
|
+
remote = Rugged::Remote.lookup(@repo, 'test_remote')
|
109
|
+
assert_equal ['refs/heads/*:refs/heads/testing/*'], remote.push_refspecs
|
110
|
+
|
111
|
+
assert_empty Rugged::Remote.lookup(@repo, 'libgit2').push_refspecs
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_add_fetch
|
115
|
+
remote = Rugged::Remote.new(@repo, 'git://github.com/libgit2/libgit2.git')
|
116
|
+
assert_nil remote.add_fetch('+refs/heads/*:refs/remotes/test/*')
|
117
|
+
assert_equal ['+refs/heads/*:refs/remotes/test/*'], remote.fetch_refspecs
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_add_push
|
121
|
+
remote = Rugged::Remote.new(@repo, 'git://github.com/libgit2/libgit2.git')
|
122
|
+
assert_nil remote.add_push('refs/heads/*:refs/heads/test/*')
|
123
|
+
assert_equal ['refs/heads/*:refs/heads/test/*'], remote.push_refspecs
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_clear_refspecs
|
127
|
+
remote = Rugged::Remote.lookup(@repo, 'test_remote')
|
128
|
+
|
129
|
+
remote.clear_refspecs
|
130
|
+
|
131
|
+
assert_empty remote.push_refspecs
|
132
|
+
assert_empty remote.fetch_refspecs
|
133
|
+
end
|
134
|
+
|
41
135
|
def test_remote_lookup
|
42
136
|
remote = Rugged::Remote.lookup(@repo, 'libgit2')
|
43
137
|
assert_equal 'git://github.com/libgit2/libgit2.git', remote.url
|
@@ -101,3 +195,130 @@ class RemotePushTest < Rugged::SandboxedTestCase
|
|
101
195
|
assert_equal "8496071c1b46c854b31185ea97743be6a8774479", @remote_repo.ref("refs/heads/master").target
|
102
196
|
end
|
103
197
|
end
|
198
|
+
|
199
|
+
class RemoteWriteTest < Rugged::TestCase
|
200
|
+
include Rugged::TempRepositoryAccess
|
201
|
+
|
202
|
+
def test_remote_add
|
203
|
+
Rugged::Remote.add(@repo, 'upstream', 'git://github.com/libgit2/libgit2.git')
|
204
|
+
remote = Rugged::Remote.lookup(@repo, 'upstream')
|
205
|
+
assert_equal 'upstream', remote.name
|
206
|
+
assert_equal 'git://github.com/libgit2/libgit2.git', remote.url
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_remote_add_with_invalid_url
|
210
|
+
assert_raises ArgumentError do
|
211
|
+
Rugged::Remote.add(@repo, 'upstream', 'libgit2')
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_url_set
|
216
|
+
new_url = 'git://github.com/l?#!@#$ibgit2/TestGitRepository.git'
|
217
|
+
remote = Rugged::Remote.lookup(@repo, 'origin')
|
218
|
+
remote.url = new_url
|
219
|
+
assert remote.save
|
220
|
+
assert_equal new_url, Rugged::Remote.lookup(@repo, 'origin').url
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_rename
|
224
|
+
remote = Rugged::Remote.lookup(@repo, 'origin')
|
225
|
+
assert_nil remote.rename!('new_remote_name')
|
226
|
+
assert Rugged::Remote.lookup(@repo, 'new_remote_name')
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_rename_invalid_name
|
230
|
+
remote = Rugged::Remote.lookup(@repo, 'origin')
|
231
|
+
assert_raises Rugged::ConfigError do
|
232
|
+
remote.rename!('/?')
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_rename_exists
|
237
|
+
remote = Rugged::Remote.lookup(@repo, 'origin')
|
238
|
+
assert_raises Rugged::ConfigError do
|
239
|
+
remote.rename!('origin')
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_rename_error_callback
|
244
|
+
@repo.config['remote.origin.fetch'] = '+refs/*:refs/*'
|
245
|
+
remote = Rugged::Remote.lookup(@repo, 'origin')
|
246
|
+
assert_equal ["+refs/*:refs/*"], remote.rename!('test_remote')
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
class RemoteTransportTest < Rugged::TestCase
|
251
|
+
class TestException < StandardError
|
252
|
+
end
|
253
|
+
|
254
|
+
def setup
|
255
|
+
@path = Dir.mktmpdir 'dir'
|
256
|
+
@repo = Rugged::Repository.init_at(@path, false)
|
257
|
+
repo_dir = File.join(TEST_DIR, (File.join('fixtures', 'testrepo.git', '.')))
|
258
|
+
@remote = Rugged::Remote.add(@repo, 'origin', "file://#{repo_dir}")
|
259
|
+
end
|
260
|
+
|
261
|
+
def teardown
|
262
|
+
FileUtils.remove_entry_secure(@path)
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_remote_disconnect
|
266
|
+
@remote.connect(:fetch)
|
267
|
+
assert @remote.connected?
|
268
|
+
|
269
|
+
@remote.disconnect
|
270
|
+
refute @remote.connected?
|
271
|
+
end
|
272
|
+
|
273
|
+
def test_remote_ls
|
274
|
+
@remote.connect(:fetch) do |r|
|
275
|
+
assert r.ls.kind_of? Enumerable
|
276
|
+
rheads = r.ls.to_a
|
277
|
+
|
278
|
+
assert_equal 7, rheads.count
|
279
|
+
|
280
|
+
rhead = rheads.first
|
281
|
+
assert_equal false, rhead[:local?]
|
282
|
+
assert rhead[:oid]
|
283
|
+
assert_nil rhead[:loid]
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_update_tips_callback
|
288
|
+
@remote.connect(:fetch) do |r|
|
289
|
+
r.download
|
290
|
+
r.update_tips! do |ref, source, destination|
|
291
|
+
assert Rugged::Reference.lookup(@repo, ref)
|
292
|
+
assert_nil source
|
293
|
+
assert destination
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
# this is not as useless as it seems
|
299
|
+
# LocalJumpError is raised in the second call to
|
300
|
+
# update_tips! if libgit2 callback is not cleared
|
301
|
+
# Also the exception is explicitly raised after the
|
302
|
+
# callback is cleared
|
303
|
+
def test_update_tips_cleanup_callbacks
|
304
|
+
@remote.connect(:fetch) do |r|
|
305
|
+
r.download
|
306
|
+
assert_raises TestException do
|
307
|
+
r.update_tips! do
|
308
|
+
raise TestException
|
309
|
+
end
|
310
|
+
end
|
311
|
+
r.update_tips!
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_remote_fetch
|
316
|
+
@remote.connect(:fetch) do |r|
|
317
|
+
r.download
|
318
|
+
r.update_tips!
|
319
|
+
end
|
320
|
+
|
321
|
+
assert_equal '36060c58702ed4c2a40832c51758d5344201d89a', @repo.rev_parse('origin/master').oid
|
322
|
+
assert @repo.lookup('36060c5')
|
323
|
+
end
|
324
|
+
end
|