Class: Gity::Landing

Inherits:
Object
  • Object
show all
Includes:
Common, Operation, Overview, PushWorkspace, TR::CondUtils
Defined in:
lib/gity/landing.rb

Instance Method Summary collapse

Methods included from PushWorkspace

#push_workspace

Methods included from Common

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

Methods included from Operation

#prompt_operation

Methods included from Operation::Delete

#delete

Methods included from Operation::Diff

#diff

Methods included from Operation::RemoveStaged

#remove_staged

Methods included from Operation::Ignore

#ignore

Methods included from Operation::Add

#add

Methods included from Operation::Commit

#commit

Methods included from Status

#status

Methods included from Operation::CommitAll

#commit_all

Methods included from Overview

#print_overview, #print_workspace_items

Instance Method Details

#process_flashObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/gity/landing.rb', line 59

def process_flash
  if Flash.instance.has_messages?
    if Flash.instance.has_info_msg?
      while Flash.instance.has_info_msg?
        _prmt.puts _fmt Flash.instance.info_msg.pop, :magenta
      end
    end

    if Flash.instance.has_err_msg?
      while Flash.instance.has_err_msg?
        _prmt.puts _fmt Flash.instance.err_msg.pop, :red
      end
    end

    if Flash.instance.has_warning_msg?
      while Flash.instance.has_warning_msg?
        _prmt.puts _fmt Flash.instance.warning_msg.pop, :bright_yellow
      end
    end
  end
end

#run(root, opts = {}, &block) ⇒ Object

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/gity/landing.rb', line 18

def run(root, opts = {}, &block)

  @ws = GitCli::Workspace.new(root)
  raise Error, "Given path '#{root}' is not a Git workspace" if not @ws.is_workspace?

  opts = {} if opts.nil?
  opts[:loop] = true if is_empty?(opts[:loop])

  begin
    loop do

      _cls
      print_header
      _prmt.puts
      res = print_overview(@ws, opts) do |ws, files, optts|
        _prmt.puts
        process_flash
        _prmt.puts
        prompt_operation(ws, files, optts, &block)
      end


      break if not opts[:loop] or res.clean?
    end
  rescue OperationCompleted
  end

  _prmt.puts
  push = _prmt.yes?(_fmt("Do you want to push the changes to remote repository? ", :cyan))
  if push
    begin

      _cls
      push_workspace(@ws, opts)

    rescue OperationCompleted
    end
  end

end