git-maintain 0.9.0 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 868f7d13ca258e469a2a32f892646f22486c006b2dd6cdd927a8df4ee349aaaf
4
- data.tar.gz: ee9fabe23d3918015bd195d67ca36d528dba9d993574749134e338143d06429f
3
+ metadata.gz: e9af927752168031d4518212f7ce2114730068296267e7b390db20dde01c3565
4
+ data.tar.gz: 3e72669ad23fb312fb6d6cadc96ec0b3d9ab1c57db9ee97032a756ac6bffae71
5
5
  SHA512:
6
- metadata.gz: 306f260c676c76fc85d2bf87b797e3e8831cdcdd5fb0d847f3d7515e6b68ca35d271dd2348d6b1f850300c22a806be344b8eeeac382e9ed02ab19d3dabe18aab
7
- data.tar.gz: c7a5aae40d1ab800006f6bc8aa9674eaced5a9acc5ec92a71e338d85a75e9e19768dce0be894b3a846c7976a5b2df189292c2973d31c86aadf0e9a9fdbd66a4e
6
+ metadata.gz: 4185735836c059c50a9a76568d678a9a7900fd81a1855c6d3b45edb31245d62e0b877fb1f352e03df94743bef3027c3630be0c9bf57eafb61d82899ed5f58e49
7
+ data.tar.gz: 966702bfd742eee451afc86ed247e0bca851cbd955b4cbf2cad2a2f7e30dbe815600093d286aef7f78a8e5f311680fa57991b0f15965d97f5881d9b144e66dd8
data/CHANGELOG CHANGED
@@ -1,3 +1,22 @@
1
+ ------------------
2
+ 0.11.0 (2025-04-15)
3
+ ------------------
4
+
5
+ * Add github workflow for CI and publishing released rubygems
6
+
7
+ ------------------
8
+ 0.10.0 (2025-04-15)
9
+ ------------------
10
+
11
+ * Fix and extend CI
12
+ * Add addons info in general help and repo summary
13
+ * Add ENV var to point to custom addons
14
+ * Addons updates
15
+ * Set PS1_WARNING to help dealing with subshell status
16
+ * Azure fixes
17
+ * Remove list_stable, monitor_stable, push_stable commands. Replace with --stable option of the regular ones
18
+ * Add pull command
19
+
1
20
  ------------------
2
21
  0.9.0 (2022-10-18)
3
22
  ------------------
data/README.md CHANGED
@@ -13,12 +13,9 @@ The idea is to script most of the maintenance tasks so the maintainer can focus
13
13
  - **delete**: Delete all local branches using the suffix
14
14
  - **steal**: Steal commit from upstream that fixes commit in the branch or were tagged as stable
15
15
  - **list**: List commit present in the branch but not in the stable branch
16
- - **list_stable**: List commit present in the stable branch but not in the latest associated relase
17
16
  - **merge**: Merge branch with suffix specified in -m <suff> into the main branch
18
17
  - **push**: Push branches to github for validation
19
18
  - **monitor**: Check the CI state of all branches
20
- - **push_stable**: Push to stable repo
21
- - **monitor_stable**: Check the CI state of all stable branches
22
19
  - **release**: Create new release on all concerned branches
23
20
  - **reset**: Reset branch against upstream
24
21
  - **submit_release**: Push the to stable and create the release packages
@@ -167,7 +164,7 @@ Some time later, check their status
167
164
 
168
165
  If everything looks good, push to the stable repo
169
166
 
170
- ```git maintain push_stable --version '1[789]'```
167
+ ```git maintain push --stable --version '1[789]'```
171
168
 
172
169
  If patches have been sent to the ML but are not yet accepted, I usually try them out on a "pending" branch.
173
170
 
@@ -225,6 +222,11 @@ To run:
225
222
  Once some work has been done, it is time for a new release.
226
223
 
227
224
  First, unless you're working for the rdma-core repo, you'll need to add your own 'add-on' class to do automatize tyour release process. Please look at 'addons/RDMACore.rb' for an example.
225
+ Addons should be '.rb' file placed either in the same directory as pre-installed addons, or in a directory pointed to by the environment variable GIT_MAINTAIN_ADDON_DIR.
226
+
227
+ To list available addons, run:
228
+
229
+ ```git maintain -h```
228
230
 
