Module: Gity::Operation::Diff
Instance Method Summary collapse
Methods included from Common
#_cls, #_flash, #_fmt, #_logger, #_operation_done, #_pastel, #_prmt, #print_header
Instance Method Details
#diff(ws, files) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gity/operation/diff.rb', line 8 def diff(ws, files) _cls print_header _prmt.puts print_workspace_items(ws, files, skip_other_files: true) _prmt.puts efiles = files.modified[:files] + files.staged[:files] #+ files.deleted[:files] begin sel = _prmt.select(_fmt("Please select file to diff : "), filter: true, per_page: 10) do |m| efiles.sort.each do |f| m.choice f,f.path end m.choice "Done", :done end if is_empty?(sel) or sel != :done st, res = ws.diff_file(sel) raise OperationError, "Diff file '#{sel}' failed with error : #{res}" if not st _prmt.puts _fmt "Diff file result for '#{sel}'" _prmt.puts _fmt res, :bright_blue _prmt.puts _prmt.puts _fmt "[Enter to close]", :inverse STDIN.gets end rescue TTY::Reader::InputInterrupt end end |