Skip to content

Commit 323181e

Browse files
authored
Merge pull request #840 from HParker/remove-ruby-2.7-warnings
Remove ruby 2.7 warnings
2 parents 5d7dee5 + a4ad1df commit 323181e

File tree

7 files changed

+51
-41
lines changed

7 files changed

+51
-41
lines changed

lib/rugged/commit.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
module Rugged
77
class Commit
8-
98
def self.prettify_message(msg, strip_comments = true)
109
Rugged::prettify_message(msg, strip_comments)
1110
end
@@ -30,7 +29,7 @@ def diff(*args)
3029
#
3130
# See Rugged::Tree#diff_workdir for more details.
3231
def diff_workdir(options = {})
33-
self.tree.diff_workdir(options)
32+
self.tree.diff_workdir(**options)
3433
end
3534

3635
# The time when this commit was made effective. This is the same value

lib/rugged/repository.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def checkout(target, options = {})
3030
options[:strategy] ||= :safe
3131
options.delete(:paths)
3232

33-
return checkout_head(options) if target == "HEAD"
33+
return checkout_head(**options) if target == "HEAD"
3434

3535
if target.kind_of?(Rugged::Branch)
3636
branch = target
@@ -39,7 +39,7 @@ def checkout(target, options = {})
3939
end
4040

4141
if branch
42-
self.checkout_tree(branch.target, options)
42+
self.checkout_tree(branch.target, **options)
4343

4444
if branch.remote?
4545
references.create("HEAD", branch.target_id, force: true)
@@ -49,7 +49,7 @@ def checkout(target, options = {})
4949
else
5050
commit = Commit.lookup(self, self.rev_parse_oid(target))
5151
references.create("HEAD", commit.oid, force: true)
52-
self.checkout_tree(commit, options)
52+
self.checkout_tree(commit, **options)
5353
end
5454
end
5555

@@ -250,12 +250,11 @@ def blob_at(revision, path)
250250
(blob.type == :blob) ? blob : nil
251251
end
252252

253-
def fetch(remote_or_url, *args)
253+
def fetch(remote_or_url, *args, **kwargs)
254254
unless remote_or_url.kind_of? Remote
255255
remote_or_url = remotes[remote_or_url] || remotes.create_anonymous(remote_or_url)
256256
end
257-
258-
remote_or_url.fetch(*args)
257+
remote_or_url.fetch(*args, **kwargs)
259258
end
260259

261260
# Push a list of refspecs to the given remote.

lib/rugged/submodule_collection.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class SubmoduleCollection
2626
#
2727
# Returns the newly created +submodule+
2828
def add(url, path, options = {})
29-
submodule = setup_add(url, path, options)
30-
clone_submodule(submodule.repository, options)
29+
submodule = setup_add(url, path, **options)
30+
clone_submodule(submodule.repository, **options)
3131
submodule.finalize_add
3232
end
3333

@@ -40,9 +40,9 @@ def add(url, path, options = {})
4040
# 1. fetches the remote
4141
# 2. sets up a master branch to be tracking origin/master
4242
# 3. checkouts the submodule
43-
def clone_submodule(repo, fetch_options)
43+
def clone_submodule(repo, **fetch_options)
4444
# the remote was just added by setup_add, no need to check presence
45-
repo.remotes['origin'].fetch(fetch_options)
45+
repo.remotes['origin'].fetch(**fetch_options)
4646

4747
repo.branches.create('master','origin/master')
4848
repo.branches['master'].upstream = repo.branches['origin/master']

test/online/fetch_test.rb

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ def test_fetch_over_https_with_certificate_callback
3333
@repo.remotes.create("origin", "https://github.com/libgit2/TestGitRepository.git")
3434

3535
args = {}
36-
@repo.fetch("origin", {
36+
@repo.fetch(
37+
"origin",
3738
certificate_check: lambda { |valid, host|
3839
args[:valid] = valid
3940
args[:host] = host
40-
4141
true
4242
}
43-
})
43+
)
4444

4545
assert_equal({ valid: true, host: "github.com" }, args)
4646
end
@@ -49,9 +49,10 @@ def test_fetch_over_https_with_certificate_callback_fail
4949
@repo.remotes.create("origin", "https://github.com/libgit2/TestGitRepository.git")
5050

5151
exception = assert_raises Rugged::HTTPError do
52-
@repo.fetch("origin", {
52+
@repo.fetch(
53+
"origin",
5354
certificate_check: lambda { |valid, host| false }
54-
})
55+
)
5556
end
5657

5758
assert_equal "user rejected certificate for github.com", exception.message
@@ -61,11 +62,12 @@ def test_fetch_over_https_with_certificate_callback_exception
6162
@repo.remotes.create("origin", "https://github.com/libgit2/TestGitRepository.git")
6263

6364
exception = assert_raises RuntimeError do
64-
@repo.fetch("origin", {
65+
@repo.fetch(
66+
"origin",
6567
certificate_check: lambda { |valid, host|
6668
raise "Exception from callback"
6769
}
68-
})
70+
)
6971
end
7072

7173
assert_equal "Exception from callback", exception.message
@@ -92,11 +94,11 @@ def test_fetch_over_ssh_with_credentials_from_agent
9294
def test_fetch_over_ssh_with_credentials_callback
9395
@repo.remotes.create("origin", ENV['GITTEST_REMOTE_SSH_URL'])
9496

95-
@repo.fetch("origin", {
97+
@repo.fetch("origin",
9698
credentials: lambda { |url, username, allowed_types|
9799
return ssh_key_credential
98100
}
99-
})
101+
)
100102
end
101103
end
102104
end

test/rebase_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ def test_rebase_does_not_lose_files
172172
rebase = Rugged::Rebase.new(@repo, "refs/heads/gravy", "refs/heads/veal")
173173

174174
assert rebase.next
175-
assert rebase.commit({ committer: { :email => "[email protected]", :name => "Rebaser" } })
175+
assert rebase.commit(committer: { :email => "[email protected]", :name => "Rebaser" })
176176

177177
assert rebase.next
178-
assert rebase.commit({ committer: { :email => "[email protected]", :name => "Rebaser" } })
178+
assert rebase.commit(committer: { :email => "[email protected]", :name => "Rebaser" })
179179
end
180180

181181
def test_inmemory_rebase_does_not_lose_files
@@ -197,9 +197,9 @@ def test_inmemory_rebase_does_not_lose_files
197197
rebase = Rugged::Rebase.new(@repo, "refs/heads/gravy", "refs/heads/veal", inmemory: true)
198198

199199
assert rebase.next
200-
assert rebase.commit({ committer: { :email => "[email protected]", :name => "Rebaser" } })
200+
assert rebase.commit(committer: { :email => "[email protected]", :name => "Rebaser" })
201201

202202
assert rebase.next
203-
assert rebase.commit({ committer: { :email => "[email protected]", :name => "Rebaser" } })
203+
assert rebase.commit(committer: { :email => "[email protected]", :name => "Rebaser" })
204204
end
205205
end

test/reference_test.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ def test_create_default_log_custom_ident
336336
def test_create_default_log_custom_log_message
337337
ref = @repo.references.create(
338338
"refs/heads/test-reflog-default",
339-
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750", {
340-
message: "reference created"
341-
})
339+
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
340+
message: "reference created"
341+
)
342342
reflog = ref.log
343343

344344
assert_equal reflog.size, 1
@@ -359,9 +359,9 @@ def test_create_default_log_custom_ident_and_log_message
359359

360360
ref = @repo.references.create(
361361
"refs/heads/test-reflog-default",
362-
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750", {
363-
message: "reference created"
364-
})
362+
"a65fedf39aefe402d3bb6e24df4d4f5fe4547750",
363+
message: "reference created"
364+
)
365365
reflog = ref.log
366366

367367
assert_equal reflog.size, 1
@@ -408,9 +408,11 @@ def test_set_target_default_log_custom_signature
408408
end
409409

410410
def test_set_target_default_log_custom_log_message
411-
@repo.references.update(@ref, "5b5b025afb0b4c913b4c338a42934a3863bf3644", {
411+
@repo.references.update(
412+
@ref,
413+
"5b5b025afb0b4c913b4c338a42934a3863bf3644",
412414
message: "reference updated"
413-
})
415+
)
414416

415417
reflog = @ref.log
416418
assert_equal reflog.size, 2

test/tag_test.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,12 @@ def test_extract_signature
158158
class AnnotatedTagTest < Rugged::TestCase
159159
def setup
160160
@repo = FixtureRepo.from_libgit2("testrepo.git")
161-
@tag = @repo.tags.create('annotated_tag', "5b5b025afb0b4c913b4c338a42934a3863bf3644", {
161+
@tag = @repo.tags.create(
162+
'annotated_tag',
163+
"5b5b025afb0b4c913b4c338a42934a3863bf3644",
162164
:message => "test tag message\n",
163165
:tagger => { :name => 'Scott', :email => '[email protected]', :time => Time.now }
164-
})
166+
)
165167
end
166168

167169
def test_is_annotated
@@ -242,10 +244,12 @@ def setup
242244
end
243245

244246
def test_writing_a_tag
245-
tag = @repo.tags.create('tag', "5b5b025afb0b4c913b4c338a42934a3863bf3644", {
247+
tag = @repo.tags.create(
248+
'tag',
249+
"5b5b025afb0b4c913b4c338a42934a3863bf3644",
246250
:message => "test tag message\n",
247251
:tagger => { :name => 'Scott', :email => '[email protected]', :time => Time.now }
248-
})
252+
)
249253

250254
annotation = tag.annotation
251255
assert_equal :tag, annotation.type
@@ -261,20 +265,24 @@ def test_writing_a_tag_without_signature
261265
@repo.config['user.name'] = name
262266
@repo.config['user.email'] = email
263267

264-
tag = @repo.tags.create('tag', "5b5b025afb0b4c913b4c338a42934a3863bf3644", {
268+
tag = @repo.tags.create(
269+
'tag',
270+
"5b5b025afb0b4c913b4c338a42934a3863bf3644",
265271
:message => "test tag message\n"
266-
})
272+
)
267273

268274
assert_equal name, tag.annotation.tagger[:name]
269275
assert_equal email, tag.annotation.tagger[:email]
270276
end
271277

272278
def test_tag_invalid_message_type
273279
assert_raises TypeError do
274-
@repo.tags.create('tag', "5b5b025afb0b4c913b4c338a42934a3863bf3644", {
280+
@repo.tags.create(
281+
'tag',
282+
"5b5b025afb0b4c913b4c338a42934a3863bf3644",
275283
:message => :invalid_message,
276284
:tagger => {:name => 'Scott', :email => '[email protected]', :time => Time.now }
277-
})
285+
)
278286
end
279287
end
280288

0 commit comments

Comments
 (0)