Module: GitMaintain
- Defined in:
- lib/repo.rb,
lib/branch.rb,
lib/common.rb,
lib/travis.rb,
lib/addons/RDMACore.rb
Defined Under Namespace
Classes: Branch, CherryPickErrorException, Common, RDMACoreBranch, Repo, TravisChecker
Constant Summary
collapse
- ACTION_CLASS =
[ Common, Branch, Repo ]
- @@custom_classes =
{}
- @@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
-
.getCustom(repo_name) ⇒ 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
155
156
157
|
# File 'lib/common.rb', line 155
def _log(lvl, str, out=STDOUT)
puts("# " + lvl.to_s() + ": " + str)
end
|
.checkDirectConstructor(theClass) ⇒ Object
Check that the constructor was called through loadClass
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/common.rb', line 80
def checkDirectConstructor(theClass)
depth = 1
while caller_locations(depth, 1)[0].label != "new"
depth +=1
end
raise("Use GitMaintain::loadClass to construct a #{theClass} class") if
caller_locations(depth + 1, 1)[0].label != "loadClass"
end
|
.checkLog(opts, br1, br2, action_msg) ⇒ Object
139
140
141
142
143
144
145
|
# File 'lib/common.rb', line 139
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
107
108
109
110
111
112
|
# File 'lib/common.rb', line 107
def checkOpts(opts)
ACTION_CLASS.each(){|x|
next if x.singleton_methods().index(:check_opts) == nil
x.check_opts(opts)
}
end
|
.confirm(opts, msg) ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/common.rb', line 124
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
115
116
117
118
119
120
121
|
# File 'lib/common.rb', line 115
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
92
93
94
|
# File 'lib/common.rb', line 92
def getActionAttr(attr)
return ACTION_CLASS.map(){|x| x.const_get(attr)}.flatten()
end
|
.getCustom(repo_name) ⇒ Object
62
63
64
|
# File 'lib/common.rb', line 62
def getCustom(repo_name)
return @@custom_classes[repo_name]
end
|
.loadClass(default_class, repo_name, *more) ⇒ Object
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/common.rb', line 67
def loadClass(default_class, repo_name, *more)
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].new(*more)
else
log(:DEBUG,"Detected NO custom #{default_class} classes for repo '#{repo_name}'")
return default_class.new(*more)
end
end
|
.log(lvl, str) ⇒ Object
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/common.rb', line 160
def log(lvl, str)
case lvl
when :DEBUG
_log("DEBUG".magenta(), str) if ENV["DEBUG"].to_s() != ""
when :DEBUG_TRAVIS
_log("DEBUG_TRAVIS".magenta(), str) if ENV["DEBUG_TRAVIS"].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
56
57
58
59
|
# File 'lib/common.rb', line 56
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
97
98
99
100
101
102
103
104
|
# File 'lib/common.rb', line 97
def setOpts(action, optsParser, opts)
ACTION_CLASS.each(){|x|
next if x::ACTION_LIST.index(action) == nil
next if x.singleton_methods().index(:set_opts) == nil
x.set_opts(action, optsParser, opts)
break
}
end
|
.setVerbose(val) ⇒ Object
180
181
182
|
# File 'lib/common.rb', line 180
def setVerbose(val)
@@verbose_log = val
end
|
.showLog(opts, br1, br2) ⇒ Object
148
149
150
151
152
|
# File 'lib/common.rb', line 148
def showLog(opts, br1, br2)
log(:INFO, "Diff between #{br1} and #{br2}")
puts `git log --format=oneline #{br1} ^#{br2}`
return "n"
end
|