git-maintain 0.12.0 → 0.14.2

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: 3f55eb06d04154df930e2e69d85b4d0d3b882361681f2d70a2acc503dc9abfad
4
- data.tar.gz: 6d4597f517459cf6304ca419ef7b4897b894c032200f311a1efd549524fc13ba
3
+ metadata.gz: 14413a6c304673d11dd57a4b5ecec51e2717aff5e77b2b6c7caade9d89a29ed4
4
+ data.tar.gz: 0e74198aea4155a40790169c51123293aa0811ae41b5f0d17e0a8b81f72bbf1b
5
5
  SHA512:
6
- metadata.gz: 9363ed5154f62cef4ac12ee4a1599c108f48bd192dcaea8154cbf4b0db3f80eda06baf8972f39986d8870b6cf5c812ad6877d0fd75c24eb594e4f9e96dc53731
7
- data.tar.gz: 97d60ac6e78bec2d3c8c6233e99412f4941c1e9fed9f69f1ce9acc923e9f3060279c9a82d7dd6f50a66b6c50c6799c0d686e86aeaec984b8fe704e018497f3d9
6
+ metadata.gz: c8ba35679ef2ea3676be16e59db74bbc3266eed55f4ab73f9d28d923f11d67c058833a3eeb984252d5d089b28485d9a44536729f8db68918c371fe6581bf1667
7
+ data.tar.gz: ee69deed0ff1ceb20900d252cd74948921847a488aedd01226001be2a82dc3cf248662a4310fe5ca30188d7fb98ed83d108ca37cb6e1e4c26aec7d53cf458daf
data/CHANGELOG CHANGED
@@ -1,3 +1,26 @@
1
+ ------------------
2
+ 0.14.2 (2026-09-09)
3
+ ------------------
4
+
5
+ ------------------
6
+ 0.14.1 (2026-09-09)
7
+ ------------------
8
+
9
+ ------------------
10
+ 0.14.0 (2026-09-09)
11
+ ------------------
12
+
13
+ ------------------
14
+ 0.13.0 (2026-09-09)
15
+ ------------------
16
+
17
+ * Major internal refactor
18
+ * CLI code has been moded to cli_class_tool
19
+ * Replace all return values by exceptions
20
+ * Cleanup path handling
21
+ * Simplify Branch class by introducing a BranchIterator
22
+ * In theory, fully transparent for end-users
23
+
1
24
  ------------------
2
25
  0.12.0 (2025-09-11)
3
26
  ------------------
data/README.md CHANGED
@@ -27,10 +27,10 @@ The idea is to script most of the maintenance tasks so the maintainer can focus
27
27
  - Load git-maintain-completion.sh for shell completion
28
28
 
29
29
  ## Remote setup
30
- - the 'github' remote should be your own WIP github to test out branches before submitting to the official repo.
30
+ - the 'github' remote should be your own WIP github to test out branches before submitting to the official repo.
31
31
  Also know as the 'Validation' repo. It can be switched to another remote by setting maintain.valid-repo=xxx in your gitconfig
32
32
  - the 'origin' remote should be the official repo in read-only mode to avoid any accidental pushes
33
- - the 'stable' remote should be the official repo in RW mode.
33
+ - the 'stable' remote should be the official repo in RW mode.
34
34
  Also know as the 'Stable' repo. It can be switched to another remote by setting maintain.stable-repo=xxx in your gitconfig
35
35
 
36
36
  ## Stealing commits
@@ -38,10 +38,10 @@ The idea is to script most of the maintenance tasks so the maintainer can focus
38
38
  The steal feature uses was shamelessly copied it from https://git.kernel.org/pub/scm/linux/kernel/git/sashal/stable-tools.git/tree/
39
39
 
40
40
  ## Making releases
41
- The release process being very specific to each project, the release command does nothing by default.
41
+ The release process being very specific to each project, the release command does nothing by default.
42
42
  However the behaviour can be overriden for specific repo (detected by repo name)
43
43
 
