Skip to content

Commit 2f8bf94

Browse files
Merge pull request ruby-git#157 from nishidayuya/fix_warnings_on_ruby_2.1.2
Fix File.exists? warnings on Ruby 2.1.2
2 parents 33f100f + 656b2ed commit 2f8bf94

File tree

7 files changed

+30
-29
lines changed

7 files changed

+30
-29
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ rvm:
44
- 1.9.2
55
- 1.9.3
66
- 2.0.0
7+
- 2.1
78
- jruby-18mode
89
- jruby-19mode
910
- jruby-head

lib/git/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,13 @@ def gc
446446
end
447447

448448
def apply(file)
449-
if File.exists?(file)
449+
if File.exist?(file)
450450
self.lib.apply(file)
451451
end
452452
end
453453

454454
def apply_mail(file)
455-
self.lib.apply_mail(file) if File.exists?(file)
455+
self.lib.apply_mail(file) if File.exist?(file)
456456
end
457457

458458
## LOWER LEVEL INDEX OPERATIONS ##

lib/git/lib.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def pull(remote='origin', branch='master')
632632

633633
def tag_sha(tag_name)
634634
head = File.join(@git_dir, 'refs', 'tags', tag_name)
635-
return File.read(head).chomp if File.exists?(head)
635+
return File.read(head).chomp if File.exist?(head)
636636

637637
command('show-ref', ['--tags', '-s', tag_name])
638638
end

lib/git/path.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Path
77
def initialize(path, check_path=true)
88
path = File.expand_path(path)
99

10-
if check_path && !File.exists?(path)
10+
if check_path && !File.exist?(path)
1111
raise ArgumentError, 'path does not exist', [path]
1212
end
1313

tests/units/test_archive.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ def tempfile
1515

1616
def test_archive
1717
f = @git.archive('v2.6', tempfile)
18-
assert(File.exists?(f))
18+
assert(File.exist?(f))
1919

2020
f = @git.object('v2.6').archive(tempfile) # writes to given file
21-
assert(File.exists?(f))
21+
assert(File.exist?(f))
2222

2323
f = @git.object('v2.6').archive # returns path to temp file
24-
assert(File.exists?(f))
24+
assert(File.exist?(f))
2525

2626
f = @git.object('v2.6').archive(nil, :format => 'tar') # returns path to temp file
27-
assert(File.exists?(f))
27+
assert(File.exist?(f))
2828

2929
lines = `cd /tmp; tar xvpf #{f}`.split("\n")
3030
assert_equal('ex_dir/', lines[0])
@@ -34,10 +34,10 @@ def test_archive
3434
assert(File.file?(f))
3535

3636
f = @git.object('v2.6').archive(tempfile, :format => 'tgz', :prefix => 'test/')
37-
assert(File.exists?(f))
37+
assert(File.exist?(f))
3838

3939
f = @git.object('v2.6').archive(tempfile, :format => 'tar', :prefix => 'test/', :path => 'ex_dir/')
40-
assert(File.exists?(f))
40+
assert(File.exist?(f))
4141

4242
lines = `cd /tmp; tar xvpf #{f}`.split("\n")
4343
assert_equal('test/', lines[0])
@@ -47,7 +47,7 @@ def test_archive
4747
c = Git.clone(@wbare, 'new')
4848
c.chdir do
4949
f = @git.remote('origin').branch('master').archive(tempfile, :format => 'tgz')
50-
assert(File.exists?(f))
50+
assert(File.exist?(f))
5151
end
5252
end
5353
end

tests/units/test_index_ops.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,26 @@ def test_clean
5656
new_file('clean-me-too', 'blablahbla')
5757
end
5858

59-
assert(File.exists?('file-to-clean'))
60-
assert(File.exists?('dir_to_clean'))
61-
assert(File.exists?('ignored_file'))
59+
assert(File.exist?('file-to-clean'))
60+
assert(File.exist?('dir_to_clean'))
61+
assert(File.exist?('ignored_file'))
6262

