Skip to content

Commit dfaa57b

Browse files
committed
Add -x option to 'clean' to remove ignored files
1 parent 12dd8aa commit dfaa57b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/git/lib.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ def clean(opts = {})
428428
arr_opts = []
429429
arr_opts << '--force' if opts[:force]
430430
arr_opts << '-d' if opts[:d]
431-
431+
arr_opts << '-x' if opts[:x]
432+
432433
command('clean', arr_opts)
433434
end
434435

tests/units/test_index_ops.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def test_clean
4343
g = Git.clone(@wbare, 'clean_me')
4444
Dir.chdir('clean_me') do
4545
new_file('test-file', 'blahblahbal')
46+
new_file('ignored_file', 'ignored file contents')
47+
new_file('.gitignore', 'ignored_file')
48+
4649
g.add
4750
g.commit("first commit")
4851

@@ -55,18 +58,24 @@ def test_clean
5558

5659
assert(File.exists?('file-to-clean'))
5760
assert(File.exists?('dir_to_clean'))
58-
61+
assert(File.exists?('ignored_file'))
62+
5963
g.clean(:force => true)
6064

6165
assert(!File.exists?('file-to-clean'))
6266
assert(File.exists?('dir_to_clean'))
63-
67+
assert(File.exists?('ignored_file'))
68+
6469
new_file('file-to-clean', 'blablahbla')
6570

6671
g.clean(:force => true, :d => true)
6772

6873
assert(!File.exists?('file-to-clean'))
6974
assert(!File.exists?('dir_to_clean'))
75+
assert(File.exists?('ignored_file'))
76+
77+
g.clean(:force => true, :x => true)
78+
assert(!File.exists?('ignored_file'))
7079
end
7180
end
7281
end

0 commit comments

Comments
 (0)