gem_comet 0.3.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GemComet
4
+ # Gets the repository URL on the GitHub
5
+ class RepositoryUrl < ServiceAbstract
6
+ def initialize; end
7
+
8
+ private
9
+
10
+ # Returns the git origin URL via git command.
11
+ #
12
+ # @return [String] The origin URL
13
+ def call
14
+ if git_remote_command =~ /git@github.com:(.+).git/
15
+ "https://github.com/#{Regexp.last_match(1)}"
16
+ else
17
+ git_remote_command.sub('.git', '').chomp
18
+ end
19
+ end
20
+
21
+ def git_remote_command
22
+ @git_remote_command ||= `git remote get-url --push origin`
23
+ end
24
+ end
25
+ end
@@ -5,16 +5,16 @@ module GemComet
5
5
  class ServiceAbstract
6
6
  private_class_method :new
7
7
 
8
- def self.call(*args)
9
- new(*args).send(:call)
8
+ def self.call(**args)
9
+ new(**args).send(:call)
10
10
  end
11
11
 
12
- private
13
-
14
12
  def initialize(_args)
15
13
  raise "Please implement #{self.class}##{__method__}"
16
14
  end
17
15
 
16
+ private
17
+
18
18
  def call
19
19
  raise "Please implement #{self.class}##{__method__}"
20
20
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GemComet
4
+ # Verifies current git branch condition
5
+ class VerifyGitCondition < ServiceAbstract
6
+ def initialize
7
+ @base_branch = Config.call.release.base_branch
8
+ @git_command = GitCommand.new
9
+ end
10
+
11
+ private
12
+
13
+ attr_reader :base_branch, :git_command
14
+
15
+ def call
16
+ verify_git_status
17
+ checkout_to_base_branch!
18
+ git_pull!
19
+ end
20
+
21
+ # Verifies that there are not uncommitted files
22
+ #
23
+ # @raise [RuntimeError] Exists uncommitted files
24
+ def verify_git_status
25
+ uncommitted_files = git_command.uncommitted_files
26
+ return if uncommitted_files.empty?
27
+
28
+ raise "There are uncommitted files:\n#{uncommitted_files.join("\n")}"
29
+ end
30
+
31
+ # Checkout to the base branch
32
+ def checkout_to_base_branch!
33
+ current_branch = git_command.current_branch
34
+ return if base_branch == current_branch
35
+
36
+ puts "Current branch is expected to '#{base_branch}', but '#{current_branch}'."
37
+ puts "Checkout to '#{base_branch}'."
38
+ git_command.checkout(base_branch)
39
+ end
40
+
41
+ def git_pull!
42
+ git_command.pull
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GemComet
4
- VERSION = '0.3.0'
4
+ VERSION = '0.7.2'
5
5
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GemComet
4
+ # Reads versions by `git tag` command
5
+ class VersionHistory
6
+ # Gets all version numbers
7
+ #
8
+ # @return [Array<String>] An array of version numbers
9
+ def versions
10
+ array_of_version_and_date.map(&:first).push('HEAD')
11
+ end
12
+
13
+ # Gets a previous version number from the specified version number
14
+ #
15
+ # @param version [String] Any version number
16
+ # @return [String] A previous version number
17
+ # @raise [RuntimeError] The specified version cannot be found
18
+ def previous_version_from(version)
19
+ index = find_version_index(version)
20
+ return nil if index.zero?
21
+
22
+ versions.at(index - 1)
23
+ end
24
+
25
+ # Gets the verioning date of the version number
26
+ #
27
+ # @param version [String] Any version number
28
+ # @return [Date] The verioning date
29
+ # @raise [RuntimeError] The specified version cannot be found
30
+ def versioning_date_of(version)
31
+ return Date.today if version == 'HEAD'
32
+
33
+ index = find_version_index(version)
34
+ Date.parse(array_of_version_and_date[index].last)
35
+ end
36
+
37
+ private
38
+
39
+ # Processes `git tag` command result
40
+ #
41
+ # @return [Array<Array<String>>] An array of versions and date
42
+ # e.g. [['v0.1.0', '2019-07-15'], ['v0.2.0', '2019-10-14']]
43
+ def array_of_version_and_date
44
+ @array_of_version_and_date ||=
45
+ git_tag_list.lines.map(&:chomp).map(&:split).reject(&:empty?).sort_by(&:last)
46
+ end
47
+
48
+ # Finds an index of the specified version number
49
+ #
50
+ # @param version [String] Any version number
51
+ # @return [Integer] The index of the specified version number
52
+ # @raise [RuntimeError] The specified version cannot be found
53
+ def find_version_index(version)
54
+ index = versions.index(version)
55
+ raise 'The specified version cannot be found' if index.nil?
56
+
57
+ index
58
+ end
59
+
60
+ # Executes `git tag` command
61
+ #
62
+ # @return [String] Output result
63
+ def git_tag_list
64
+ `git tag --list 'v*' --format='%(tag) %(taggerdate:short)'`
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ]
5
+ }
@@ -1,7 +1,10 @@
1
1
  # [Usage]