44
- Check the lib/addons/RDMACore.rb for an example.
44
+ Check the lib/addons/RDMACore.rb for an example.
45
45
  In this case, the release command bump the version in all the appropriate files (after computing the previous and next version numbers), commit and tags the commit.
46
46
 
47
47
 
@@ -122,12 +122,12 @@ $ git maintain summary
122
122
  # INFO: Configuration summary:
123
123
  # INFO: Stable remote: stable
124
124
  # INFO: Validation remote: github
125
- # INFO:
125
+ # INFO:
126
126
  # INFO: Branch config:
127
127
  # INFO: Local branch format: /dev\/stable-v([0-9]*)/
128
128
  # INFO: Remote stable branch format: stable-v\1
129
129
  # INFO: Remote stable base format: v\1
130
- # INFO:
130
+ # INFO:
131
131
  # INFO: Local branches:
132
132
  # INFO: dev/stable-v15/master -> stable/stable-v15
133
133
  # INFO: dev/stable-v16/master -> stable/stable-v16
@@ -137,7 +137,7 @@ $ git maintain summary
137
137
  # INFO: dev/stable-v20/master -> stable/stable-v20
138
138
  # INFO: dev/stable-v21/master -> stable/stable-v21
139
139
  # INFO: dev/stable-v22/master -> stable/stable-v22
140
- # INFO:
140
+ # INFO:
141
141
  # INFO: Upstream branches:
142
142
  # INFO: <MISSING> -> stable/stable-v23
