version-manager 0.0.7 → 0.0.8

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
  SHA1:
3
- metadata.gz: 9c8b3d22e9596018b567dd472b59fa1403ce49bc
4
- data.tar.gz: f2c07628d82f8c67c0da20d3b28c544c9a6c8dd2
3
+ metadata.gz: 6d559cf3375b9da3ddd916c4fc9e95f7337d0b28
4
+ data.tar.gz: 818ec77ac1bf956b2249c2a887c0b36b316f510d
5
5
  SHA512:
6
- metadata.gz: daaf1b6beb27e15b7ebe3b591d743ae4c7bfc46ebf44e858ae7a66d430120851f9ccebaccc697ace4a2f90873bc30e461fe2c8d363aebe24872fe0b532f54349
7
- data.tar.gz: 2cc0e45bdca3993a12fd397da1e84c4716f88b460364da8c57e30d4114c78ecc6bde71e22d1fda1cbb1c00ff86aba7d75474366d4ecb177f00769eb6bc87b78a
6
+ metadata.gz: b318adf3f2c519388297683f17abc7c98116a41bdebf759307c099ff9fdfd0ab0fcd39c67a5d8d1ae08d8dbc4c95eafd673494084423d7dcef35842b12e279e6
7
+ data.tar.gz: 2f026727ac553beca5dd328b895ff9ee45e9584fe8265c5c53564d27c08dc72b71798365a96ee2ddfdfc08f652e4d73bb33413ec4788a1dad9ea7980be94bc55
@@ -49,13 +49,19 @@ module VersionManager
49
49
 
50
50
  def make_release(release_type)
51
51
  storage = build_storage
52
- version = release_type == :patch ? storage.current_version : storage.latest_version
53
52
 
54
- new_version = version.public_send("bump_#{release_type}")
55
- return if version && !Ask.confirm("You are going to upgrade version to #{new_version}. Do it?", default: false)
56
- version = retrieve_initial_version unless version
53
+ make = Make.new(VCS.build, storage)
54
+ make.validate!(release_type)
55
+
56
+ version = release_type == :patch ? storage.current_version : storage.latest_version
57
+ if version
58
+ new_version = version.public_send("bump_#{release_type}")
59
+ return unless Ask.confirm("You are going to upgrade version to #{new_version}. Do it?", default: false)
60
+ else
61
+ version = retrieve_initial_version
62
+ end
57
63
 
58
- Make.new(version, VCS.build, storage).public_send("#{release_type}!")
64
+ make.public_send("#{release_type}!", version)
59
65
  rescue VersionManager::VersionStorage::WrongLatestVersionError => e
60
66
  puts "There is inappropriate version #{e.version} in your local/remote repository. Please remove it"
61
67
  end
@@ -12,45 +12,42 @@ module VersionManager
12
12
  end
13
13
  end
14
14
 
15
- def initialize(version, vcs, version_storage)
16
- @version = version
15
+ def initialize(vcs, version_storage)
17
16
  @vcs = vcs
18
17
  @version_storage = version_storage
19
18
  end
20
19
 
21
- def major!
20
+ def validate!(release_type)
22
21
  raise BranchIsNotUpToDateError unless vcs.master_state_actual?
23
- raise ForbiddenBranchError unless appropriate_branch_for?('major')
24
- default_strategy { version.bump_major }
22
+ raise ForbiddenBranchError unless appropriate_branch_for?(release_type)
25
23
  end
26
24
 
27
- def minor!
28
- raise BranchIsNotUpToDateError unless vcs.master_state_actual?
29
- raise ForbiddenBranchError unless appropriate_branch_for?('minor')
30
- default_strategy { version.bump_minor }
25
+ def major!(version)
26
+ default_strategy(version.bump_major)
31
27
  end
32
28
 
33
- def patch!
34
- raise BranchIsNotUpToDateError unless vcs.state_actual?
35
- raise ForbiddenBranchError unless appropriate_branch_for?('patch')
36
- @version = version.bump_patch
37
- vcs.commit(version_storage.store(version), default_commit_message)
38
- vcs.add_tag(version.to_s, default_commit_message)
29
+ def minor!(version)
30
+ default_strategy(version.bump_minor)
31
+ end
32
+
33
+ def patch!(version)
34
+ version = version.bump_patch
35
+ vcs.commit(version_storage.store(version), default_commit_message(version))
36
+ vcs.add_tag(version.to_s, default_commit_message(version))
39
37
  vcs.push_tag(version.to_s)
40
38
  vcs.push
41
39
  end
42
40
 
43
41
  private
44
42
 
45
- attr_reader :version, :vcs, :version_storage
43
+ attr_reader :vcs, :version_storage
46
44
 
47
45
  def appropriate_branch_for?(action)
48
46
  authorized_mask = VersionManager.options[:authorized_branches][action.to_sym]
49
47
  !authorized_mask || !vcs.current_branch.match(authorized_mask).nil?
50
48
  end
51
49
 
52
- def default_strategy
53
- @version = yield
50
+ def default_strategy(version)
54
51
  vcs.create_branch!(version.branch)
55
52
  vcs.commit(version_storage.store(version), default_commit_message)
56
53
  vcs.add_tag(version.to_s, default_commit_message)
@@ -58,7 +55,7 @@ module VersionManager
58
55
  vcs.push
59
56
  end
60
57
 
61
- def default_commit_message
58
+ def default_commit_message(version)
62
59
  message = VersionManager.options[:vcs][:default_commit_message]
63
60
  message.respond_to?(:call) ? message.call(version) : message.to_s
64
61
  end
@@ -20,7 +20,7 @@ module VersionManager
20
20
  end
21
21
 
22
22
  def show_file(branch, filepath)
23
- git.object("#{branch}:#{filepath}").contents
23
+ git.object("#{remote}/#{branch}:#{filepath}").contents
24
24
  rescue StandardError
25
25
  nil
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module VersionManager
2
- VERSION = '0.0.7'.freeze
2
+ VERSION = '0.0.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: version-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - isolo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-27 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler