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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9af927752168031d4518212f7ce2114730068296267e7b390db20dde01c3565
4
- data.tar.gz: 3e72669ad23fb312fb6d6cadc96ec0b3d9ab1c57db9ee97032a756ac6bffae71
3
+ metadata.gz: 5be1a3c87bfe24c13824a78a03caf5a3b93f8a13653c8befdadde867b4db6cd2
4
+ data.tar.gz: 85f3b0d06e05db436012d69e058b30d1121ce0b0458cabc1d014f0ab6e6fdfe7
5
5
  SHA512:
6
- metadata.gz: 4185735836c059c50a9a76568d678a9a7900fd81a1855c6d3b45edb31245d62e0b877fb1f352e03df94743bef3027c3630be0c9bf57eafb61d82899ed5f58e49
7
- data.tar.gz: 966702bfd742eee451afc86ed247e0bca851cbd955b4cbf2cad2a2f7e30dbe815600093d286aef7f78a8e5f311680fa57991b0f15965d97f5881d9b144e66dd8
6
+ metadata.gz: 98db4aba9ccd5891fe62cf00abde4e6dfa9a34132c3494043cb2b3fa18c32d4f5d387807e0914faca6bef657b5e61fe4bd55310144df6e9c8582877abcf18155
7
+ data.tar.gz: 15ae0262936ddf8f83191854c32eff8a732543ac028f26dd82fd5ccb1565a28ae9c6258cdea28634c83cac38d654766ecb1a8886ace6812326dbe37dd538a664
data/CHANGELOG CHANGED
@@ -1,3 +1,24 @@
1
+ ------------------
2
+ 0.13.0 (2026-09-09)
3
+ ------------------
4
+
5
+ * Major internal refactor
6
+ * CLI code has been moded to cli_class_tool
7
+ * Replace all return values by exceptions
8
+ * Cleanup path handling
9
+ * Simplify Branch class by introducing a BranchIterator
10
+ * In theory, fully transparent for end-users
11
+
12
+ ------------------
13
+ 0.12.0 (2025-09-11)
14
+ ------------------
15
+
16
+ * Cleanup code for Addons releases
17
+ * Replace all egrep calls with grep -E
18
+ * Replace $? handling with Exceptions
19
+ * Various minor fixes
20
+ * Drop obsolete Travis CI code
21
+
1
22
  ------------------
2
23
  0.11.0 (2025-04-15)
3
24
  ------------------
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
-
@@ -1,13 +1,13 @@
1
1
  export _GIT_MAINTAIN_CMD_AWK=$(([ -f /bin/awk ] && echo "/bin/awk") || echo "/usr/bin/awk")
2
2
  export _GIT_MAINTAIN_CMD_SORT=$(([ -f /bin/sort ] && echo "/bin/sort") || echo "/usr/bin/sort")
3
- export _GIT_MAINTAIN_CMD_EGREP=$(([ -f /bin/egrep ] && echo "/bin/egrep") || echo "/usr/bin/egrep")
3
+ export _GIT_MAINTAIN_CMD_GREP=$(([ -f /bin/grep ] && echo "/bin/grep") || echo "/usr/bin/grep")
4
4
  export _GIT_MAINTAIN_CMD_SED=$(([ -f /bin/sed ] && echo "/bin/sed") || echo "/usr/bin/sed")
5
5
 