143
143
  ```
@@ -262,16 +262,16 @@ This is a summary of all the settings that can be set in the git config:
262
262
 
263
263
  - `maintain.valid-repo`: Remote github repo to test out branches before submitting. Default = `github`
264
264
  - `maintain.stable-repo`: Remote stable github repository t submit validated branches and new releases. Default = `stable`
265
- - `maintain.autofetch`: Enable/Disable auto fetching.
266
- Can be overriden by the --[no-]fetch option on the CLI.
265
+ - `maintain.autofetch`: Enable/Disable auto fetching.
266
+ Can be overriden by the --[no-]fetch option on the CLI.
267
267
  If unset, autofetch is enabled
268
- - `maintain.branch-format`: Local branch name space that also extracts the version.
268
+ - `maintain.branch-format`: Local branch name space that also extracts the version.
269
269
  Example: dev\/stable-v([0-9]*) will allow all branch names dev/stable-vXXX/foo to be used against stable branch with version XXX
270
- - `maintain.stable-branch-format`: Name of the stable branch generated with the version extracted by the `maintain.branch-format` regexp.
270
+ - `maintain.stable-branch-format`: Name of the stable branch generated with the version extracted by the `maintain.branch-format` regexp.
271
271
  Example: stable-v\1 will track dev/stable-vXXX/foo against <STABLE_REPO>/stable-vXXX
272
- - `maintain.stable-base-format`: Name of the tag from which the stable branch was forked from generated with the version extracted by the `maintain.branch-format` regexp.
273
- Example: v\1 will be mark vXXX has the fork tag for branch <STABLE_REPO>/stable-vXXX and local branch dev/stable-vXXX/foo
274
- This settings is only needed when using `git maintain steal` command
272
+ - `maintain.stable-base-format`: Name of the tag from which the stable branch was forked from generated with the version extracted by the `maintain.branch-format` regexp.
273
+ Example: v\1 will be mark vXXX has the fork tag for branch <STABLE_REPO>/stable-vXXX and local branch dev/stable-vXXX/foo
274
+ This settings is only needed when using `git maintain steal` command
275
275
  This rule can be overriden by a specific entry in gitconfig:
276
276
  `stable-base.dev---stable-vXXX vYY-ZZ`
277
277
  As git does not allow `/` in gitconfig they are to be replaced by `---`
data/bin/git-maintain CHANGED
@@ -4,66 +4,18 @@ require 'optparse'
4
4
  require 'net/http'
5
5
  require 'json'
6
6
 
7
- BACKPORT_LIB_DIR = File.dirname(__FILE__) + '/../lib'
8
- $LOAD_PATH.push(BACKPORT_LIB_DIR)
9
- require 'common'
7
+ GIT_MAINTAIN_LIB_DIR = File.expand_path('../lib', __dir__)
8
+ $LOAD_PATH.push(GIT_MAINTAIN_LIB_DIR)
9
+ require 'git-maintain'
10
10
  $LOAD_PATH.pop()
11
11
 
12
12
  opts = {
13
13
  :br_suff => "master",
14
14
  :yn_default => nil,
15
15
  }
16
- ACTION_HELPS = GitMaintain::getActionAttr("ACTION_HELP")
17
- actionParser = OptionParser.new(nil, 60)
18
- actionParser.banner = "Usage: #{__FILE__} <action> [action options]"
19
- actionParser.separator ""
20
- actionParser.separator "Options:"
21
- actionParser.on("-h", "--help", "Display usage.") { |val| puts actionParser.to_s; exit 0 }
22
- actionParser.separator "Possible actions:"
23
- ACTION_HELPS.each(){|k, x|
24
- actionParser.separator "\t * " + k.to_s() + ": " + x
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
16
 
17
+ GitMaintain.run_cli(opts) do |parser, phase, action_opts|
18
+ if phase == :action
19
+ parser.on("-b", "--branch-suffix [SUFFIX]", "Branch suffix. Default is 'master'.") { |val| action_opts[:br_suff] = val }
20
+ end
33
21
  end
34
-
35
- rest = actionParser.order!(ARGV);
36
- if rest.length <= 0 then
37
- STDERR.puts("Error: No action provided")
38
- puts actionParser.to_s()
39
- exit 1
40
- end
41
-
42
- action_s = ARGV[0]
43
- action = action_s.to_sym()
44
- raise("Invalid action '#{action_s}'") if GitMaintain::getActionAttr("ACTION_LIST").index(action) == nil
45
- opts[:action] = action
46
- ARGV.shift()
47
-
48
- optsParser = OptionParser.new(nil, 60)
49
- optsParser.banner = "Usage: #{__FILE__} #{action_s} "
50
- optsParser.separator "# " + ACTION_HELPS[action].to_s()
51
- optsParser.separator ""
52
- optsParser.separator "Options:"
53
- optsParser.on("-h", "--help", "Display usage.") { |val| puts optsParser.to_s; exit 0 }
54
- optsParser.on("-b", "--branch-suffix [SUFFIX]", "Branch suffix. Default is 'master'.") {
55
- |val| opts[:br_suff] = val}
56
- optsParser.on("-n", "--no", "Assume no to all questions.") {
57
- |val| opts[:yn_default] = :no}
58
- optsParser.on("-y", "--yes", "Assume yes to all questions.") {
59
- |val| opts[:yn_default] = :yes}
60
- optsParser.on("--verbose", "Displays more informations.") {
61
- |val| GitMaintain::setVerbose(true)}
62
- GitMaintain::setOpts(action, optsParser, opts)
63
-
64
- rest = optsParser.order!(ARGV);
65
- raise("Extra Unexpected extra arguments provided: " + rest.map(){|x|"'" + x + "'"}.join(", ")) if rest.length != 0
66
-
67
- GitMaintain::checkOpts(opts)
68
- GitMaintain::execAction(opts, opts[:action])
69
-
@@ -34,7 +34,7 @@ _git_maintain_cp()
34
34
  local OPT_LIST=$(_git_maintain_genoptlist git maintain cp)
35
35
 
36
36
  case "$prev" in
37
- -c|--sha1);;
37
+ -c|--sha1|--breaker);;
38
38
  *)
39
39
  __gitcomp_nl "$OPT_LIST"
40
40
  _complete_git_maintain_branch
@@ -1,12 +1,24 @@
1
+ # Module containing addon classes for rdma-core repository.
1
2
  module GitMaintain
3
+
4
+ # Subclass of Branch customized for the rdma-core repository.
2
5
  class RDMACoreBranch < Branch
6
+ # The name of this repository.
3
7
  REPO_NAME = "rdma-core"
8
+ # Minimum version number supported by Azure CI.
4
9
  AZURE_MIN_VERSION = 18
10
+ # Addon action list for rdma-core branch.
5
11
  ACTION_LIST = Branch::ACTION_LIST + [ :validate ]
12
+ # Help descriptions of addon actions for CLI.
6
13
  ACTION_HELP = {
7
14
  :validate => "Validate that branch still builds"
8
15
  }.merge(Branch::ACTION_HELP)
9
16
 
17
+ # Configure release-specific command line options.
18
+ #
19
+ # @param action [Symbol] Selected action name
20
+ # @param optsParser [OptionParser] The OptionParser instance
21
+ # @param opts [Hash] The options hash to populate
10
22
  def self.set_opts(action, optsParser, opts)
11
23
  opts[:rel_type] = nil
12
24
 
@@ -16,13 +28,18 @@ module GitMaintain
16
28
  opts[:rel_type] = :major }
17
29
  optsParser.on("--stable", "Release a stable version.") {
18
30
  opts[:rel_type] = :stable }
19
- end
31
+ end
20
32
  end
33
+
34
+ # Validate release-specific command line options.
35
+ #
36
+ # @param opts [Hash] Options hash to validate
37
+ # @raise [GitMaintainError] If rel_type is not specified
21
38
  def self.check_opts(opts)
22
39
  if opts[:action] == :release then
23
40
  case opts[:rel_type]
24
41
  when nil
25
- raise "No release type specified use --stable or --major"
42
+ raise GitMaintainError.new("No release type specified use --stable or --major")
26
43
  when :major
27
44
  if opts[:manual_branch] == nil then
28
45
  GitMaintain::log(:INFO, "Major release selected. Auto-forcing branch to master")
@@ -31,6 +48,12 @@ module GitMaintain
31
48
  end
32
49
  end
33
50
  end
51
+
52
+ # Create a new release for rdma-core.
53
+ # Updates spec files, CMakeLists, changelog, commits, and tags the release.
54
+ #
55
+ # @param opts [Hash] Options hash
56
+ # @raise [GitMaintainError] If prepping, committing, or tagging fails
34
57
  def release(opts)
35
58
  prev_ver=@repo.runGit("show HEAD:CMakeLists.txt | grep -E \"[sS][eE][tT]\\\\(PACKAGE_VERSION\"").
36
59
  chomp().gsub(/[sS][eE][tT]\(PACKAGE_VERSION\s*"([0-9.]*)".*$/, '\1')
@@ -57,7 +80,7 @@ module GitMaintain
57
80
  end
58
81
 
59
82
  puts "Preparing #{opts[:rel_type].to_s} release #{prev_ver} => #{rel_ver}"
60
- rep = GitMaintain::checkLog(opts, @local_branch, git_prev_ver, "release")
83
+ rep = checkLog(opts, @local_branch, git_prev_ver, "release")
61
84
  if rep != "y" then
62
85
  puts "Skipping release"
63
86
  return
@@ -76,9 +99,6 @@ module GitMaintain
76
99
  tag_file.puts `git log HEAD ^#{git_prev_ver} --no-merges --format=' * %s'`