2
2
  #
3
3
  # $ gem install gem_comet
4
+ # $ gem_comet init
4
5
  # $ gem_comet release {version number, like as "1.2.3"}
6
+ # $ gem_comet changelog
7
+ # $ gem_comet versions
5
8
 
6
9
  version: <%= config[:version] %>
7
10
 
@@ -0,0 +1,5 @@
1
+ # TODO
2
+
3
+ - [ ] Merge "Update v<%= version %>" first
4
+
5
+ Generated by [gem_comet](https://github.com/ryz310/gem_comet)
@@ -0,0 +1,6 @@
1
+ # TODO
2
+
3
+ - [ ] Check version numbering: v<%= version %> (was v<%= prev_version %>)
4
+ - [ ] Edit the CHANGELOG.md
5
+
6
+ Generated by [gem_comet](https://github.com/ryz310/gem_comet)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_comet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryz310
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-19 00:00:00.000000000 Z
11
+ date: 2021-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pr_comet
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0
19
+ version: 0.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.0
26
+ version: 0.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -168,16 +168,16 @@ dependencies:
168
168
  name: simplecov
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ">="
171
+ - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: '0'
173
+ version: 0.17.1
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ">="
178
+ - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: '0'
180
+ version: 0.17.1
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: yard
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -201,11 +201,13 @@ extensions: []
201
201
  extra_rdoc_files: []
202
202
  files:
203
203
  - ".circleci/config.yml"
204
+ - ".dependabot/config.yml"
204
205
  - ".envrc.skeleton"
205
206
  - ".gem_comet.yml"
206
207
  - ".gitignore"
207
208
  - ".rspec"
208
209
  - ".rubocop.yml"
210
+ - ".rubocop_challenge.yml"
209
211
  - ".rubocop_todo.yml"
210
212
  - CHANGELOG.md
211
213
  - CODE_OF_CONDUCT.md
@@ -219,19 +221,29 @@ files:
219
221
  - exe/gem_comet
220
222
  - gem_comet.gemspec
221
223
  - lib/gem_comet.rb
224
+ - lib/gem_comet/bundle_updater.rb
222
225
  - lib/gem_comet/changelog.rb
223
226
  - lib/gem_comet/changelog/editor.rb
224
227
  - lib/gem_comet/changelog/generator.rb
228
+ - lib/gem_comet/changelog/initializer.rb
225
229
  - lib/gem_comet/cli.rb
226
230
  - lib/gem_comet/config.rb
231
+ - lib/gem_comet/git_command.rb
232
+ - lib/gem_comet/open_github_pulls_page.rb
227
233
  - lib/gem_comet/release.rb
228
- - lib/gem_comet/release/release_pr.rb
229
- - lib/gem_comet/release/update_pr.rb
234
+ - lib/gem_comet/release/create_release_pr.rb
235
+ - lib/gem_comet/release/create_update_pr.rb
236
+ - lib/gem_comet/repository_url.rb
230
237
  - lib/gem_comet/service_abstract.rb
238
+ - lib/gem_comet/verify_git_condition.rb
231
239
  - lib/gem_comet/version.rb
232
240
  - lib/gem_comet/version_editor.rb
241
+ - lib/gem_comet/version_history.rb
242
+ - renovate.json
233
243
  - template/.gem_comet.yml.erb
234
244
  - template/CHANGELOG.md.erb
245
+ - template/release_pr.md.erb
246
+ - template/update_pr.md.erb
235
247
  homepage: https://github.com/ryz310/gem_comet
236
248
  licenses:
237
249
  - MIT
@@ -244,14 +256,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
244
256
  requirements:
245
257
  - - ">="
246
258
  - !ruby/object:Gem::Version
247
- version: '0'
259
+ version: 2.7.0
248
260
  required_rubygems_version: !ruby/object:Gem::Requirement
249
261
  requirements:
250
262
  - - ">="
251
263
  - !ruby/object:Gem::Version
252
264
  version: '0'
253
265
  requirements: []
254
- rubygems_version: 3.0.3
266
+ rubygems_version: 3.2.3
255
267
  signing_key:
256
268
  specification_version: 4
257
269
  summary: Release a gem quickly like comets