Module: Gity::Overview
Instance Method Summary
collapse
Methods included from Status
#status
Methods included from Common
#_cls, #_flash, #_fmt, #_logger, #_operation_done, #_pastel, #_prmt, #print_header
Instance Method Details
#print_overview(ws, opts = {}, &block) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/gity/overview.rb', line 12
def print_overview(ws, opts = {}, &block)
res = status(ws)
print_workspace_items(ws, res, opts)
if block and not res.clean?
block.call(ws, res, opts)
end
res
end
|
#print_workspace_items(ws, itm, opts = {}) ⇒ Object
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/gity/overview.rb', line 24
def print_workspace_items(ws, itm, opts = {})
opts = {} if opts.nil?
_prmt.puts _fmt "Workspace path : #{ws.workspace_root}", :bright_yellow
_prmt.puts
title = opts[:title] || "Workspace Status : "
_prmt.puts _fmt title
branch = ws.current_branch
_prmt.puts _fmt "Branch : #{branch}" if not_empty?(branch)
_prmt.puts
mfiles = itm
_prmt.puts _fmt "Staged Files : ", :bold, :underline
files = mfiles.staged[:dirs] + mfiles.staged[:files]
if files.length > 0
files.sort.each do |v|
_prmt.puts _fmt("* #{v}")
end
else
_prmt.puts _fmt "** No staged file found", :yellow
end
res = []
skipOtherFile = opts[:skip_other_files] || false
if not skipOtherFile
_prmt.puts ""
_prmt.puts _fmt "Other Files : ", :bold, :underline
res = mfiles.modified[:dirs] + mfiles.modified[:files] + mfiles.deleted[:dirs] + mfiles.deleted[:files]
res2 = mfiles.new[:dirs] + mfiles.new[:files]
if res.length > 0 or res2.length > 0
res.sort.each do |vv|
case vv
when GitCli::Delta::ModifiedFile, GitCli::Delta::ModifiedDir
_prmt.puts _fmt(vv)
when GitCli::Delta::DeletedFile, GitCli::Delta::DeletedDir
_prmt.puts _fmt(vv)
end
end
_prmt.puts "\n ******** Untracked Files & Directories ******** "
res2.sort.each do |vv|
case vv
when GitCli::Delta::NewFile
_prmt.puts _fmt(vv)
when GitCli::Delta::NewDir
_prmt.puts _fmt(vv) if vv.has_files?
end
end
else
_prmt.puts _fmt("** No other file found", :yellow)
end
end
if mfiles.clean?
_prmt.puts
_prmt.puts _fmt("Workspace is clean", :inverse)
_prmt.puts
st, logs = ws.logs(limit: 3)
en = GitLogParser.new(logs)
_prmt.puts _fmt "Last 3 last commit : "
en.entries.each do |e|
_prmt.puts _fmt "#{e.commit_by} @ #{e.timestamp}\n\n #{e.commit_notes}"
_prmt.puts _fmt "\n**** ****"
end
_prmt.puts
true
else
false
end
end
|