git-maintain 0.5.0.pre.11.g7c08aac → 0.5.0.pre.13.ge72a2b0
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 +2 -0
- data/bin/git-maintain +2 -0
- data/lib/branch.rb +34 -35
- data/lib/common.rb +66 -2
- data/lib/repo.rb +24 -8
- data/lib/travis.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44043bb13255df2557298655ba268fa2775f32f543f0fc50785dc9944e47b578
|
4
|
+
data.tar.gz: b3af11b591ce0c4096c4df44cf8d52c7d8bd8015e5d5cb1204bbbfe0d8b6656d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb884e28eb8e4f60f262a36aed4bcab2c383ee80ebc3952f847d89d9f9c77bac8db409474d2062beda3e263225ddb43ce552f01a38ee492fbddb5200a49a0cae
|
7
|
+
data.tar.gz: 671e9220b866fa12c048dc531e609726e723b6a5c0028c0998868f976b42fef8b0f5e686dd42b9c9db96bd39e14afb4ade2d5feff7a0cda8ea87af4f1c292b03
|
data/CHANGELOG
CHANGED
data/bin/git-maintain
CHANGED
@@ -45,6 +45,8 @@ optsParser.on("-b", "--branch-suffix [SUFFIX]", "Branch suffix. Default is 'mast
|
|
45
45
|
|val| opts[:br_suff] = val}
|
46
46
|
optsParser.on("-n", "--no", "Assume no to all questions.") {
|
47
47
|
|val| opts[:no] = true}
|
48
|
+
optsParser.on("--verbose", "Displays more informations.") {
|
49
|
+
|val| GitMaintain::setVerbose(true)}
|
48
50
|
GitMaintain::setOpts(action, optsParser, opts)
|
49
51
|
|
50
52
|
rest = optsParser.order!(ARGV);
|
data/lib/branch.rb
CHANGED
@@ -120,10 +120,10 @@ module GitMaintain
|
|
120
120
|
branch = Branch::load(repo, br, travis, opts[:br_suff])
|
121
121
|
case branch.is_targetted?(opts)
|
122
122
|
when :too_old
|
123
|
-
|
123
|
+
log(:VERBOSE, "Skipping older v#{branch.version}")
|
124
124
|
next
|
125
125
|
when :no_match
|
126
|
-
|
126
|
+
log(:VERBOSE, "Skipping v#{branch.version} not matching #{opts[:version].to_s()}")
|
127
127
|
next
|
128
128
|
end
|
129
129
|
branch
|
@@ -136,10 +136,7 @@ module GitMaintain
|
|
136
136
|
system("clear; date") if opts[:watch] != false
|
137
137
|
branchList.each(){|branch|
|
138
138
|
if NO_CHECKOUT_ACTIONS.index(action) == nil then
|
139
|
-
|
140
|
-
puts "# Working on #{branch.verbose_name}"
|
141
|
-
puts "###############################"
|
142
|
-
|
139
|
+
GitMaintain::log(:INFO, "Working on #{branch.verbose_name}")
|
143
140
|
branch.checkout()
|
144
141
|
end
|
145
142
|
branch.send(action, opts)
|
@@ -177,6 +174,10 @@ module GitMaintain
|
|
177
174
|
end
|
178
175
|
attr_reader :version, :local_branch, :head, :remote_branch, :remote_ref, :stable_head, :verbose_name
|
179
176
|
|
177
|
+
def log(lvl, str)
|
178
|
+
GitMaintain::log(lvl, str)
|
179
|
+
end
|
180
|
+
|
180
181
|
def is_targetted?(opts)
|
181
182
|
return true if @branch_type == :user_specified
|
182
183
|
if @version.to_i < opts[:base_ver] then
|
@@ -201,9 +202,8 @@ module GitMaintain
|
|
201
202
|
opts[:commits].each(){|commit|
|
202
203
|
@repo.runGit("cherry-pick #{commit}")
|
203
204
|
if $? != 0 then
|
204
|
-
|
205
|
-
@repo.
|
206
|
-
puts "Continuing..."
|
205
|
+
log(:WARNING, "Cherry pick failure. Starting bash for manual fixes. Exit shell to continue")
|
206
|
+
@repo.runBash()
|
207
207
|
end
|
208
208
|
make_pretty(commit)
|
209
209
|
}
|
@@ -219,8 +219,8 @@ module GitMaintain
|
|
219
219
|
sha = @repo.runGit("rev-parse 'git-maintain/steal/last/#{@stable_base}' 2>&1")
|
220
220
|
if $? == 0 then
|
221
221
|
base_ref=sha
|
222
|
-
|
223
|
-
|
222
|
+
log(:VERBOSE, "Starting from last successfull run:")
|
223
|
+
log(:VERBOSE, @repo.getCommitHeadline(base_ref))
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
@@ -232,9 +232,9 @@ module GitMaintain
|
|
232
232
|
# can just steal from this point on the next run
|
233
233
|
if res == true then
|
234
234
|
@repo.runGit("tag -f 'git-maintain/steal/last/#{@stable_base}' origin/master")
|
235
|
-
|
236
|
-
|
237
|
-
|
235
|
+
log(:VERBOSE, "Marking new last successfull run at:")
|
236
|
+
log(:VERBOSE, @repo.getCommitHeadline(master_sha))
|
237
|
+
end
|
238
238
|
end
|
239
239
|
|
240
240
|
# List commits in the branch that are no in the stable branch
|
@@ -249,12 +249,11 @@ module GitMaintain
|
|
249
249
|
if rep == "y" then
|
250
250
|
@repo.runGit("merge #{merge_branch}")
|
251
251
|
if $? != 0 then
|
252
|
-
|
253
|
-
@repo.
|
254
|
-
puts "Continuing..."
|
252
|
+
log(:WARNING, "Merge failure. Starting bash for manual fixes. Exit shell to continue")
|
253
|
+
@repo.runBash()
|
255
254
|
end
|
256
255
|
else
|
257
|
-
|
256
|
+
log(:INFO, "Skipping merge")
|
258
257
|
return
|
259
258
|
end
|
260
259
|
end
|
@@ -272,7 +271,7 @@ module GitMaintain
|
|
272
271
|
when "started"
|
273
272
|
suff= " started at #{@travis.getValidTS(head)}"
|
274
273
|
end
|
275
|
-
|
274
|
+
log(:INFO, "Status for v#{@version}: " + st + suff)
|
276
275
|
if st == "failed"
|
277
276
|
rep = "y"
|
278
277
|
suff=""
|
@@ -296,13 +295,13 @@ module GitMaintain
|
|
296
295
|
def push_stable(opts)
|
297
296
|
if (opts[:no_travis] != true && @NO_TRAVIS != true) &&
|
298
297
|
@travis.checkValidState(@head) != true then
|
299
|
-
|
298
|
+
log(:WARNING, "Build is not passed on travis. Skipping push to stable")
|
300
299
|
return
|
301
300
|
end
|
302
301
|
c1=@repo.runGit("rev-parse --verify --quiet #{@local_branch}")
|
303
302
|
c2=@repo.runGit("rev-parse --verify --quiet #{@remote_ref}")
|
304
303
|
if c1 == c2 then
|
305
|
-
|
304
|
+
log(:INFO, "Stable is already up-to-date")
|
306
305
|
return
|
307
306
|
end
|
308
307
|
|
@@ -315,7 +314,7 @@ module GitMaintain
|
|
315
314
|
if rep == "y" then
|
316
315
|
@repo.runGit("push #{@repo.stable_repo} #{@local_branch}:#{@remote_branch}")
|
317
316
|
else
|
318
|
-
|
317
|
+
log(:INFO, "Skipping push to stable")
|
319
318
|
return
|
320
319
|
end
|
321
320
|
end
|
@@ -328,7 +327,7 @@ module GitMaintain
|
|
328
327
|
when "started"
|
329
328
|
suff= " started at #{@travis.getStableTS(@stable_head)}"
|
330
329
|
end
|
331
|
-
|
330
|
+
log(:INFO, "Status for v#{@version}: " + st + suff)
|
332
331
|
end
|
333
332
|
|
334
333
|
# Reset the branch to the upstream stable one
|
@@ -337,13 +336,13 @@ module GitMaintain
|
|
337
336
|
if rep == "y" then
|
338
337
|
@repo.runGit("reset --hard #{@remote_ref}")
|
339
338
|
else
|
340
|
-
|
339
|
+
log(:INFO, "Skipping reset")
|
341
340
|
return
|
342
341
|
end
|
343
342
|
end
|
344
343
|
|
345
344
|
def release(opts)
|
346
|
-
|
345
|
+
log(:ERROR,"#No release command available for this repo")
|
347
346
|
end
|
348
347
|
|
349
348
|
private
|
@@ -375,7 +374,7 @@ module GitMaintain
|
|
375
374
|
# This might happen if someone pointed to a commit that doesn't exist in our
|
376
375
|
# tree.
|
377
376
|
if $? != 0 then
|
378
|
-
|
377
|
+
log(:WARNING, "Commit #{src_commit} points to a SHA #{commit} not in tree")
|
379
378
|
return false
|
380
379
|
end
|
381
380
|
|
@@ -467,11 +466,11 @@ module GitMaintain
|
|
467
466
|
def confirm_one(opts, commit)
|
468
467
|
rep=""
|
469
468
|
do_cp=false
|
470
|
-
puts @repo.
|
469
|
+
puts @repo.getCommitHeadline(commit)
|
471
470
|
while rep != "y" do
|
472
471
|
puts "Do you want to steal this commit ? (y/n/b/?)"
|
473
472
|
if opts[:no] == true then
|
474
|
-
|
473
|
+
log(:INFO, "Auto-replying no due to --no option")
|
475
474
|
rep = 'n'
|
476
475
|
break
|
477
476
|
else
|
@@ -479,10 +478,10 @@ module GitMaintain
|
|
479
478
|
end
|
480
479
|
case rep
|
481
480
|
when "n"
|
482
|
-
|
481
|
+
log(:INFO, "Skip this commit")
|
483
482
|
break
|
484
483
|
when "b"
|
485
|
-
|
484
|
+
LOG(:INFO, "Blacklisting this commit for the current branch")
|
486
485
|
add_blacklist(commit)
|
487
486
|
break
|
488
487
|
when "y"
|
@@ -492,7 +491,7 @@ module GitMaintain
|
|
492
491
|
when "?"
|
493
492
|
puts @repo.runGit("show #{commit}")
|
494
493
|
else
|
495
|
-
|
494
|
+
log(:ERROR, "Invalid answer $rep")
|
496
495
|
puts @repo.runGit("show --format=oneline --no-patch --no-decorate #{commit}")
|
497
496
|
end
|
498
497
|
end
|
@@ -522,8 +521,8 @@ module GitMaintain
|
|
522
521
|
# Check if it's not blacklisted by a git-notes
|
523
522
|
if is_blacklisted?(orig_cmt) == true then
|
524
523
|
# Commit is blacklisted
|
525
|
-
|
526
|
-
@repo.runGit("
|
524
|
+
log(:INFO, "Skipping 'blacklisted' commit " +
|
525
|
+
@repo.runGit("log --format=oneline --no-patch --no-decorate #{orig_cmt}"))
|
527
526
|
return true
|
528
527
|
end
|
529
528
|
|
@@ -533,7 +532,7 @@ module GitMaintain
|
|
533
532
|
begin
|
534
533
|
pick_one(commit)
|
535
534
|
rescue CherryPickErrorException => e
|
536
|
-
|
535
|
+
log(:WARNING, "Cherry pick failed. Fix, commit (or reset) and exit.")
|
537
536
|
@repo.runSystem("/bin/bash")
|
538
537
|
return false
|
539
538
|
end
|
@@ -543,7 +542,7 @@ module GitMaintain
|
|
543
542
|
if orig_cmt == "" then
|
544
543
|
msg="Custom"
|
545
544
|
orig_cmt=@repo.runGit("rev-parse HEAD")
|
546
|
-
|
545
|
+
log(:WARNING, "Custom commit, please double-check!")
|
547
546
|
@repo.runSystem("/bin/bash")
|
548
547
|
end
|
549
548
|
make_pretty(orig_cmt, msg)
|
data/lib/common.rb
CHANGED
@@ -6,6 +6,39 @@ require 'branch'
|
|
6
6
|
|
7
7
|
$LOAD_PATH.pop()
|
8
8
|
|
9
|
+
class String
|
10
|
+
# colorization
|
11
|
+
@@is_a_tty = nil
|
12
|
+
def colorize(color_code)
|
13
|
+
@@is_a_tty = STDOUT.isatty() if @@is_a_tty == nil
|
14
|
+
if @@is_a_tty then
|
15
|
+
return "\e[#{color_code}m#{self}\e[0m"
|
16
|
+
else
|
17
|
+
return self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def red
|
22
|
+
colorize(31)
|
23
|
+
end
|
24
|
+
|
25
|
+
def green
|
26
|
+
colorize(32)
|
27
|
+
end
|
28
|
+
|
29
|
+
def brown
|
30
|
+
colorize(33)
|
31
|
+
end
|
32
|
+
|
33
|
+
def blue
|
34
|
+
colorize(34)
|
35
|
+
end
|
36
|
+
|
37
|
+
def magenta
|
38
|
+
colorize(35)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
9
42
|
module GitMaintain
|
10
43
|
class Common
|
11
44
|
ACTION_LIST = [ :list_actions ]
|
@@ -18,6 +51,8 @@ module GitMaintain
|
|
18
51
|
ACTION_CLASS = [ Common, Branch, Repo ]
|
19
52
|
@@custom_classes = {}
|
20
53
|
|
54
|
+
@@verbose_log = false
|
55
|
+
|
21
56
|
def registerCustom(repo_name, classes)
|
22
57
|
raise("Multiple class for repo #{repo_name}") if @@custom_classes[repo_name] != nil
|
23
58
|
@@custom_classes[repo_name] = classes
|
@@ -32,10 +67,10 @@ module GitMaintain
|
|
32
67
|
def loadClass(default_class, repo_name, *more)
|
33
68
|
custom = @@custom_classes[repo_name]
|
34
69
|
if custom != nil && custom[default_class] != nil then
|
35
|
-
|
70
|
+
log(:DEBUG,"Detected custom #{default_class} class for repo '#{repo_name}'")
|
36
71
|
return custom[default_class].new(*more)
|
37
72
|
else
|
38
|
-
|
73
|
+
log(:DEBUG,"Detected NO custom #{default_class} classes for repo '#{repo_name}'")
|
39
74
|
return default_class.new(*more)
|
40
75
|
end
|
41
76
|
end
|
@@ -110,6 +145,35 @@ module GitMaintain
|
|
110
145
|
end
|
111
146
|
module_function :checkLog
|
112
147
|
|
148
|
+
def _log(lvl, str, out=STDOUT)
|
149
|
+
puts("# " + lvl.to_s() + ": " + str)
|
150
|
+
end
|
151
|
+
module_function :_log
|
152
|
+
|
153
|
+
def log(lvl, str)
|
154
|
+
case lvl
|
155
|
+
when :DEBUG
|
156
|
+
_log("DEBUG".magenta(), str) if ENV["DEBUG"].to_s() != ""
|
157
|
+
when :DEBUG_TRAVIS
|
158
|
+
_log("DEBUG_TRAVIS".magenta(), str) if ENV["DEBUG_TRAVIS"].to_s() != ""
|
159
|
+
when :VERBOSE
|
160
|
+
_log("INFO".blue(), str) if @@verbose_log == true
|
161
|
+
when :INFO
|
162
|
+
_log("INFO".green(), str)
|
163
|
+
when :WARNING
|
164
|
+
_log("WARNING".brown(), str)
|
165
|
+
when :ERROR
|
166
|
+
_log("ERROR".red(), str, STDERR)
|
167
|
+
else
|
168
|
+
_log(lvl, str)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
module_function :log
|
172
|
+
|
173
|
+
def setVerbose(val)
|
174
|
+
@@verbose_log = val
|
175
|
+
end
|
176
|
+
module_function :setVerbose
|
113
177
|
end
|
114
178
|
$LOAD_PATH.pop()
|
115
179
|
|
data/lib/repo.rb
CHANGED
@@ -67,6 +67,10 @@ module GitMaintain
|
|
67
67
|
end
|
68
68
|
attr_reader :path, :remote_valid, :remote_stable, :valid_repo, :stable_repo
|
69
69
|
|
70
|
+
def log(lvl, str)
|
71
|
+
GitMaintain::log(lvl, str)
|
72
|
+
end
|
73
|
+
|
70
74
|
def run(cmd)
|
71
75
|
return `cd #{@path} && #{cmd}`
|
72
76
|
end
|
@@ -74,10 +78,8 @@ module GitMaintain
|
|
74
78
|
return system("cd #{@path} && #{cmd}")
|
75
79
|
end
|
76
80
|
def runGit(cmd)
|
77
|
-
|
78
|
-
|
79
|
-
puts "Running git command '#{cmd}'"
|
80
|
-
end
|
81
|
+
log(:DEBUG, "Called from #{caller[1]}")
|
82
|
+
log(:DEBUG, "Running git command '#{cmd}'")
|
81
83
|
return `git --work-tree=#{@path} #{cmd}`.chomp()
|
82
84
|
end
|
83
85
|
def runGitImap(cmd)
|
@@ -90,8 +92,22 @@ module GitMaintain
|
|
90
92
|
fi; git --work-tree=#{@path} imap-send #{cmd}`
|
91
93
|
end
|
92
94
|
|
95
|
+
def runBash()
|
96
|
+
runSystem("bash")
|
97
|
+
if $? == 0 then
|
98
|
+
log(:INFO, "Continuing...")
|
99
|
+
else
|
100
|
+
log(:ERROR, "Shell exited with code #{$?}. Exiting")
|
101
|
+
raise("Cancelled by user")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def getCommitHeadline(sha)
|
106
|
+
return runGit("show --format=oneline --no-patch --no-decorate #{sha}")
|
107
|
+
end
|
108
|
+
|
93
109
|
def stableUpdate()
|
94
|
-
|
110
|
+
log(:VERBOSE, "Fetching stable updates...")
|
95
111
|
runGit("fetch #{@stable_repo}")
|
96
112
|
end
|
97
113
|
def getStableList(br_suff)
|
@@ -125,11 +141,11 @@ module GitMaintain
|
|
125
141
|
|
126
142
|
new_tags = local_tags - remote_tags
|
127
143
|
if new_tags.empty? then
|
128
|
-
|
144
|
+
log(:INFO, "All tags are already submitted.")
|
129
145
|
return
|
130
146
|
end
|
131
147
|
|
132
|
-
|
148
|
+
log(:WARNING, "This will officially release these tags: #{new_tags.join(", ")}")
|
133
149
|
rep = GitMaintain::confirm(opts, "release them")
|
134
150
|
if rep != 'y' then
|
135
151
|
raise "Aborting.."
|
@@ -179,7 +195,7 @@ module GitMaintain
|
|
179
195
|
puts runGitImap("< #{mail_path}; rm -f #{mail_path}")
|
180
196
|
end
|
181
197
|
|
182
|
-
|
198
|
+
log(:WARNING, "Last chance to cancel before submitting")
|
183
199
|
rep= GitMaintain::confirm(opts, "submit these releases")
|
184
200
|
if rep != 'y' then
|
185
201
|
raise "Aborting.."
|
data/lib/travis.rb
CHANGED
@@ -15,6 +15,10 @@ module GitMaintain
|
|
15
15
|
end
|
16
16
|
|
17
17
|
private
|
18
|
+
def log(lvl, str)
|
19
|
+
GitMaintain::log(lvl, str)
|
20
|
+
end
|
21
|
+
|
18
22
|
def fetch(uri_str, limit = 10)
|
19
23
|
# You should choose a better exception.
|
20
24
|
raise ArgumentError, 'too many HTTP redirects' if limit == 0
|
@@ -35,8 +39,8 @@ module GitMaintain
|
|
35
39
|
return @cachedJson[query_label] if @cachedJson[query_label] != nil
|
36
40
|
url = TRAVIS_URL + query
|
37
41
|
uri = URI(url)
|
38
|
-
|
39
|
-
|
42
|
+
log(:INFO, "Querying travis...")
|
43
|
+
log(DEBUG_TRAVIS, url)
|
40
44
|
response = fetch(uri)
|
41
45
|
raise("Travis request failed '#{url}'") if response.code.to_s() != '200'
|
42
46
|
|
@@ -75,11 +79,11 @@ module GitMaintain
|
|
75
79
|
return getJson(:br_stable, 'repos/' + @repo.remote_stable + '/branches')
|
76
80
|
end
|
77
81
|
def findBranch(sha1, resp)
|
78
|
-
|
82
|
+
log(:DEBUG_TRAVIS, "Looking for build for #{sha1}")
|
79
83
|
resp["branches"].each(){|br|
|
80
84
|
commit=resp["commits"].select(){|e| e["id"] == br["commit_id"]}.first()
|
81
85
|
raise("Incomplete JSON received from Travis") if commit == nil
|
82
|
-
|
86
|
+
log(:DEBUG_TRAVIS, "Found entry for sha #{commit["sha"]}")
|
83
87
|
next if commit["sha"] != sha1
|
84
88
|
return br
|
85
89
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0.pre.
|
4
|
+
version: 0.5.0.pre.13.ge72a2b0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Morey-Chaisemartin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: github-release
|