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 +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/gem_comet/git_command.rb +46 -0
- data/lib/gem_comet/release.rb +1 -0
- data/lib/gem_comet/verify_git_condition.rb +45 -0
- data/lib/gem_comet/version.rb +1 -1
- data/lib/gem_comet.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba30b799de346dffa5bd093cac66ea82e6797de2d7c8f443bebdc1e1be5d36da
|
4
|
+
data.tar.gz: 1c18e9ec7f1dcbc878c849e77dff5ef368dfc4d8fd40b34f29549d56719da9f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcec552a4d36dc03e55172388c8461f03d41402a6be3c2076dd864c51763b7af0b882165d0bd102ad7e9e2538954ede67d7836609812ccb561baeb06d0ed8ada
|
7
|
+
data.tar.gz: cb728564444d6b938be9eb02b959c13f4f108df3de9b295d2c8f173aaa762fe0545edb99404478e2e5c62bea57ef647ec0be880a1e04c3b1417b006723f9417a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/gem_comet/release.rb
CHANGED
@@ -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
|
data/lib/gem_comet/version.rb
CHANGED
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.
|
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
|