gem_comet 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57c1e8a6cd0cfce646e1f0e2308d6a29dea5c0f741763d7aa721b6d61f5c9c71
4
- data.tar.gz: 6bcc4d93b64b5eabfb1e6b824a167a4b54a9dfeadcfacbdccdaa1d81568397ea
3
+ metadata.gz: ba30b799de346dffa5bd093cac66ea82e6797de2d7c8f443bebdc1e1be5d36da
4
+ data.tar.gz: 1c18e9ec7f1dcbc878c849e77dff5ef368dfc4d8fd40b34f29549d56719da9f3
5
5
  SHA512:
6
- metadata.gz: e0db304325a3cdf022c961ffbc24728e1cdd606974de62ed93a64676e95e3b99069e2c76d0ba67476a52f8c6a8614ed4e7be3bf67d08cf551b593fd39764a6fd
7
- data.tar.gz: 36a24509001aed657bed2976b4134f6a8155e5bffa9e251b8af555fb742a26b28600642d02138cf7d047dff70c90586fcbbe347b91d703e4a79daa9f94f28255
6
+ metadata.gz: fcec552a4d36dc03e55172388c8461f03d41402a6be3c2076dd864c51763b7af0b882165d0bd102ad7e9e2538954ede67d7836609812ccb561baeb06d0ed8ada
7
+ data.tar.gz: cb728564444d6b938be9eb02b959c13f4f108df3de9b295d2c8f173aaa762fe0545edb99404478e2e5c62bea57ef647ec0be880a1e04c3b1417b006723f9417a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change log
2
2
 
3
+ ## v0.6.0 (Nov 03, 2019)
4
+
5
+ ### Feature
6
+
7
+ * [#60](https://github.com/ryz310/gem_comet/pull/60) Verify git condition on release ([@ryz310](https://github.com/ryz310))
8
+
3
9
  ## v0.5.0 (Nov 02, 2019)
4
10
 
5
11
  ### Feature
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gem_comet (0.5.0)
4
+ gem_comet (0.6.0)
5
5
  pr_comet (~> 0.3.1)
6
6
  thor
7
7
  type_struct
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GemComet
4
+ # Executes git command
5
+ class GitCommand
6
+ def initialize; end
7
+
8
+ # Get uncommitted files
9
+ #
10
+ # @return [Array<String>] Uncommitted files
11
+ def uncommitted_files
12
+ git_status_short.lines.map(&:chomp)
13
+ end
14
+
15
+ # Get current git branch name
16
+ #
17
+ # @return [String] The current branch name
18
+ def current_branch
19
+ run 'rev-parse', '--abbrev-ref', 'HEAD'
20
+ end
21
+
22
+ def checkout(branch)
23
+ run 'checkout', branch
24
+ end
25
+
26
+ # Executes `$ git pull`
27
+ def pull
28
+ run 'pull'
29
+ end
30
+
31
+ private
32
+
33
+ def execute(command)
34
+ `#{command}`.chomp
35
+ end
36
+
37
+ def run(*subcommands)
38
+ command = "git #{subcommands.join(' ')}"
39
+ execute(command)
40
+ end
41
+
42
+ def git_status_short
43
+ run 'status', '--short'
44
+ end
45
+ end
46
+ end
@@ -15,6 +15,7 @@ module GemComet
15
15
  attr_reader :version, :config
16
16
 
17
17
  def call
18
+ VerifyGitCondition.call
18
19
  UpdatePR.call(update_pr_args)
19
20
  ReleasePR.call(release_pr_args)
20
21
  OpenGithubPullsPage.call
@@ -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.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
data/lib/gem_comet.rb CHANGED
@@ -8,6 +8,7 @@ require 'yaml'
8
8
  require 'gem_comet/version'
9
9
  require 'gem_comet/service_abstract'
10
10
  require 'gem_comet/config'
11
+ require 'gem_comet/git_command'
11
12
  require 'gem_comet/bundle_updater'
12
13
  require 'gem_comet/version_editor'
13
14
  require 'gem_comet/version_history'
@@ -20,4 +21,5 @@ require 'gem_comet/repository_url'
20
21
  require 'gem_comet/release'
21
22
  require 'gem_comet/release/update_pr'
22
23
  require 'gem_comet/release/release_pr'
24
+ require 'gem_comet/verify_git_condition'
23
25
  require 'gem_comet/cli'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_comet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ryz310
@@ -226,12 +226,14 @@ files:
226
226
  - lib/gem_comet/changelog/initializer.rb
227
227
  - lib/gem_comet/cli.rb
228
228
  - lib/gem_comet/config.rb
229
+ - lib/gem_comet/git_command.rb
229
230
  - lib/gem_comet/open_github_pulls_page.rb
230
231
  - lib/gem_comet/release.rb
231
232
  - lib/gem_comet/release/release_pr.rb
232
233
  - lib/gem_comet/release/update_pr.rb
233
234
  - lib/gem_comet/repository_url.rb
234
235
  - lib/gem_comet/service_abstract.rb
236
+ - lib/gem_comet/verify_git_condition.rb
235
237
  - lib/gem_comet/version.rb
236
238
  - lib/gem_comet/version_editor.rb
237
239
  - lib/gem_comet/version_history.rb