229
231
  Then all you need to do is create your release(s)
230
232
 
@@ -232,16 +234,16 @@ Then all you need to do is create your release(s)
232
234
 
233
235
  This will run your addon code. What you usually want to do in there is create a tag and eventually bump version numbers, add releases notes, etc.
234
236
 
235
- I strongly advise here to then use the 'push_stable' command. It will update the branches, but NOT push the tag.
237
+ I strongly advise here to then use the 'push --stable' command. It will update the branches, but NOT push the tag.
236
238
  This means that if something has been broken by the release commit (if any), there is still time to fix it.
237
239
 
238
240
  The tag will not have been propagated anywhere else and can be deleted manually.
239
241
 
240
- ```git maintain push_stable --version '1[789]'```
242
+ ```git maintain push --stable --version '1[789]'```
241
243
 
242
244
  You can then monitor the status on CI
243
245
 
244
- ```git maintain monitor_stable --version '1[789]'```
246
+ ```git maintain monitor --stable --version '1[789]'```
245
247
 
246
248
 
247
249
  Once everything is green, it is time to submit your release
data/bin/git-maintain CHANGED
@@ -23,6 +23,15 @@ actionParser.separator "Possible actions:"
23
23
  ACTION_HELPS.each(){|k, x|
24
24
  actionParser.separator "\t * " + k.to_s() + ": " + x
25
25
  }
26
+ custom_classes = GitMaintain::getCustomClasses()
27
+ if custom_classes.length > 0 then
28
+ actionParser.separator "Custom repo addons available:"
29
+ custom_classes.each(){|k, x|
30
+ actionParser.separator "\t * " + k.to_s()
31
+ }
32
+
33
+ end
34
+
26
35
  rest = actionParser.order!(ARGV);
27
36
  if rest.length <= 0 then
28
37
  STDERR.puts("Error: No action provided")
@@ -2,6 +2,10 @@ module GitMaintain
2
2
  class RDMACoreBranch < Branch
3
3
  REPO_NAME = "rdma-core"
4
4
  AZURE_MIN_VERSION = 18
5
+ ACTION_LIST = Branch::ACTION_LIST + [ :validate ]
6
+ ACTION_HELP = {
7
+ :validate => "Validate that branch still builds"
8
+ }.merge(Branch::ACTION_HELP)
5
9
 
6
10
  def self.set_opts(action, optsParser, opts)
7
11
  opts[:rel_type] = nil
@@ -117,9 +121,18 @@ mv debian/changelog.new debian/changelog")
117
121
  end
118
122
  `rm -f #{tag_path}`
119
123
  end
124
+ def validate(opts)
125
+ @repo.runSystem("rm -Rf build/ && mkdir build/ && cd build/ && cmake .. && make -j")
126
+ raise("Validation failure") if $? != 0
127
+ end
120
128
  end
121
129
  class RDMACoreRepo < Repo
122
130
  AZURE_MIN_VERSION = 18
131
+ ACTION_LIST = Repo::ACTION_LIST + [ :create_stable ]
132
+ ACTION_HELP = {
133
+ :create_stable => "Create a stable branch from a release tag"
134
+ }.merge(Repo::ACTION_HELP)
135
+
123
136
  def submitReleases(opts, new_tags)
124
137
  new_tags.each(){|tag|
125
138
  next if tag !~ /v([0-9]*)\.[0-9]*/
@@ -128,6 +141,49 @@ mv debian/changelog.new debian/changelog")
128
141
  createRelease(opts, tag, major < AZURE_MIN_VERSION)
129
142
  }
130
143
  end
