Module: GitMaintain
- Defined in:
- lib/ci.rb,
lib/repo.rb,
lib/branch.rb,
lib/common.rb,
lib/travis.rb,
lib/addons/RDMACore.rb
Defined Under Namespace
Classes: Branch, CI, CherryPickErrorException, Common, RDMACoreBranch, RDMACoreCI, RDMACoreRepo, Repo, TravisCI
Constant Summary
collapse
- ACTION_CLASS =
[ Common, Branch, Repo ]
- @@custom_classes =
{}
- @@load_class =
[]
- @@verbose_log =
false
Class Method Summary
collapse
-
._log(lvl, str, out = STDOUT) ⇒ Object
-
.checkDirectConstructor(theClass) ⇒ Object
Check that the constructor was called through loadClass.
-
.checkLog(opts, br1, br2, action_msg) ⇒ Object
-
.checkOpts(opts) ⇒ Object
-
.confirm(opts, msg) ⇒ Object
-
.execAction(opts, action) ⇒ Object
-
.getActionAttr(attr) ⇒ Object
-
.getClass(default_class, repo_name = File.basename(Dir.pwd())) ⇒ Object
-
.loadClass(default_class, repo_name, *more) ⇒ Object
-
.log(lvl, str) ⇒ Object
-
.registerCustom(repo_name, classes) ⇒ Object
-
.setOpts(action, optsParser, opts) ⇒ Object
-
.setVerbose(val) ⇒ Object
-
.showLog(opts, br1, br2) ⇒ Object
Class Method Details
._log(lvl, str, out = STDOUT) ⇒ Object
172
173
174
|
# File 'lib/common.rb', line 172
def _log(lvl, str, out=STDOUT)
puts("# " + lvl.to_s() + ": " + str)
end
|
.checkDirectConstructor(theClass) ⇒ Object
Check that the constructor was called through loadClass
85
86
87
88
89
90
91
92
93
|
# File 'lib/common.rb', line 85
def checkDirectConstructor(theClass)
curLoad= @@load_class.last()
cl = theClass
while cl != Object
return if cl == curLoad
cl = cl.superclass
end
raise("Use GitMaintain::loadClass to construct a #{theClass} class")
end
|
.checkLog(opts, br1, br2, action_msg) ⇒ Object
156
157
158
159
160
161
162
|
# File 'lib/common.rb', line 156
def checkLog(opts, br1, br2, action_msg)
puts "Diff between #{br1} and #{br2}"
puts `git shortlog #{br1} ^#{br2}`
return "n" if action_msg.to_s() == ""
rep = confirm(opts, "#{action_msg} this branch")
return rep
end
|
.checkOpts(opts) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/common.rb', line 117
def checkOpts(opts)
ACTION_CLASS.each(){|x|
next if x::ACTION_LIST.index(opts[:action]) == nil
next if x.singleton_methods().index(:check_opts) == nil
x.check_opts(opts)
y = getClass(x)
if x != y && y.singleton_methods().index(:check_opts) != nil then
y.check_opts(opts)
end
}
end
|
.confirm(opts, msg) ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/common.rb', line 141
def confirm(opts, msg)
rep = 't'
while rep != "y" && rep != "n" && rep != '' do
puts "Do you wish to #{msg} ? (y/N): "
if opts[:no] == true then
puts "Auto-replying no due to --no option"
rep = 'n'
else
rep = STDIN.gets.chomp()
end
end
return rep
end
|
.execAction(opts, action) ⇒ Object
132
133
134
135
136
137
138
|
# File 'lib/common.rb', line 132
def execAction(opts, action)
ACTION_CLASS.each(){|x|
next if x::ACTION_LIST.index(action) == nil
x.execAction(opts, action)
break
}
end
|
.getActionAttr(attr) ⇒ Object
96
97
98
|
# File 'lib/common.rb', line 96
def getActionAttr(attr)
return ACTION_CLASS.map(){|x| x.const_get(attr)}.flatten()
end
|
.getClass(default_class, repo_name = File.basename(Dir.pwd())) ⇒ Object
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/common.rb', line 64
def getClass(default_class, repo_name = File.basename(Dir.pwd()))
custom = @@custom_classes[repo_name]
if custom != nil && custom[default_class] != nil then
log(:DEBUG,"Detected custom #{default_class} class for repo '#{repo_name}'")
return custom[default_class]
else
log(:DEBUG,"Detected NO custom #{default_class} classes for repo '#{repo_name}'")
return default_class
end
end
|
.loadClass(default_class, repo_name, *more) ⇒ Object
76
77
78
79
80
81
|
# File 'lib/common.rb', line 76
def loadClass(default_class, repo_name, *more)
@@load_class.push(default_class)
obj = GitMaintain::getClass(default_class, repo_name).new(*more)
@@load_class.pop()
return obj
end
|
.log(lvl, str) ⇒ Object
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/common.rb', line 177
def log(lvl, str)
case lvl
when :DEBUG
_log("DEBUG".magenta(), str) if ENV["DEBUG"].to_s() != ""
when :DEBUG_CI
_log("DEBUG_CI".magenta(), str) if ENV["DEBUG_CI"].to_s() != ""
when :VERBOSE
_log("INFO".blue(), str) if @@verbose_log == true
when :INFO
_log("INFO".green(), str)
when :WARNING
_log("WARNING".brown(), str)
when :ERROR
_log("ERROR".red(), str, STDERR)
else
_log(lvl, str)
end
end
|
.registerCustom(repo_name, classes) ⇒ Object
58
59
60
61
|
# File 'lib/common.rb', line 58
def registerCustom(repo_name, classes)
raise("Multiple class for repo #{repo_name}") if @@custom_classes[repo_name] != nil
@@custom_classes[repo_name] = classes
end
|
.setOpts(action, optsParser, opts) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/common.rb', line 101
def setOpts(action, optsParser, opts)
ACTION_CLASS.each(){|x|
next if x::ACTION_LIST.index(action) == nil
if x.singleton_methods().index(:set_opts) != nil then
x.set_opts(action, optsParser, opts)
end
y = getClass(x)
if x != y && y.singleton_methods().index(:set_opts) != nil then
y.set_opts(action, optsParser, opts)
end
break
}
end
|
.setVerbose(val) ⇒ Object
197
198
199
|
# File 'lib/common.rb', line 197
def setVerbose(val)
@@verbose_log = val
end
|
.showLog(opts, br1, br2) ⇒ Object
165
166
167
168
169
|
# File 'lib/common.rb', line 165
def showLog(opts, br1, br2)
log(:INFO, "Diff between #{br1} and #{br2}")
puts `git log --format=oneline #{br1} ^#{br2}`
return "n"
end
|