6
6
  _git_maintain_genoptlist(){
7
7
  local COMMAND=$*
8
8
  ${COMMAND} --help 2>&1 | \
9
9
  ${_GIT_MAINTAIN_CMD_AWK} 'BEGIN { found = 0 } { if(found == 1) print $$0; if($$1 == "Options:") {found = 1}}' | \
10
- ${_GIT_MAINTAIN_CMD_EGREP} -e "^[[:space:]]*--" -e "^[[:space:]]*-[a-zA-Z0-9]" | \
10
+ ${_GIT_MAINTAIN_CMD_GREP} -E -e "^[[:space:]]*--" -e "^[[:space:]]*-[a-zA-Z0-9]" | \
11
11
  ${_GIT_MAINTAIN_CMD_SED} -e 's/^[[:space:]]*//' -e 's/^-[^-], //' | \
12
12
  ${_GIT_MAINTAIN_CMD_AWK} '{ print $1}' | \
13
13
  ${_GIT_MAINTAIN_CMD_SED} -e 's/^\(.*\)\[no-\]\(.*$\)/\1\2\n\1no-\2/' | \
@@ -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,8 +48,14 @@ 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
- prev_ver=@repo.runGit("show HEAD:CMakeLists.txt | egrep \"[sS][eE][tT]\\\\(PACKAGE_VERSION\"").
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')
37
60
  ver_nums = prev_ver.split(".")
38
61
  new_ver = (ver_nums[0 .. -2] + [ver_nums[-1].to_i() + 1 ]).join(".")
@@ -49,14 +72,15 @@ module GitMaintain
49
72
 
50
73
  git_prev_ver = "v" + prev_ver
51
74
  # Older tags might do have the terminal minor version (.0) for major releases
52
- @repo.runGit("rev-parse --verify --quiet #{git_prev_ver}")
53
- if $? != 0 then
75
+ begin
76
+ @repo.ref_exist?(git_prev_ver)
77
+ rescue NoRefError
54
78
  # Try without the minor version number
55
79
  git_prev_ver = "v" + ver_nums[0 .. -2].join(".")
56
80
  end
57
81
 
58
82
  puts "Preparing #{opts[:rel_type].to_s} release #{prev_ver} => #{rel_ver}"
59
- rep = GitMaintain::checkLog(opts, @local_branch, git_prev_ver, "release")
83
+ rep = checkLog(opts, @local_branch, git_prev_ver, "release")
60
84
  if rep != "y" then
61
85
  puts "Skipping release"
62
86
  return
@@ -75,15 +99,9 @@ module GitMaintain
75
99
  tag_file.puts `git log HEAD ^#{git_prev_ver} --no-merges --format=' * %s'`
76
100
  tag_file.close()
77
101
 
78
- edit_flag = ""
79
- edit_flag = "--edit" if opts[:no_edit] == false
80
-
81
102
  if opts[:rel_type] == :major
82
103
  # For major, tag the current version first
83
- @repo.runGitInteractive("tag -a -s v#{rel_ver} #{edit_flag} -F #{tag_path}")
84
- if $? != 0 then
85
- raise("Failed to tag branch #{local_branch}")
86
- end
104
+ release_do_tag(opts, "v" + rel_ver, tag_path)
87
105
  end
88
106
 
89
107
  # Update version number in relevant files
@@ -107,32 +125,44 @@ mv debian/changelog.new debian/changelog")
107
125
  end
108
126
 
109
127
  # Add and commit
110
- @repo.runGit("add */*.spec CMakeLists.txt debian/changelog")
111
- @repo.runGitInteractive("commit -m '#{commit_msg} #{new_ver}' --verbose #{edit_flag} --signoff")
112
- if $? != 0 then
113
- raise("Failed to commit on branch #{local_branch}")
114
- end
128
+ release_do_add_commit(opts, [ "*/*.spec", "CMakeLists.txt", "debian/changelog" ],
129
+ nil, "#{commit_msg} #{new_ver}")
115
130
 
116
131
  if opts[:rel_type] == :stable
117
- @repo.runGitInteractive("tag -a -s v#{rel_ver} #{edit_flag} -F #{tag_path}")
118
- if $? != 0 then
119
- raise("Failed to tag branch #{local_branch}")
120
- end
132
+ release_do_tag(opts, "v" + rel_ver, tag_path)
121
133
  end
122
134
  `rm -f #{tag_path}`
123
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
124
141
  def validate(opts)
125
- @repo.runSystem("rm -Rf build/ && mkdir build/ && cd build/ && cmake .. && make -j")
126
- raise("Validation failure") if $? != 0
142
+ begin
143
+ @repo.runSystem("rm -Rf build/ && mkdir build/ && cd build/ && cmake .. && make -j")
144
+ rescue RunError
145
+ raise GitMaintainError.new("Validation failure")
146
+ end
127
147
  end
128
148
  end
149
+ # Repo class customized for the rdma-core repository.
129
150
  class RDMACoreRepo < Repo
151
+ # Minimum version number supported by Azure CI.
130
152
  AZURE_MIN_VERSION = 18
153
+ # Addon action list for rdma-core repo.
131
154
  ACTION_LIST = Repo::ACTION_LIST + [ :create_stable ]
155
+ # Help descriptions of addon actions for CLI.
132
156
  ACTION_HELP = {
133
157
  :create_stable => "Create a stable branch from a release tag"
134
158
  }.merge(Repo::ACTION_HELP)
135
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
136
166
  def submitReleases(opts, new_tags)
137
167
  new_tags.each(){|tag|
138
168
  next if tag !~ /v([0-9]*)\.[0-9]*/
@@ -142,6 +172,11 @@ mv debian/changelog.new debian/changelog")
142
172
  }
143
173
  end
144
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
145
180
  def self.set_opts(action, optsParser, opts)
146
181
  case action
147
182
  when :create_stable then
@@ -153,22 +188,34 @@ mv debian/changelog.new debian/changelog")
153
188
  |val| opts[:skip_docker] = true}