144
+
145
+ def self.set_opts(action, optsParser, opts)
146
+ case action
147
+ when :create_stable then
148
+ optsParser.on("-V", "--version [NUM]", Integer,
149
+ "Specify which version to use to create the stable branch.") {
150
+ |val| opts[:version] = val}
151
+ optsParser.on("-S", "--skip",
152
+ "Skip docker image generation") {
153
+ |val| opts[:skip_docker] = true}
154
+ end
155
+ end
156
+ def self.check_opts(opts)
157
+ case opts[:action]
158
+ when :create_stable
159
+ if opts[:version].to_s() == "" then
160
+ raise "Action #{opts[:action]} requires a branch number to be specified"
161
+ end
162
+ if opts[:br_suff] != "master" then
163
+ raise "Action #{opts[:action]} can only be done on 'master' suffixed branches"
164
+ end
165
+ end
166
+ end
167
+ def create_stable(opts)
168
+ ver = opts[:version].to_s()
169
+ suff = opts[:br_suff]
170
+ if getBranchList(suff).index(ver) != nil then
171
+ raise("Local branch already exists for version #{ver}")
172
+ end
173
+ br = versionToLocalBranch(ver, suff)
174
+ full_ver = ver.gsub(/([0-9]+)/, @stable_base_format)
175
+ runGit("checkout -B #{br} #{full_ver}")
176
+ cmdList = `awk '/\`\`\`/{p=!p; next};p' Documentation/stable.md`.chomp().split("\n")
177
+ if opts[:skip_docker] == true then
178
+ cmdList = cmdList.map(){|x| x if x !~ /build-images/}.compact()
179
+ end
180
+ cmdList = cmdList.map(){|x| (x !~ /pkg azp/) ? x : (x + " || true") }.compact()
181
+ cmdList << "./buildlib/cbuild pkg azp"
182
+
183
+ toDo=cmdList.join("&&")
184
+ runSystem(toDo)
185
+ raise("Fail to run stable creation code") if $? != 0
186
+ end
131
187
  end
132
188
 
133
189
  class RDMACoreCI < CI
@@ -1,19 +1,47 @@
1
1
  module GitMaintain
2
2
  class GitMaintainBranch < Branch
3
3
  REPO_NAME = "git-maintain"
4
+ def self.set_opts(action, optsParser, opts)
5
+ opts[:rel_type] = nil
4
6
 
7
+ case action
8
+ when :release
9
+ optsParser.on("--major [VERSION]", "Release a major version.") {|val|
10
+ opts[:rel_type] = :major
11
+ opts[:new_ver] = val
12
+ }
13
+ optsParser.on("--stable", "Release a stable version.") {
14
+ opts[:rel_type] = :stable
15
+ }
16
+ end
17
+ end
18
+ def self.check_opts(opts)
19
+ if opts[:action] == :release then
20
+ case opts[:rel_type]
21
+ when nil
22
+ raise "No release type specified use --stable or --major"
23
+ when :major
24
+ if opts[:manual_branch] == nil then
25
+ GitMaintain::log(:INFO, "Major release selected. Auto-forcing branch to master")
26
+ opts[:manual_branch] = "master"
27
+ end
28
+ end
29
+ end
30
+ end
5
31
  def release(opts)
6
32
  prev_ver=@repo.runGit("show HEAD:CHANGELOG | grep -A 1 -- '---------' | head -n 2 | tail -n 1 | awk '{ print $1}'").chomp()
7
33
  ver_nums = prev_ver.split(".")
8
34
 
9
- if opts[:manual_branch] == nil then
35
+ if opts[:rel_type] == :stable then
10
36
  new_ver = (ver_nums[0 .. -2] + [ver_nums[-1].to_i() + 1 ]).join(".")
11
37
  git_prev_ver = "v" + (ver_nums[-1] == "0" ? ver_nums[0 .. -2].join(".") : prev_ver)
12
- else
38
+ elsif opts[:rel_type] == :major then
13
39
  new_ver = (ver_nums[0 .. -3] + [ver_nums[-2].to_i() + 1 ] + [ "0" ]).join(".")
40
+ new_ver = opts[:new_ver] if opts[:new_ver] != nil
14
41
  git_prev_ver = "v" + prev_ver
15
42
  end
16
43
 
44
+
17
45
  changes=@repo.runGit("show HEAD:CHANGELOG | awk ' BEGIN {count=0} {if ($1 == \"------------------\") count++; if (count == 0) print $0}'")
18
46
 
19
47
  puts "Preparing release #{prev_ver} => #{new_ver}"
data/lib/azure.rb CHANGED
@@ -13,7 +13,7 @@ module GitMaintain
13
13
  def getState(sha1, resp)
14
14
  br = findBranch(sha1, resp)
15
15
  return "not found" if br == nil