77
100
  tag_file.close()
78
101
 
79
- edit_flag = ""
80
- edit_flag = "--edit" if opts[:no_edit] == false
81
-
82
102
  if opts[:rel_type] == :major
83
103
  # For major, tag the current version first
84
104
  release_do_tag(opts, "v" + rel_ver, tag_path)
@@ -106,29 +126,43 @@ mv debian/changelog.new debian/changelog")
106
126
 
107
127
  # Add and commit
108
128
  release_do_add_commit(opts, [ "*/*.spec", "CMakeLists.txt", "debian/changelog" ],
109
- new_ver, nil, "#{commit_msg} #{new_ver}")
129
+ nil, "#{commit_msg} #{new_ver}")
110
130
 
111
131
  if opts[:rel_type] == :stable
112
- release_do_tag(opts, rel_ver, tag_path)
132
+ release_do_tag(opts, "v" + rel_ver, tag_path)
113
133
  end
114
134
  `rm -f #{tag_path}`
115
- return 0
116
135
  end
136
+
137
+ # Validate that the branch compiles successfully by building it.
138
+ #
139
+ # @param opts [Hash] Options hash
140
+ # @raise [GitMaintainError] If building the branch fails
117
141
  def validate(opts)
118
142
  begin
119
143
  @repo.runSystem("rm -Rf build/ && mkdir build/ && cd build/ && cmake .. && make -j")