154
189
  end
155
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
156
197
  def self.check_opts(opts)
157
198
  case opts[:action]
158
199
  when :create_stable
159
200
  if opts[:version].to_s() == "" then
160
- raise "Action #{opts[:action]} requires a branch number to be specified"
201
+ raise MissingArgumentError.new("branch number")
161
202
  end
162
- if opts[:br_suff] != "master" then
163
- 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")
164
205
  end
165
- end
206
+ end
166
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
167
214
  def create_stable(opts)
168
215
  ver = opts[:version].to_s()
169
216
  suff = opts[:br_suff]
170
217
  if getBranchList(suff).index(ver) != nil then
171
- raise("Local branch already exists for version #{ver}")
218
+ raise GitMaintainError.new("Local branch already exists for version #{ver}")
172
219
  end
173
220
  br = versionToLocalBranch(ver, suff)
174
221
  full_ver = ver.gsub(/([0-9]+)/, @stable_base_format)
@@ -181,13 +228,23 @@ mv debian/changelog.new debian/changelog")
181
228
  cmdList << "./buildlib/cbuild pkg azp"
182
229
 
183
230
  toDo=cmdList.join("&&")
184
- runSystem(toDo)
185
- raise("Fail to run stable creation code") if $? != 0
231
+ begin
232
+ runSystem(toDo)
233
+ rescue RunError
234
+ raise GitMaintainError.new("Fail to run stable creation code")
235
+ end
186
236
  end
187
237
  end
188
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.
189
241
  class RDMACoreCI < CI
242
+ # Minimum version number supported by Azure CI.
190
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
191
248
  def initialize(repo)
192
249
  super(repo)
193
250
  @travis = GitMaintain::TravisCI.new(repo)
@@ -203,10 +260,10 @@ mv debian/changelog.new debian/changelog")
203
260
  self.define_singleton_method(method) { |br, *args|
204
261
  if br.version =~ /([0-9]+)/
205
262
  major=$1.to_i
206
- elsif br.version == "master"
263
+ elsif br.version == "master"
207
264
  major=99999
208
265
  else
209
- raise("Unable to monitor branch #{br} on a CI")
266
+ raise GitMaintainError.new("Unable to monitor branch #{br} on a CI")
210
267
  end
211
268
  if major < AZURE_MIN_VERSION
212
269
  @travis.send(method, br, *args)
@@ -216,6 +273,7 @@ mv debian/changelog.new debian/changelog")
216
273
  }
217
274
  }
218
275
  end
276
+ # Clear any cached build state for both Travis and Azure adapters.
219
277
  def emptyCache()
220
278
  @travis.emptyCache()
221
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()
@@ -69,20 +91,16 @@ $(cat CHANGELOG)
69
91
  EOF
70
92
  mv CHANGELOG.new CHANGELOG")
71
93
 
72
- # Add and commit
73
- @repo.runGit("add CHANGELOG")
74
- @repo.runGitInteractive("commit -F #{tag_path} --verbose --edit --signoff")
75
- if $? != 0 then
76
- raise("Failed to commit on branch #{local_branch}")
77
- end
78
- @repo.runGitInteractive("tag -a -s v#{new_ver} --edit -F #{tag_path}")
79
- if $? != 0 then
80
- raise("Failed to tag branch #{local_branch}")
81
- end
94
+ release_do_add_commit_tag(opts, ["CHANGELOG"], "v" + new_ver, tag_path)
82
95
  `rm -f #{tag_path}`
83
96
  end
84
97
  end
98
+
99
+ # Repo class customized for the git-maintain repository.
85
100
  class GitMaintainRepo < Repo
101
+ # Initialize GitMaintainRepo with release notifications disabled.
102
+ #
103
+ # @param path [String] Repository directory path
86
104
  def initialize(path)
87
105
  super(path)
88
106
  @NOTIFY_RELEASE = false
@@ -91,4 +109,19 @@ mv CHANGELOG.new CHANGELOG")
91
109
  GitMaintain::registerCustom(GitMaintainBranch::REPO_NAME,
92
110
  { GitMaintain::Branch => GitMaintainBranch,
93
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
+
94
127
  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