16
- return "running" if br["result"] == nil
16
+ return "started" if br["result"] == nil
17
17
  return br["result"].to_s()
18
18
  end
19
19
  def getLog(sha1, resp)
@@ -34,7 +34,7 @@ module GitMaintain
34
34
  def getTS(sha1, resp)
35
35
  br = findBranch(sha1, resp)
36
36
  raise("Travis build not found") if br == nil
37
- return br["started_at"]
37
+ return br["startTime"]
38
38
  end
39
39
  def checkState(sha1, resp)
40
40
  st = getState(sha1, resp)
data/lib/branch.rb CHANGED
@@ -10,16 +10,15 @@ module GitMaintain
10
10
 
11
11
  class Branch
12
12
  ACTION_LIST = [
13
- :cp, :steal, :list, :list_stable,
14
- :merge, :push, :monitor,
15
- :push_stable, :monitor_stable,
13
+ :cp, :steal, :list,
14
+ :merge, :pull, :push, :monitor,
16
15
  :release, :reset, :create, :delete
17
16
  ]
18
17
  NO_FETCH_ACTIONS = [
19
18
  :cp, :merge, :monitor, :release, :delete
20
19
  ]
21
20
  NO_CHECKOUT_ACTIONS = [
22
- :create, :delete, :list, :list_stable, :push, :monitor, :monitor_stable
21
+ :create, :delete, :list, :push, :monitor
23
22
  ]
24
23
  ALL_BRANCHES_ACTIONS = [
25
24
  :create
@@ -30,12 +29,10 @@ module GitMaintain
30
29
  :delete => "Delete all local branches using the suffix",
31
30
  :steal => "Steal commit from upstream that fixes commit in the branch or were tagged as stable",
32
31
  :list => "List commit present in the branch but not in the stable branch",
33
- :list_stable => "List commit present in the stable branch but not in the latest associated relase",
34
32
  :merge => "Merge branch with suffix specified in -m <suff> into the main branch",
35
33
  :push => "Push branches to github for validation",
34
+ :pull => "Rebase branches on top of the upstream one",
36
35
  :monitor => "Check the CI state of all branches",
37
- :push_stable => "Push to stable repo",
38
- :monitor_stable => "Check the CI state of all stable branches",
39
36
  :release => "Create new release on all concerned branches",
40
37
  :reset => "Reset branch against upstream",
41
38
  }
@@ -58,6 +55,7 @@ module GitMaintain
58
55
  opts[:watch] = false
59
56
  opts[:delete_remote] = false
60
57
  opts[:no_edit] = false
58
+ opts[:stable] = false
61
59
 
62
60
  optsParser.on("-v", "--base-version [MIN_VER]", Integer, "Older release to consider.") {
63
61
  |val| opts[:base_ver] = val}
@@ -84,27 +82,36 @@ module GitMaintain
84
82
  when :delete
85
83
  optsParser.on("--remote", "Delete the remote staging branch instead of the local ones.") {
86
84
  |val| opts[:delete_remote] = true}
85
+ when :list
86
+ optsParser.on("--stable", "List unreleased commits in the upstream stable branch.") {
87
+ opts[:stable] = true }
87
88
  when :merge
88
89
  optsParser.banner += "-m <suffix>"
89
90
  optsParser.on("-m", "--merge [SUFFIX]", "Merge branch with suffix.") {
90
91
  |val| opts[:do_merge] = val}
91
- when :monitor, :monitor_stable
92
+ when :monitor
92
93
  optsParser.on("-w", "--watch <PERIOD>", Integer,
93
94
  "Watch and refresh CI status every <PERIOD>.") {
94
95
  |val| opts[:watch] = val}
96
+ optsParser.on("--stable", "Check CI status on stable repo.") {
97
+ opts[:stable] = true }
98
+ when :pull
99
+ optsParser.on("--stable", "List unreleased commits in the upstream stable branch.") {
100
+ opts[:stable] = true }
95
101
  when :push
96
102
  optsParser.banner += "[-f]"
97
103
  optsParser.on("-f", "--force", "Add --force to git push (for 'push' action).") {
98
- |val| opts[:push_force] = val}
99
- when :push_stable
104
+ opts[:push_force] = true}
105
+ optsParser.on("--stable", "Push to stable repo.") {
106
+ opts[:stable] = true }
100
107
  optsParser.banner += "[-T]"
