23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/fgit/cli.rb', line 23
def cp(source_branch, file_name)
if !options[:force] && status = local_changes
puts "[Warning] There are unstaged local changes."
puts status
print "Copy files may override these changes. Continue? [yN]:"
return unless !!(STDIN.gets.chomp =~ /^\s*[yY]\s*$/)
end
real_file_paths = ls(source_branch, file_name)
if !options[:force]
file_count = real_file_paths.split.compact.size
file_string = file_count <= 1 ? "file" : "files"
print "Copy #{file_count} #{file_string} above to current branch? [yN]:"
return unless !!(STDIN.gets.chomp =~ /^\s*[yY]\s*$/)
end
unless real_file_paths.empty?
puts "Handling..."
`#{cp_command(source_branch, file_name)}`
puts "Done."
end
end
|