120
- rescue RuntimeError
121
- raise("Validation failure")
144
+ rescue RunError
145
+ raise GitMaintainError.new("Validation failure")
122
146
  end
123
147
  end
124
148
  end
149
+ # Repo class customized for the rdma-core repository.
125
150
  class RDMACoreRepo < Repo
151
+ # Minimum version number supported by Azure CI.
126
152
  AZURE_MIN_VERSION = 18
153
+ # Addon action list for rdma-core repo.
127
154
  ACTION_LIST = Repo::ACTION_LIST + [ :create_stable ]
155
+ # Help descriptions of addon actions for CLI.
128
156
  ACTION_HELP = {
129
157
  :create_stable => "Create a stable branch from a release tag"
130
158
  }.merge(Repo::ACTION_HELP)
131
159
 
160
+ # Submit release tags, conditionally creating GitHub releases depending on the version.
161
+ # Starting from v27, the GitHub release is created automatically by Azure pipelines.
162
+ #
163
+ # @param opts [Hash] Options hash
164
+ # @param new_tags [Array<String>] List of release tags to submit
165
+ # @raise [GitMaintainError] If release submission fails
132
166
  def submitReleases(opts, new_tags)
133
167
  new_tags.each(){|tag|
134
168
  next if tag !~ /v([0-9]*)\.[0-9]*/
@@ -138,6 +172,11 @@ mv debian/changelog.new debian/changelog")
138
172
  }
139
173
  end
140
174
 
175
+ # Configure options for the create_stable action.
176
+ #
177
+ # @param action [Symbol] Action name
178
+ # @param optsParser [OptionParser] The OptionParser instance
179
+ # @param opts [Hash] The options hash to populate
141
180
  def self.set_opts(action, optsParser, opts)
142
181
  case action
143
182
  when :create_stable then
@@ -149,22 +188,34 @@ mv debian/changelog.new debian/changelog")
149
188
  |val| opts[:skip_docker] = true}
150
189
  end
151
190
  end
191
+
192
+ # Validate options for repo actions.
193
+ #
194
+ # @param opts [Hash] Options hash to validate
195
+ # @raise [MissingArgumentError] If create_stable is called without a version
196
+ # @raise [GitMaintainError] If create_stable is called on a non-master suffixed branch
152
197
  def self.check_opts(opts)
153
198
  case opts[:action]
154
199
  when :create_stable
155
200
  if opts[:version].to_s() == "" then
156
- raise "Action #{opts[:action]} requires a branch number to be specified"
201
+ raise MissingArgumentError.new("branch number")
157
202
  end
158
- if opts[:br_suff] != "master" then
159
- raise "Action #{opts[:action]} can only be done on 'master' suffixed branches"
203
+ if opts[:br_suff] != "master" then
204
+ raise GitMaintainError.new("Action #{opts[:action]} can only be done on 'master' suffixed branches")
160
205
  end
161
- end
206
+ end
162
207
  end
208
+
209
+ # Create a stable branch from a release tag.
210
+ # Runs the setup commands documented in Documentation/stable.md.
211
+ #
212
+ # @param opts [Hash] Options hash
213
+ # @raise [GitMaintainError] If running stable creation commands fails
163
214
  def create_stable(opts)
164
215
  ver = opts[:version].to_s()
165
216
  suff = opts[:br_suff]
166
217
  if getBranchList(suff).index(ver) != nil then
167
- raise("Local branch already exists for version #{ver}")
218
+ raise GitMaintainError.new("Local branch already exists for version #{ver}")
168
219
  end