101
108
  optsParser.on("-T", "--no-ci", "Ignore CI build status and push anyway.") {
102
- |val| opts[:no_ci] = true}
109
+ opts[:no_ci] = true}
103
110
  optsParser.on("-c", "--check", "Check if there is something to be pushed.") {
104
- |val| opts[:check_only] = true}
111
+ opts[:check_only] = true}
105
112
  when :release
106
- optsParser.on("--no-edit", "Do not edit release commit nor tag.") {
107
- opts[:no_edit] = true }
113
+ optsParser.on("--no-edit", "Do not edit release commit nor tag.") {
114
+ opts[:no_edit] = true }
108
115
  when :steal
109
116
  optsParser.banner += "[-a][-b <HEAD>]"
110
117
  optsParser.on("-a", "--all", "Check all commits from master. "+
@@ -117,8 +124,7 @@ module GitMaintain
117
124
  end
118
125
 
119
126
  def self.check_opts(opts)
120
- if opts[:action] == :push_stable ||
121
- opts[:action] == :release then
127
+ if opts[:action] == :release then
122
128
  if opts[:br_suff] != "master" then
123
129
  raise "Action #{opts[:action]} can only be done on 'master' suffixed branches"
124
130
  end
@@ -128,6 +134,11 @@ module GitMaintain
128
134
  raise "Action #{opts[:action]} can NOT be done on 'master' suffixed branches"
129
135
  end
130
136
  end
137
+ if opts[:action] == :push
138
+ if opts[:stable] == true && opts[:push_force] == true then
139
+ raise "Action push can NOT be use both --stable and --force"
140
+ end
141
+ end
131
142
  opts[:version] = [ /.*/ ] if opts[:version].length == 0
132
143
  end
133
144
 
@@ -214,6 +225,7 @@ module GitMaintain
214
225
  end
215
226
 
216
227
  @head = @repo.runGit("rev-parse --verify --quiet #{@local_branch}")
228
+ @valid_ref = "#{@repo.valid_repo}/#{@local_branch}"
217
229
  @remote_ref = "#{@repo.stable_repo}/#{@remote_branch}"
218
230
  @stable_head = @repo.runGit("rev-parse --verify --quiet #{@remote_ref}")
219
231
  case @branch_type
@@ -223,7 +235,7 @@ module GitMaintain
223
235
  @stable_base = @remote_ref
224
236
  end
225
237
  end
226
- attr_reader :version, :local_branch, :head, :remote_branch, :remote_ref, :stable_head,
238
+ attr_reader :version, :local_branch, :head, :remote_branch, :valid_ref, :remote_ref, :stable_head,
227
239
  :verbose_name, :exists, :stable_base
228
240
 
229
241
  def log(lvl, str)
@@ -257,7 +269,7 @@ module GitMaintain
257
269
  @repo.runGitInteractive("cherry-pick #{commit}")
258
270
  if $? != 0 then
259
271
  log(:WARNING, "Cherry pick failure. Starting bash for manual fixes. Exit shell to continue")
260
- @repo.runBash()
272
+ @repo.runBash("PS1_WARNING='CP FIX'")
261
273
  end
262
274
  new_head=@repo.runGit("rev-parse HEAD")
263
275
  # Do not make commit pretty if it was not applied
@@ -305,16 +317,15 @@ module GitMaintain
305
317
  end
306
318
  end
307
319
 
308
- # List commits in the branch that are no in the stable branch
309
320
  def list(opts)
310
321
  GitMaintain::log(:INFO, "Working on #{@verbose_name}")
311
- GitMaintain::showLog(opts, @local_branch, @remote_ref)
312
- end
313
-
314
- # List commits in the stable_branch that are no in the latest release
315
- def list_stable(opts)
316
- GitMaintain::log(:INFO, "Working on #{@verbose_name}")
317
- GitMaintain::showLog(opts, @remote_ref, @repo.runGit("describe --abbrev=0 #{@local_branch}"))
322
+ if opts[:stable] == true then
323
+ # List commits in the stable_branch that are no in the latest release
324
+ GitMaintain::showLog(opts, @remote_ref, @repo.runGit("describe --abbrev=0 #{@local_branch}"))
325
+ else
326
+ # List commits in the branch that are no in the stable branch
327
+ GitMaintain::showLog(opts, @local_branch, @remote_ref)
328
+ end
318
329
  end
319
330
 
320
331
  # Merge merge_branch into this one
@@ -340,7 +351,7 @@ module GitMaintain
340
351
  @repo.runGitInteractive("merge #{merge_branch}")
341
352
  if $? != 0 then
342
353
  log(:WARNING, "Merge failure. Starting bash for manual fixes. Exit shell to continue")
343
- @repo.runBash()
354
+ @repo.runBash("PS1_WARNING='MERGING'")
344
355
  end
345
356
  else
346
357
  log(:INFO, "Skipping merge")
@@ -348,14 +359,55 @@ module GitMaintain
348
359
  end
349
360
  end
350
361
 
362
+ def pull(opts)
363
+ remoteRef = opts[:stable] == true ? @remote_ref : @valid_ref
364
+
365
+ # Make sure branch exists
366
+ @repo.runGit("rev-parse --verify --quiet #{remoteRef}")
367
+ if $? != 0 then
368
+ log(:INFO, "Branch #{remoteRef} does not exists. Skipping...")
369
+ return
370
+ end
371
+ @repo.runGitInteractive("rebase #{remoteRef}")
372
+
373
+ end
351
374
  # Push the branch to the validation repo
352
375
  def push(opts)
353
- if same_sha?(@local_branch, @repo.valid_repo + "/" + @local_branch) ||
376
+ remoteRef = opts[:stable] == true ? @remote_ref : @valid_ref
377
+
378
+ # Check both where we want to push and the final remote_ref
379
+ # We may have destroyed the validation branch but if we already merged
380
+ # in the final repo, no need to worry about it.
381
+ if same_sha?(@local_branch, remoteRef) ||
354
382
  same_sha?(@local_branch, @remote_ref) then
355
383
  log(:INFO, "Nothing to push on #{@local_branch}")
356
384
  return
357
385
  end
358
- return "#{@local_branch}:#{@local_branch}"
386
+
387
+ # For stable branches, we need to check for CI
388
+ if opts[:stable] == true &&
389
+ (opts[:no_ci] != true && @NO_CI != true) &&
390
+ @ci.checkValidState(self, @head) != true then
391
+ log(:WARNING, "Build is not passed on CI. Skipping push to stable")
392
+ return
393
+ end
394
+
395
+ if opts[:check_only] == true then
396
+ GitMaintain::checkLog(opts, @local_branch, @remote_ref, "")
397
+ return
398
+ end
399
+
400
+ # For validation/CI push, let's go and push already
401
+ return "#{@local_branch}:#{@local_branch}" if opts[:stable] != true
402
+
403
+ # For stable, we need to confirm with the user that he really wants to push
404
+ rep = GitMaintain::checkLog(opts, @local_branch, @remote_ref, "submit")
405
+ if rep == "y" then
406
+ return "#{@local_branch}:#{@remote_branch}"
407
+ else
408
+ log(:INFO, "Skipping push to stable")
409
+ return
410
+ end
359
411
  end
360
412
 
361
413
  def self.push_epilogue(opts, branches)
@@ -364,17 +416,26 @@ module GitMaintain
364
416
 
365
417
  return if branches.length == 0
366
418
 
419
+ repo = (opts[:stable] == true) ? opts[:repo].stable_repo : opts[:repo].valid_repo
367
420
  opts[:repo].runGit("push #{opts[:push_force] == true ? "-f" : ""} "+
368
- "#{opts[:repo].valid_repo} #{branches.join(" ")}")
421
+ "#{repo} #{branches.join(" ")}")
369
422
  end