6363
g.clean(:force => true)
6464

65-
assert(!File.exists?('file-to-clean'))
66-
assert(File.exists?('dir_to_clean'))
67-
assert(File.exists?('ignored_file'))
65+
assert(!File.exist?('file-to-clean'))
66+
assert(File.exist?('dir_to_clean'))
67+
assert(File.exist?('ignored_file'))
6868

6969
new_file('file-to-clean', 'blablahbla')
7070

7171
g.clean(:force => true, :d => true)
7272

73-
assert(!File.exists?('file-to-clean'))
74-
assert(!File.exists?('dir_to_clean'))
75-
assert(File.exists?('ignored_file'))
73+
assert(!File.exist?('file-to-clean'))
74+
assert(!File.exist?('dir_to_clean'))
75+
assert(File.exist?('ignored_file'))
7676

7777
g.clean(:force => true, :x => true)
78-
assert(!File.exists?('ignored_file'))
78+
assert(!File.exist?('ignored_file'))
7979
end
8080
end
8181
end
@@ -97,7 +97,7 @@ def test_revert
9797
commits = g.log(1e4).count
9898
g.revert(first_commit.sha)
9999
assert_equal(commits + 1, g.log(1e4).count)
100-
assert(!File.exists?('test-file2'))
100+
assert(!File.exist?('test-file2'))
101101
end
102102
end
103103
end

tests/units/test_init.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_git_init
3434
in_temp_dir do |path|
3535
repo = Git.init(path)
3636
assert(File.directory?(File.join(path, '.git')))
37-
assert(File.exists?(File.join(path, '.git', 'config')))
37+
assert(File.exist?(File.join(path, '.git', 'config')))
3838
assert_equal('false', repo.config('core.bare'))
3939
end
4040
end
@@ -43,34 +43,34 @@ def test_git_init_bare
4343
in_temp_dir do |path|
4444
repo = Git.init(path, :bare => true)
4545
assert(File.directory?(File.join(path, '.git')))
46-
assert(File.exists?(File.join(path, '.git', 'config')))
46+
assert(File.exist?(File.join(path, '.git', 'config')))
4747
assert_equal('true', repo.config('core.bare'))
4848
end
4949
end
5050

5151
def test_git_init_remote_git
5252
in_temp_dir do |dir|
53-
assert(!File.exists?(File.join(dir, 'config')))
53+
assert(!File.exist?(File.join(dir, 'config')))
5454

5555
in_temp_dir do |path|
5656
Git.init(path, :repository => dir)
57-
assert(File.exists?(File.join(dir, 'config')))
57+
assert(File.exist?(File.join(dir, 'config')))
5858
end
5959
end
6060
end
6161

6262
def test_git_clone
6363
in_temp_dir do |path|
6464
g = Git.clone(@wbare, 'bare-co')
65-
assert(File.exists?(File.join(g.repo.path, 'config')))
65+
assert(File.exist?(File.join(g.repo.path, 'config')))
6666
assert(g.dir)
6767
end
6868
end
6969

7070
def test_git_clone_bare
7171
in_temp_dir do |path|
7272
g = Git.clone(@wbare, 'bare.git', :bare => true)
73-
assert(File.exists?(File.join(g.repo.path, 'config')))
73+
assert(File.exist?(File.join(g.repo.path, 'config')))
7474
assert_nil(g.dir)
7575
end
7676
end
@@ -79,7 +79,7 @@ def test_git_clone_config
7979
in_temp_dir do |path|
8080
g = Git.clone(@wbare, 'config.git', :config => "receive.denyCurrentBranch=ignore")
8181
assert_equal('ignore', g.config['receive.denycurrentbranch'])
82-
assert(File.exists?(File.join(g.repo.path, 'config')))
82+
assert(File.exist?(File.join(g.repo.path, 'config')))
8383
assert(g.dir)
8484
end
8585
end

0 commit comments

Comments
 (0)