169
220
  br = versionToLocalBranch(ver, suff)
170
221
  full_ver = ver.gsub(/([0-9]+)/, @stable_base_format)
@@ -179,14 +230,21 @@ mv debian/changelog.new debian/changelog")
179
230
  toDo=cmdList.join("&&")
180
231
  begin
181
232
  runSystem(toDo)
182
- rescue RuntimeError
183
- raise("Fail to run stable creation code")
233
+ rescue RunError
234
+ raise GitMaintainError.new("Fail to run stable creation code")
184
235
  end
185
236
  end
186
237
  end
187
238
 
239
+ # CI interface subclass customized to route CI queries for rdma-core.
240
+ # Uses Travis for older versions (< 18) and Azure DevOps for newer versions.
188
241
  class RDMACoreCI < CI
242
+ # Minimum version number supported by Azure CI.
189
243
  AZURE_MIN_VERSION = 18
244
+
245
+ # Initialize RDMACoreCI, setting up both Travis and Azure DevOps adapters.
246
+ #
247
+ # @param repo [Repo] The Repo instance
190
248
  def initialize(repo)
191
249
  super(repo)
192
250
  @travis = GitMaintain::TravisCI.new(repo)
@@ -202,10 +260,10 @@ mv debian/changelog.new debian/changelog")
202
260
  self.define_singleton_method(method) { |br, *args|
203
261
  if br.version =~ /([0-9]+)/
204
262
  major=$1.to_i
205
- elsif br.version == "master"
263
+ elsif br.version == "master"
206
264
  major=99999
207
265
  else
208
- raise("Unable to monitor branch #{br} on a CI")
266
+ raise GitMaintainError.new("Unable to monitor branch #{br} on a CI")
209
267
  end
210
268
  if major < AZURE_MIN_VERSION
211
269
  @travis.send(method, br, *args)
@@ -215,6 +273,7 @@ mv debian/changelog.new debian/changelog")
215
273
  }
216
274
  }
217
275
  end
276
+ # Clear any cached build state for both Travis and Azure adapters.
218
277
  def emptyCache()
219
278
  @travis.emptyCache()
220
279
  @azure.emptyCache()
@@ -1,6 +1,16 @@
1
+ # Module containing addon classes for git-maintain repository itself.
1
2
  module GitMaintain
3
+
4
+ # Subclass of Branch customized for the git-maintain repository.
2
5
  class GitMaintainBranch < Branch
6
+ # The name of this repository.
3
7
  REPO_NAME = "git-maintain"
8
+
9
+ # Configure release-specific command line options.
10
+ #
11
+ # @param action [Symbol] Selected action name
12
+ # @param optsParser [OptionParser] The OptionParser instance
13
+ # @param opts [Hash] The options hash to populate
4
14
  def self.set_opts(action, optsParser, opts)
5
15
  opts[:rel_type] = nil
6
16
 
@@ -13,13 +23,18 @@ module GitMaintain
13
23
  optsParser.on("--stable", "Release a stable version.") {
14
24
  opts[:rel_type] = :stable
15
25
  }
16
- end
26
+ end
17
27
  end
28
+
29
+ # Validate release-specific command line options.
30
+ #
31
+ # @param opts [Hash] Options hash to validate
32
+ # @raise [GitMaintainError] If rel_type is not specified
18
33
  def self.check_opts(opts)
19
34
  if opts[:action] == :release then
20
35
  case opts[:rel_type]
21
36
  when nil
22
- raise "No release type specified use --stable or --major"
37
+ raise GitMaintainError.new("No release type specified use --stable or --major")
23
38
  when :major
24
39
  if opts[:manual_branch] == nil then
25
40
  GitMaintain::log(:INFO, "Major release selected. Auto-forcing branch to master")
@@ -28,13 +43,20 @@ module GitMaintain
28
43
  end
29
44
  end
30
45
  end
46
+
47
+ # Create a new release for git-maintain.
48
+ # Updates CHANGELOG, commits, and tags the release.
49
+ #
50
+ # @param opts [Hash] Options hash
51
+ # @raise [GitMaintainError] If prepping, committing, or tagging fails
31
52
  def release(opts)