370
423
 
371
424
  # Monitor the build status on CI
372
425
  def monitor(opts)
373
- st = @ci.getValidState(self, @head)
426
+ ts = st = head = nil
374
427
  suff=""
428
+ if opts[:stable] == true then
429
+ st = @ci.getStableState(self, @stable_head)
430
+ ts = @ci.getStableTS(self, @stable_head) if st == "started"
431
+ else
432
+ st = @ci.getValidState(self, @head)
433
+ ts = @ci.getValidTS(self, @head) if st == "started"
434
+ end
435
+
375
436
  case st
376
437
  when "started"
377
- suff= " started at #{@ci.getValidTS(self, @head)}"
438
+ suff= " at #{ts}"
378
439
  end
379
440
  log(:INFO, "Status for v#{@version}: " + st + suff)
380
441
  if @ci.isErrored(self, st) && opts[:watch] == false
@@ -396,52 +457,6 @@ module GitMaintain
396
457
  end
397
458
  end
398
459
 
399
- # Push branch to the stable repo
400
- def push_stable(opts)
401
- if same_sha?(@local_branch, @remote_ref) then
402
- log(:INFO, "Stable is already up-to-date")
403
- return
404
- end
405
-
406
- if (opts[:no_ci] != true && @NO_CI != true) &&
407
- @ci.checkValidState(self, @head) != true then
408
- log(:WARNING, "Build is not passed on CI. Skipping push to stable")
409
- return
410
- end
411
-
412
- if opts[:check_only] == true then
413
- GitMaintain::checkLog(opts, @local_branch, @remote_ref, "")
414
- return
415
- end
416
-
417
- rep = GitMaintain::checkLog(opts, @local_branch, @remote_ref, "submit")
418
- if rep == "y" then
419
- return "#{@local_branch}:#{@remote_branch}"
420
- else
421
- log(:INFO, "Skipping push to stable")
422
- return
423
- end
424
- end
425
-
426
-
427
- def self.push_stable_epilogue(opts, branches)
428
- # Compact to remove empty entries
429
- branches.compact!()
430
-
431
- return if branches.length == 0
432
- opts[:repo].runGit("push #{opts[:repo].stable_repo} #{branches.join(" ")}")
433
- end
434
- # Monitor the build status of the stable branch on CI
435
- def monitor_stable(opts)
436
- st = @ci.getStableState(self, @stable_head)
437
- suff=""
438
- case st
439
- when "started"
440
- suff= " started at #{@ci.getStableTS(self, @stable_head)}"
441
- end
442
- log(:INFO, "Status for v#{@version}: " + st + suff)
443
- end
444
-
445
460
  # Reset the branch to the upstream stable one
