Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -ff option to git clean #529

Merged
merged 2 commits into from Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/git/base.rb
Expand Up @@ -290,6 +290,7 @@ def reset_hard(commitish = nil, opts = {})
# options:
# :force
# :d
# :ff
#
def clean(opts = {})
self.lib.clean(opts)
Expand Down
1 change: 1 addition & 0 deletions lib/git/lib.rb
Expand Up @@ -684,6 +684,7 @@ def reset(commit, opts = {})
def clean(opts = {})
arr_opts = []
arr_opts << '--force' if opts[:force]
arr_opts << '-ff' if opts[:ff]
arr_opts << '-d' if opts[:d]
arr_opts << '-x' if opts[:x]

Expand Down
10 changes: 10 additions & 0 deletions tests/units/test_index_ops.rb
Expand Up @@ -49,6 +49,11 @@ def test_clean
g.add
g.commit("first commit")

FileUtils.mkdir_p("nested")
Dir.chdir('nested') do
Git.init
end

new_file('file-to-clean', 'blablahbla')
FileUtils.mkdir_p("dir_to_clean")

Expand Down Expand Up @@ -76,6 +81,11 @@ def test_clean

g.clean(:force => true, :x => true)
assert(!File.exist?('ignored_file'))

assert(File.exist?('nested'))

g.clean(:ff => true, :d => true)
assert(!File.exist?('nested'))
end
end
end
Expand Down