32
53
  prev_ver=@repo.runGit("show HEAD:CHANGELOG | grep -A 1 -- '---------' | head -n 2 | tail -n 1 | awk '{ print $1}'").chomp()
33
54
  ver_nums = prev_ver.split(".")
34
55
 
35
56
  if opts[:rel_type] == :stable then
57
+
36
58
  new_ver = (ver_nums[0 .. -2] + [ver_nums[-1].to_i() + 1 ]).join(".")
37
- git_prev_ver = "v" + (ver_nums[-1] == "0" ? ver_nums[0 .. -2].join(".") : prev_ver)
59
+ git_prev_ver = "v" + prev_ver
38
60
  elsif opts[:rel_type] == :major then
39
61
  new_ver = (ver_nums[0 .. -3] + [ver_nums[-2].to_i() + 1 ] + [ "0" ]).join(".")
40
62
  new_ver = opts[:new_ver] if opts[:new_ver] != nil
@@ -45,7 +67,7 @@ module GitMaintain
45
67
  changes=@repo.runGit("show HEAD:CHANGELOG | awk ' BEGIN {count=0} {if ($1 == \"------------------\") count++; if (count == 0) print $0}'")
46
68
 
47
69
  puts "Preparing release #{prev_ver} => #{new_ver}"
48
- rep = GitMaintain::checkLog(opts, @local_branch, git_prev_ver, "release")
70
+ rep = checkLog(opts, @local_branch, git_prev_ver, "release")
49
71
  if rep != "y" then
50
72
  puts "Skipping release"
51
73
  return
@@ -55,7 +77,7 @@ module GitMaintain
55
77
  tag_path=`mktemp`.chomp()
56
78
  puts tag_path
57
79
  tag_file = File.open(tag_path, "w+")
58
- tag_file.puts "git-maintain-#{new_ver}"
80
+ tag_file.puts "#{self.class::REPO_NAME}-#{new_ver}"
59
81
  tag_file.puts ""
60
82
  tag_file.puts changes
61
83
  tag_file.close()
@@ -71,10 +93,14 @@ mv CHANGELOG.new CHANGELOG")
71
93
 
72
94
  release_do_add_commit_tag(opts, ["CHANGELOG"], "v" + new_ver, tag_path)
73
95
  `rm -f #{tag_path}`
74
- return 0
75
96
  end
76
97
  end
98
+
99
+ # Repo class customized for the git-maintain repository.
77
100
  class GitMaintainRepo < Repo
101
+ # Initialize GitMaintainRepo with release notifications disabled.
102
+ #
103
+ # @param path [String] Repository directory path
78
104
  def initialize(path)
79
105
  super(path)
80
106
  @NOTIFY_RELEASE = false
@@ -83,4 +109,33 @@ mv CHANGELOG.new CHANGELOG")
83
109
  GitMaintain::registerCustom(GitMaintainBranch::REPO_NAME,
84
110
  { GitMaintain::Branch => GitMaintainBranch,
85
111
  GitMaintain::Repo => GitMaintainRepo})
112
+
113
+ # Subclass of GitMaintainBranch for cli_class_tool repository.
114
+ class CLIClassToolBranch < GitMaintainBranch
115
+ # Repository name constant for cli_class_tool.
116
+ REPO_NAME = "cli_class_tool"
117
+ end
118
+
119
+ # Subclass of GitMaintainRepo for cli_class_tool repository.
120
+ class CLIClassToolRepo < GitMaintainRepo
121
+ end
122
+
123
+ GitMaintain::registerCustom(CLIClassToolBranch::REPO_NAME,
124
+ { GitMaintain::Branch => CLIClassToolBranch,
125
+ GitMaintain::Repo => CLIClassToolRepo})
126
+
127
+ # Subclass of GitMaintainBranch for cli_class_workEnv repository.
128
+ class WorkEnvBranch < GitMaintainBranch
129
+ # Repository name constant for cli_class_tool.
130
+ REPO_NAME = "workEnv"
131
+ end
132
+
133
+ # Subclass of GitMaintainRepo for workEnv repository.
134
+ class WorkEnvRepo < GitMaintainRepo
135
+ end
136
+
137
+ GitMaintain::registerCustom(WorkEnvBranch::REPO_NAME,
138
+ { GitMaintain::Branch => WorkEnvBranch,
139
+ GitMaintain::Repo => WorkEnvRepo})
140
+
86
141
  end