446
461
  def reset(opts)
447
462
  if same_sha?(@local_branch, @remote_ref) then
@@ -709,7 +724,7 @@ module GitMaintain
709
724
  pick_one(commit)
710
725
  rescue CherryPickErrorException => e
711
726
  log(:WARNING, "Cherry pick failed. Fix, commit (or reset) and exit.")
712
- @repo.runSystem("/bin/bash")
727
+ @repo.runBash("PS1_WARNING='CP FIX'")
713
728
  end
714
729
  new_head=@repo.runGit("rev-parse HEAD")
715
730
 
@@ -719,7 +734,7 @@ module GitMaintain
719
734
  msg="Custom"
720
735
  orig_cmt=@repo.runGit("rev-parse HEAD")
721
736
  log(:WARNING, "Custom commit, please double-check!")
722
- @repo.runSystem("/bin/bash")
737
+ @repo.runBash("PS1_WARNING='CHECK'")
723
738
  end
724
739
  if new_head != prev_head
725
740
  make_pretty(orig_cmt, msg)
data/lib/common.rb CHANGED
@@ -57,6 +57,7 @@ module GitMaintain
57
57
 
58
58
  def registerCustom(repo_name, classes)
59
59
  raise("Multiple class for repo #{repo_name}") if @@custom_classes[repo_name] != nil
60
+ classes[:name] = repo_name if classes[:name] == nil
60
61
  @@custom_classes[repo_name] = classes
61
62
  end
62
63
  module_function :registerCustom
@@ -73,6 +74,11 @@ module GitMaintain
73
74
  end
74
75
  module_function :getClass
75
76
 
77
+ def getCustomClasses()
78
+ return @@custom_classes
79
+ end
80
+ module_function :getCustomClasses
81
+
76
82
  def loadClass(default_class, repo_name, *more)
77
83
  @@load_class.push(default_class)
78
84
  obj = GitMaintain::getClass(default_class, repo_name).new(*more)
@@ -95,49 +101,64 @@ module GitMaintain
95
101
 
96
102
  def getActionAttr(attr)
97
103
  if Common.const_get(attr).class == Hash
