module GitMaintain
Constants
- ACTION_CLASS
Public Class Methods
_log(lvl, str, out=STDOUT)
click to toggle source
# File lib/common.rb, line 172 def _log(lvl, str, out=STDOUT) puts("# " + lvl.to_s() + ": " + str) end
checkDirectConstructor(theClass)
click to toggle source
Check that the constructor was called through loadClass
# 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)
click to toggle source
# 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)
click to toggle source
# 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) # Try to add repo specific opts y = getClass(x) if x != y && y.singleton_methods().index(:check_opts) != nil then y.check_opts(opts) end } end
confirm(opts, msg)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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()))
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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 # Try to add repo specific opts 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)
click to toggle source
# File lib/common.rb, line 197 def setVerbose(val) @@verbose_log = val end
showLog(opts, br1, br2)
click to toggle source
# 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
Private Instance Methods
_log(lvl, str, out=STDOUT)
click to toggle source
# File lib/common.rb, line 172 def _log(lvl, str, out=STDOUT) puts("# " + lvl.to_s() + ": " + str) end
checkDirectConstructor(theClass)
click to toggle source
Check that the constructor was called through loadClass
# 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)
click to toggle source
# 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)
click to toggle source
# 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) # Try to add repo specific opts y = getClass(x) if x != y && y.singleton_methods().index(:check_opts) != nil then y.check_opts(opts) end } end
confirm(opts, msg)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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()))
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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 # Try to add repo specific opts 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)
click to toggle source
# File lib/common.rb, line 197 def setVerbose(val) @@verbose_log = val end
showLog(opts, br1, br2)
click to toggle source
# 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