@@ -0,0 +1,73 @@
1
+ # Module containing addon classes for healthd repository.
2
+ module GitMaintain
3
+
4
+ # Subclass of Branch customized for the healthd repository.
5
+ class HealthdBranch < Branch
6
+ # The name of this repository.
7
+ REPO_NAME = "healthd"
8
+
9
+ # Create a new release for healthd.
10
+ # Updates CHANGELOG, spect files, commits, and tags the release.
11
+ #
12
+ # @param opts [Hash] Options hash
13
+ # @raise [GitMaintainError] If prepping, committing, or tagging fails
14
+ def release(opts)
15
+ prev_ver=@repo.runGit("show HEAD:CHANGELOG | grep -A 1 -- '---------' | head -n 2 | tail -n 1 | awk '{ print $1}'").chomp()
16
+ ver_nums = prev_ver.split(".")
17
+
18
+ if opts[:manual_branch] == nil then
19
+ new_ver = (ver_nums[0 .. -2] + [ver_nums[-1].to_i() + 1 ]).join(".")
20
+ git_prev_ver = "v" + (ver_nums[-1] == "0" ? ver_nums[0 .. -2].join(".") : prev_ver)
21
+ else
22
+ new_ver = (ver_nums[0 .. -3] + [ver_nums[-2].to_i() + 1 ] + [ "0" ]).join(".")
23
+ git_prev_ver = "v" + prev_ver
24
+ end
25
+
26
+ changes=@repo.runGit("show HEAD:CHANGELOG | awk ' BEGIN {count=0} {if ($1 == \"------------------\") count++; if (count == 0) print $0}'")
27
+
28
+ puts "Preparing release #{prev_ver} => #{new_ver}"
29
+ rep = checkLog(opts, @local_branch, git_prev_ver, "release")
30
+ if rep != "y" then
31
+ puts "Skipping release"
32
+ return
33
+ end
34
+
35
+ # Prepare tag message
36
+ tag_path=`mktemp`.chomp()
37
+ puts tag_path
38
+ tag_file = File.open(tag_path, "w+")
39
+ tag_file.puts "healthd-#{new_ver}"
40
+ tag_file.puts ""
41
+ tag_file.puts changes
42
+ tag_file.close()
43
+
44
+ @repo.run("cat <<EOF > CHANGELOG.new
45
+ ------------------
46
+ #{new_ver} #{`date '+ (%Y-%m-%d)'`.chomp()}
47
+ ------------------
48
+
49
+ $(cat CHANGELOG)
50
+ EOF
51
+ mv CHANGELOG.new CHANGELOG")
52
+
53
+ @repo.run("sed -i -e 's/\\(Version:[[:space:]]*\\)[0-9.]\\+/\\1#{new_ver}/g' */*.spec")
54
+
55
+ release_do_add_commit_tag(opts, ["CHANGELOG", "*/*.spec"], "v" + new_ver, tag_path)
56
+ `rm -f #{tag_path}`
57
+ end
58
+ end
59
+
60
+ # Repo class customized for the healthd repository.
61
+ class HealthdRepo < Repo
62
+ # Initialize HealthdRepo with release notifications disabled.
63
+ #
64
+ # @param path [String] Repository directory path
65
+ def initialize(path)
66
+ super(path)
67
+ @NOTIFY_RELEASE = false
68
+ end
69
+ end
70
+ GitMaintain::registerCustom(HealthdBranch::REPO_NAME,
71
+ { GitMaintain::Branch => HealthdBranch,
72
+ GitMaintain::Repo => HealthdRepo})
73
+ end