98
- return ACTION_CLASS.inject({}){|h, x| h.merge(x.const_get(attr))}
104
+ return ACTION_CLASS.inject({}){|h, x| h.merge(getClass(x).const_get(attr))}
99
105
  else
100
- return ACTION_CLASS.map(){|x| x.const_get(attr)}.flatten()
106
+ return ACTION_CLASS.map(){|x| getClass(x).const_get(attr)}.flatten()
101
107
  end
102
108
  end
103
109
  module_function :getActionAttr
104
110
 
105
111
  def setOpts(action, optsParser, opts)
106
112
  ACTION_CLASS.each(){|x|
107
- next if x::ACTION_LIST.index(action) == nil
108
- if x.singleton_methods().index(:set_opts) != nil then
113
+ if x::ACTION_LIST.index(action) != nil &&
114
+ x.singleton_methods().index(:set_opts) != nil then
115
+ matched=true
109
116
  x.set_opts(action, optsParser, opts)
110
117
  end
111
118
  # Try to add repo specific opts
112
119
  y = getClass(x)
113
- if x != y && y.singleton_methods().index(:set_opts) != nil then
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
114
124
  y.set_opts(action, optsParser, opts)
115
125
  end
116
- break
126
+ break if matched == true
117
127
  }
118
128
  end
119
129
  module_function :setOpts
120
130
 
121
131
  def checkOpts(opts)
122
132
  ACTION_CLASS.each(){|x|
123
- next if x::ACTION_LIST.index(opts[:action]) == nil
124
- next if x.singleton_methods().index(:check_opts) == nil
125
- x.check_opts(opts)
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
126
138
 
127
139
  # Try to add repo specific opts
128
140
  y = getClass(x)
129
- if x != y && y.singleton_methods().index(:check_opts) != nil then
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
130
145
  y.check_opts(opts)
131
146
  end
132
- }
147
+ break if matched == true
148
+ }
133
149
  end
134
150
  module_function :checkOpts
135
151
 
136
152
  def execAction(opts, action)
137
153
  ACTION_CLASS.each(){|x|
138
- next if x::ACTION_LIST.index(action) == nil
139
- x.execAction(opts, action)
140
- break
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
141
162
  }
142
163
  end
143
164
  module_function :execAction
@@ -217,3 +238,16 @@ Dir.entries(BACKPORT_LIB_DIR + "/addons/").each(){|entry|
217
238
  require entry.sub(/.rb$/, "")
218
239
  }
219
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
+
data/lib/repo.rb CHANGED
@@ -141,8 +141,8 @@ module GitMaintain
141
141
  return @config_cache[entry] ||= runGit("config #{entry} 2> /dev/null").chomp()
142
142
  end
143
143
 
144
- def runBash()
145
- runSystem("bash")
144
+ def runBash(env="")
145
+ runSystem(env + " bash")
146
146
  if $? == 0 then
147
147
  log(:INFO, "Continuing...")
148
148
  else
@@ -334,6 +334,9 @@ module GitMaintain
334
334
  end
335
335
  def summary(opts)
336
336
  log(:INFO, "Configuration summary:")
337
+ if self.class != GitMaintain::Repo then
338
+ log(:INFO, "Using custom repo class: #{self.class.to_s()}")
339
+ end
337
340
  log(:INFO, "Stable remote: #{@stable_repo}")
338
341
  log(:INFO, "Validation remote: #{@valid_repo}")
339
342
  log(:INFO, "")
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.0
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: 2022-10-18 00:00:00.000000000 Z
11
+ date: 2025-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '5'
19
+ version: '5.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '3.0'
30
- - - "<"
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: '5'
26
+ version: '5.0'
33
27
  description: |-
34
28
  Be lazy and let git-maintain do all the heavy lifting for maintaining stable branches.
35
29
  Leaves you only with the essential: reviewing the selected patches and decide where they should go.
@@ -71,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
65
  - !ruby/object:Gem::Version
72
66
  version: '0'
73
67
  requirements: []
74
- rubygems_version: 3.0.8
68
+ rubygems_version: 3.2.33
75
69
  signing_key:
76
70
  specification_version: 4
77
71
  summary: Your ultimate script for maintaining stable branches and releasing your project.