Class: Gb::SubCommand
Direct Known Subclasses
Create, CreateTag, DeleteTag, Forall, Init, Merge, Review, Start, Status, Sync, Workspace
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Command
#error, handle_exception, #info, report_error, run
Constructor Details
Returns a new instance of SubCommand.
15
16
17
18
19
20
21
|
# File 'lib/sub_command.rb', line 15
def initialize(argv)
if @yml.nil?
@yml = 'Gb.yml'
end
super
end
|
Instance Attribute Details
#gb_config ⇒ Object
Returns the value of attribute gb_config.
13
14
15
|
# File 'lib/sub_command.rb', line 13
def gb_config
@gb_config
end
|
Instance Method Details
#check_uncommit(g, project_name) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/sub_command.rb', line 86
def check_uncommit(g, project_name)
changed = g.status.changed
added = g.status.added
deleted = g.status.deleted
untracked = g.status.untracked
if !changed.empty?
alert = true
puts "modified files:".red
changed.each do |file, status|
puts (" M: " << file).red
end
end
if !added.empty?
alert = true
puts "added files:".red
added.each do |file, status|
puts (" A: " << file).red
end
end
if !deleted.empty?
alert = true
puts "deleted files:".red
deleted.each do |file, status|
puts (" D: " << file).red
end
end
if !untracked.empty?
alert = true
puts "untracked files:".red
untracked.each do |file, status|
puts (" " << file).red
end
end
if alert
puts "exist uncommit files in current branch '#{g.current_branch}' for '#{project_name}'. ignore it? y/n "
flag = STDIN.gets.chomp
unless flag.downcase == "y"
exit
end
end
end
|
#run ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/sub_command.rb', line 27
def run
config_dir = "./"
find_config = false;
begin
result = nil
Dir.chdir(config_dir) do
result = Dir.glob('Gb.yml', File::FNM_DOTMATCH)
end
if result.length > 0
find_config = true
break
else
config_dir = File.expand_path("../", config_dir)
end
end while config_dir.length > 0 && config_dir != "/"
if find_config
Dir.chdir(config_dir) do
self.run_in_config()
end
else
raise Error.new("Current path is not gb workspace. please run 'gb start' first.")
end
end
|
#run_in_config ⇒ Object
52
53
54
|
# File 'lib/sub_command.rb', line 52
def run_in_config
end
|
#save_workspace_config(workspace_config) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/sub_command.rb', line 78
def save_workspace_config(workspace_config)
filename = '.gb'
workspace_config_path = filename
workspace_config.save(workspace_config_path)
@workspace_config = workspace_config
end
|
#validate! ⇒ Object
23
24
25
|
# File 'lib/sub_command.rb', line 23
def validate!
super
end
|
#workspace_config ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/sub_command.rb', line 65
def workspace_config
if @workspace_config.nil?
filename = '.gb'
workspace_config_path = filename
if !File.exist?(workspace_config_path)
help! "workspace config not found. please run 'gb start' first."
end
@workspace_config = WorkSpaceConfig.load_file(workspace_config_path)
end
@workspace_config
end
|