Module: Gity::Operation::CommitAll

Includes:
Common
Included in:
Gity::Operation
Defined in:
lib/gity/operation/commit_all.rb

Instance Method Summary collapse

Methods included from Common

#_cls, #_fmt, #_logger, #_pastel, #_prmt, #print_header

Instance Method Details

#commit_all(ws, files) ⇒ Object



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
# File 'lib/gity/operation/commit_all.rb', line 9

def commit_all(ws, files)
  _prmt.puts _fmt("Files eligible to be committed : ")
  [:staged, :modified, :deleted].each do |cat|
    files.send(cat).each do |k,v|
      v.each do |vv|
        _prmt.puts _fmt(vv, :magenta)
      end
    end
  end

  begin
    msg = ""
    loop do
      msg = _prmt.ask(_fmt("\n Commit message (Ctrl-c to go back) : "), required: true)
      confirm = _prmt.yes?(_fmt(" Commit message : #{msg}\n Proceed? No to provide a new commit message "))
      if confirm
        break
      end
    end

    st, res = ws.commit_all(msg)
    raise OperationError, "Commit all failed with error : #{res}" if not st
  rescue TTY::Reader::InputInterrupt
    _prmt.puts _fmt "Commit all aborted"
  end
end