Skip to content

Commit

Permalink
When core.ignoreCase, check for added files case-insensitively
Browse files Browse the repository at this point in the history
  • Loading branch information
nevinera authored and jcouball committed Jun 1, 2024
1 parent d943bf4 commit 993eb78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/git/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ def added
# added?('lib/git.rb')
# @return [Boolean]
def added?(file)
added.member?(file)
if ignore_case?
added.keys.map(&:downcase).include?(file.downcase)
else
added.member?(file)
end
end

#
Expand Down
5 changes: 5 additions & 0 deletions tests/units/test_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def test_dot_files_status
def test_added_boolean
in_temp_dir do |path|
git = Git.clone(@wdir, 'test_dot_files_status')
git.config('core.ignorecase', 'false')

create_file('test_dot_files_status/test_file_1', 'content tets_file_1')
create_file('test_dot_files_status/test_file_2', 'content tets_file_2')
Expand All @@ -100,6 +101,10 @@ def test_added_boolean

assert(git.status.added?('test_file_1'))
assert(!git.status.added?('test_file_2'))
assert(!git.status.added?('TEST_FILE_1'))

git.config('core.ignorecase', 'true')
assert(git.status.added?('TEST_FILE_1'))
end
end

Expand Down

0 comments on commit 993eb78

Please sign in to comment.