File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,11 @@ def changed
34
34
# changed?('lib/git.rb')
35
35
# @return [Boolean]
36
36
def changed? ( file )
37
- changed . member? ( file )
37
+ if ignore_case?
38
+ changed . keys . map ( &:downcase ) . include? ( file . downcase )
39
+ else
40
+ changed . member? ( file )
41
+ end
38
42
end
39
43
40
44
# Returns an Enumerable containing files that have been added.
@@ -264,5 +268,15 @@ def fetch_added
264
268
end
265
269
end
266
270
end
271
+
272
+ # It's worth noting that (like git itself) this gem will not behave well if
273
+ # ignoreCase is set inconsistently with the file-system itself. For details:
274
+ # https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreignoreCase
275
+ def ignore_case?
276
+ return @_ignore_case if defined? ( @_ignore_case )
277
+ @_ignore_case = @base . config ( 'core.ignoreCase' ) == 'true'
278
+ rescue Git ::FailedError
279
+ @_ignore_case = false
280
+ end
267
281
end
268
282
end
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ def test_added_boolean
106
106
def test_changed_boolean
107
107
in_temp_dir do |path |
108
108
git = Git . clone ( @wdir , 'test_dot_files_status' )
109
+ git . config ( 'core.ignorecase' , 'false' )
109
110
110
111
create_file ( 'test_dot_files_status/test_file_1' , 'content tets_file_1' )
111
112
create_file ( 'test_dot_files_status/test_file_2' , 'content tets_file_2' )
@@ -117,6 +118,13 @@ def test_changed_boolean
117
118
118
119
assert ( git . status . changed? ( 'test_file_1' ) )
119
120
assert ( !git . status . changed? ( 'test_file_2' ) )
121
+
122
+ update_file ( 'test_dot_files_status/scott/text.txt' , 'definitely different' )
123
+ assert ( git . status . changed? ( 'scott/text.txt' ) )
124
+ assert ( !git . status . changed? ( 'scott/TEXT.txt' ) )
125
+
126
+ git . config ( 'core.ignorecase' , 'true' )
127
+ assert ( git . status . changed? ( 'scott/TEXT.txt' ) )
120
128
end
121
129
end
122
130
You can’t perform that action at this time.
0 commit comments