git-maintain 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +21 -0
- data/README.md +14 -14
- data/bin/git-maintain +7 -55
- data/git-maintain-completion.sh +3 -3
- data/lib/{addons → git-maintain/addons}/RDMACore.rb +91 -33
- data/lib/{addons → git-maintain/addons}/git-maintain.rb +48 -15
- data/lib/git-maintain/addons/healthd.rb +73 -0
- data/lib/git-maintain/addons/hpc-testing.rb +102 -0
- data/lib/git-maintain/azure.rb +200 -0
- data/lib/git-maintain/branch.rb +944 -0
- data/lib/git-maintain/branch_iterator.rb +148 -0
- data/lib/git-maintain/ci.rb +163 -0
- data/lib/git-maintain/common.rb +117 -0
- data/lib/git-maintain/error.rb +81 -0
- data/lib/git-maintain/repo.rb +573 -0
- data/lib/git-maintain/travis.rb +179 -0
- data/lib/git-maintain.rb +2 -0
- metadata +30 -14
- data/lib/azure.rb +0 -98
- data/lib/branch.rb +0 -759
- data/lib/ci.rb +0 -88
- data/lib/common.rb +0 -253
- data/lib/repo.rb +0 -447
- data/lib/travis.rb +0 -80
data/lib/ci.rb
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
module GitMaintain
|
|
2
|
-
class CI
|
|
3
|
-
|
|
4
|
-
def self.load(repo)
|
|
5
|
-
repo_name = File.basename(repo.path)
|
|
6
|
-
return GitMaintain::loadClass(CI, repo_name, repo)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def initialize(repo)
|
|
10
|
-
GitMaintain::checkDirectConstructor(self.class)
|
|
11
|
-
|
|
12
|
-
@repo = repo
|
|
13
|
-
@cachedJson={}
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
def log(lvl, str)
|
|
18
|
-
GitMaintain::log(lvl, str)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def fetch(uri_str, limit = 10)
|
|
22
|
-
# You should choose a better exception.
|
|
23
|
-
raise ArgumentError, 'too many HTTP redirects' if limit == 0
|
|
24
|
-
|
|
25
|
-
response = Net::HTTP.get_response(URI(uri_str))
|
|
26
|
-
|
|
27
|
-
case response
|
|
28
|
-
when Net::HTTPSuccess then
|
|
29
|
-
response
|
|
30
|
-
when Net::HTTPRedirection then
|
|
31
|
-
location = response['location']
|
|
32
|
-
fetch(location, limit - 1)
|
|
33
|
-
else
|
|
34
|
-
response.value
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
def getJson(base_url, query_label, query, json=true)
|
|
38
|
-
return @cachedJson[query_label] if @cachedJson[query_label] != nil
|
|
39
|
-
url = base_url + query
|
|
40
|
-
uri = URI(url)
|
|
41
|
-
log(:INFO, "Querying CI...")
|
|
42
|
-
log(:DEBUG_CI, url)
|
|
43
|
-
response = fetch(uri)
|
|
44
|
-
raise("CI request failed '#{url}'") if response.code.to_s() != '200'
|
|
45
|
-
|
|
46
|
-
if json == true
|
|
47
|
-
@cachedJson[query_label] = JSON.parse(response.body)
|
|
48
|
-
else
|
|
49
|
-
@cachedJson[query_label] = response.body
|
|
50
|
-
end
|
|
51
|
-
return @cachedJson[query_label]
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
public
|
|
55
|
-
def getValidState(br, sha1)
|
|
56
|
-
raise("Unimplemented")
|
|
57
|
-
end
|
|
58
|
-
def checkValidState(br, sha1)
|
|
59
|
-
raise("Unimplemented")
|
|
60
|
-
end
|
|
61
|
-
def getValidLog(br, sha1)
|
|
62
|
-
raise("Unimplemented")
|
|
63
|
-
end
|
|
64
|
-
def getValidTS(br, sha1)
|
|
65
|
-
raise("Unimplemented")
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def getStableState(br, sha1)
|
|
69
|
-
raise("Unimplemented")
|
|
70
|
-
end
|
|
71
|
-
def checkStableState(br, sha1)
|
|
72
|
-
raise("Unimplemented")
|
|
73
|
-
end
|
|
74
|
-
def getStableLog(br, sha1)
|
|
75
|
-
raise("Unimplemented")
|
|
76
|
-
end
|
|
77
|
-
def getStableTS(br, sha1)
|
|
78
|
-
raise("Unimplemented")
|
|
79
|
-
end
|
|
80
|
-
def emptyCache()
|
|
81
|
-
@cachedJson={}
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def isErrored(br, status)
|
|
85
|
-
raise("Unimplemented")
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
data/lib/common.rb
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.push(BACKPORT_LIB_DIR)
|
|
2
|
-
|
|
3
|
-
require 'ci'
|
|
4
|
-
require 'travis'
|
|
5
|
-
require 'azure'
|
|
6
|
-
require 'repo'
|
|
7
|
-
require 'branch'
|
|
8
|
-
|
|
9
|
-
$LOAD_PATH.pop()
|
|
10
|
-
|
|
11
|
-
class String
|
|
12
|
-
# colorization
|
|
13
|
-
@@is_a_tty = nil
|
|
14
|
-
def colorize(color_code)
|
|
15
|
-
@@is_a_tty = STDOUT.isatty() if @@is_a_tty == nil
|
|
16
|
-
if @@is_a_tty then
|
|
17
|
-
return "\e[#{color_code}m#{self}\e[0m"
|
|
18
|
-
else
|
|
19
|
-
return self
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def red
|
|
24
|
-
colorize(31)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def green
|
|
28
|
-
colorize(32)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def brown
|
|
32
|
-
colorize(33)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def blue
|
|
36
|
-
colorize(34)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def magenta
|
|
40
|
-
colorize(35)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
module GitMaintain
|
|
45
|
-
class Common
|
|
46
|
-
ACTION_LIST = [ :list_actions ]
|
|
47
|
-
ACTION_HELP = {}
|
|
48
|
-
def self.execAction(opts, action)
|
|
49
|
-
puts GitMaintain::getActionAttr("ACTION_LIST").join("\n")
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
ACTION_CLASS = [ Common, Branch, Repo ]
|
|
54
|
-
@@custom_classes = {}
|
|
55
|
-
@@load_class = []
|
|
56
|
-
@@verbose_log = false
|
|
57
|
-
|
|
58
|
-
def registerCustom(repo_name, classes)
|
|
59
|
-
raise("Multiple class for repo #{repo_name}") if @@custom_classes[repo_name] != nil
|
|
60
|
-
classes[:name] = repo_name if classes[:name] == nil
|
|
61
|
-
@@custom_classes[repo_name] = classes
|
|
62
|
-
end
|
|
63
|
-
module_function :registerCustom
|
|
64
|
-
|
|
65
|
-
def getClass(default_class, repo_name = File.basename(Dir.pwd()))
|
|
66
|
-
custom = @@custom_classes[repo_name]
|
|
67
|
-
if custom != nil && custom[default_class] != nil then
|
|
68
|
-
log(:DEBUG,"Detected custom #{default_class} class for repo '#{repo_name}'")
|
|
69
|
-
return custom[default_class]
|
|
70
|
-
else
|
|
71
|
-
log(:DEBUG,"Detected NO custom #{default_class} classes for repo '#{repo_name}'")
|
|
72
|
-
return default_class
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
module_function :getClass
|
|
76
|
-
|
|
77
|
-
def getCustomClasses()
|
|
78
|
-
return @@custom_classes
|
|
79
|
-
end
|
|
80
|
-
module_function :getCustomClasses
|
|
81
|
-
|
|
82
|
-
def loadClass(default_class, repo_name, *more)
|
|
83
|
-
@@load_class.push(default_class)
|
|
84
|
-
obj = GitMaintain::getClass(default_class, repo_name).new(*more)
|
|
85
|
-
@@load_class.pop()
|
|
86
|
-
return obj
|
|
87
|
-
end
|
|
88
|
-
module_function :loadClass
|
|
89
|
-
|
|
90
|
-
# Check that the constructor was called through loadClass
|
|
91
|
-
def checkDirectConstructor(theClass)
|
|
92
|
-
curLoad= @@load_class.last()
|
|
93
|
-
cl = theClass
|
|
94
|
-
while cl != Object
|
|
95
|
-
return if cl == curLoad
|
|
96
|
-
cl = cl.superclass
|
|
97
|
-
end
|
|
98
|
-
raise("Use GitMaintain::loadClass to construct a #{theClass} class")
|
|
99
|
-
end
|
|
100
|
-
module_function :checkDirectConstructor
|
|
101
|
-
|
|
102
|
-
def getActionAttr(attr)
|
|
103
|
-
if Common.const_get(attr).class == Hash
|
|
104
|
-
return ACTION_CLASS.inject({}){|h, x| h.merge(getClass(x).const_get(attr))}
|
|
105
|
-
else
|
|
106
|
-
return ACTION_CLASS.map(){|x| getClass(x).const_get(attr)}.flatten()
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
module_function :getActionAttr
|
|
110
|
-
|
|
111
|
-
def setOpts(action, optsParser, opts)
|
|
112
|
-
ACTION_CLASS.each(){|x|
|
|
113
|
-
if x::ACTION_LIST.index(action) != nil &&
|
|
114
|
-
x.singleton_methods().index(:set_opts) != nil then
|
|
115
|
-
matched=true
|
|
116
|
-
x.set_opts(action, optsParser, opts)
|
|
117
|
-
end
|
|
118
|
-
# Try to add repo specific opts
|
|
119
|
-
y = getClass(x)
|
|
120
|
-
if x != y && y::ACTION_LIST.index(action) != nil &&
|
|
121
|
-
y.singleton_methods().index(:set_opts) != nil then
|
|
122
|
-
matched=true
|
|
123
|
-
x.set_opts(action, optsParser, opts) if x.singleton_methods().index(:set_opts) != nil
|
|
124
|
-
y.set_opts(action, optsParser, opts)
|
|
125
|
-
end
|
|
126
|
-
break if matched == true
|
|
127
|
-
}
|
|
128
|
-
end
|
|
129
|
-
module_function :setOpts
|
|
130
|
-
|
|
131
|
-
def checkOpts(opts)
|
|
132
|
-
ACTION_CLASS.each(){|x|
|
|
133
|
-
if x::ACTION_LIST.index(opts[:action]) != nil &&
|
|
134
|
-
x.singleton_methods().index(:check_opts) != nil then
|
|
135
|
-
matched=true
|
|
136
|
-
x.check_opts(opts)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
# Try to add repo specific opts
|
|
140
|
-
y = getClass(x)
|
|
141
|
-
if x != y && y::ACTION_LIST.index(opts[:action]) != nil &&
|
|
142
|
-
y.singleton_methods().index(:check_opts) != nil then
|
|
143
|
-
matched=true
|
|
144
|
-
x.check_opts(opts) if x.singleton_methods().index(:check_opts) != nil
|
|
145
|
-
y.check_opts(opts)
|
|
146
|
-
end
|
|
147
|
-
break if matched == true
|
|
148
|
-
}
|
|
149
|
-
end
|
|
150
|
-
module_function :checkOpts
|
|
151
|
-
|
|
152
|
-
def execAction(opts, action)
|
|
153
|
-
ACTION_CLASS.each(){|x|
|
|
154
|
-
if x::ACTION_LIST.index(action) != nil
|
|
155
|
-
return x.execAction(opts, action)
|
|
156
|
-
end
|
|
157
|
-
# Try to add repo specific opts
|
|
158
|
-
y = getClass(x)
|
|
159
|
-
if x != y && y::ACTION_LIST.index(opts[:action]) != nil then
|
|
160
|
-
return y.execAction(opts, action)
|
|
161
|
-
end
|
|
162
|
-
}
|
|
163
|
-
end
|
|
164
|
-
module_function :execAction
|
|
165
|
-
|
|
166
|
-
def confirm(opts, msg, ignore_default=false)
|
|
167
|
-
rep = 't'
|
|
168
|
-
while rep != "y" && rep != "n" && rep != '' do
|
|
169
|
-
puts "Do you wish to #{msg} ? (y/N): "
|
|
170
|
-
case (ignore_default == true ? nil : opts[:yn_default])
|
|
171
|
-
when :no
|
|
172
|
-
puts "Auto-replying no due to --no option"
|
|
173
|
-
rep = 'n'
|
|
174
|
-
when :yes
|
|
175
|
-
puts "Auto-replying yes due to --yes option"
|
|
176
|
-
rep = 'y'
|
|
177
|
-
else
|
|
178
|
-
rep = STDIN.gets.chomp()
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
return rep
|
|
182
|
-
end
|
|
183
|
-
module_function :confirm
|
|
184
|
-
|
|
185
|
-
def checkLog(opts, br1, br2, action_msg)
|
|
186
|
-
puts "Diff between #{br1} and #{br2}"
|
|
187
|
-
puts `git log --format=oneline #{br1} ^#{br2}`
|
|
188
|
-
return "n" if action_msg.to_s() == ""
|
|
189
|
-
rep = confirm(opts, "#{action_msg} this branch")
|
|
190
|
-
return rep
|
|
191
|
-
end
|
|
192
|
-
module_function :checkLog
|
|
193
|
-
|
|
194
|
-
def showLog(opts, br1, br2)
|
|
195
|
-
log(:INFO, "Diff between #{br1} and #{br2}")
|
|
196
|
-
puts `git log --format=oneline #{br1} ^#{br2}`
|
|
197
|
-
return "n"
|
|
198
|
-
end
|
|
199
|
-
module_function :showLog
|
|
200
|
-
|
|
201
|
-
def _log(lvl, str, out=STDOUT)
|
|
202
|
-
puts("# " + lvl.to_s() + ": " + str)
|
|
203
|
-
end
|
|
204
|
-
module_function :_log
|
|
205
|
-
|
|
206
|
-
def log(lvl, str)
|
|
207
|
-
case lvl
|
|
208
|
-
when :DEBUG
|
|
209
|
-
_log("DEBUG".magenta(), str) if ENV["DEBUG"].to_s() != ""
|
|
210
|
-
when :DEBUG_CI
|
|
211
|
-
_log("DEBUG_CI".magenta(), str) if ENV["DEBUG_CI"].to_s() != ""
|
|
212
|
-
when :VERBOSE
|
|
213
|
-
_log("INFO".blue(), str) if @@verbose_log == true
|
|
214
|
-
when :INFO
|
|
215
|
-
_log("INFO".green(), str)
|
|
216
|
-
when :WARNING
|
|
217
|
-
_log("WARNING".brown(), str)
|
|
218
|
-
when :ERROR
|
|
219
|
-
_log("ERROR".red(), str, STDERR)
|
|
220
|
-
else
|
|
221
|
-
_log(lvl, str)
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
module_function :log
|
|
225
|
-
|
|
226
|
-
def setVerbose(val)
|
|
227
|
-
@@verbose_log = val
|
|
228
|
-
end
|
|
229
|
-
module_function :setVerbose
|
|
230
|
-
end
|
|
231
|
-
$LOAD_PATH.pop()
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
# Load all custom classes
|
|
235
|
-
$LOAD_PATH.push(BACKPORT_LIB_DIR + "/addons/")
|
|
236
|
-
Dir.entries(BACKPORT_LIB_DIR + "/addons/").each(){|entry|
|
|
237
|
-
next if (!File.file?(BACKPORT_LIB_DIR + "/addons/" + entry) || entry !~ /\.rb$/ );
|
|
238
|
-
require entry.sub(/.rb$/, "")
|
|
239
|
-
}
|
|
240
|
-
$LOAD_PATH.pop()
|
|
241
|
-
|
|
242
|
-
if ENV["GIT_MAINTAIN_ADDON_DIR"].to_s() != "" then
|
|
243
|
-
ADDON_DIR=ENV["GIT_MAINTAIN_ADDON_DIR"].to_s()
|
|
244
|
-
if Dir.exists?(ADDON_DIR) then
|
|
245
|
-
$LOAD_PATH.push(ADDON_DIR)
|
|
246
|
-
Dir.entries(ADDON_DIR).each(){|entry|
|
|
247
|
-
next if (!File.file?(ADDON_DIR + "/" + entry) || entry !~ /\.rb$/ );
|
|
248
|
-
require entry.sub(/.rb$/, "")
|
|
249
|
-
}
|
|
250
|
-
$LOAD_PATH.pop()
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
|