bunup 0.1.0 → 0.2.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: aecb6c5b9952bc73f6e059f520a6ffb477869fa5c44f4855e92a0de17ab50d6f
4
- data.tar.gz: d0d5dc8e96c0866cafb55d380ffd3cb6d9602ba7d40a20ff81ba6312ec30e680
3
+ metadata.gz: e535e339b0b9521d91a170655c46a6384f459b8f101f07444ad060ae57994dfb
4
+ data.tar.gz: 3aba273f29f740dc3ed9a4dd9473164488929a51c01ffe90a68a3b3915bc768c
5
5
  SHA512:
6
- metadata.gz: 85686d9b73831bf4fce8d3d5e6d42ec08011315fef82e5d0ba5eba9c7e9b9541d327e9e3f166699fc2ea4b8fd0cd7d21e17c0caea8094d9574b4e45cef37bcd1
7
- data.tar.gz: f0568922bd09be73673b7e678427d9de957c49c2d3360fbec279c3f037ec1a5b35caf9f7189e00f261d513bdb58c9e48fba243e54874b19afaf23360c98e96ce
6
+ metadata.gz: de8b290a7438ea3b8aa5d3b92c1e37cd44adb7972f67527cc583f19baa101980ab5824bffd1bc6b9cd5c8bcd83bdd0639d4935c21312b939bbe2d9aed0d84df5
7
+ data.tar.gz: 73d30288f035f24eaeb43dcedb7e9f23c8f3805fb440c425b80b4b001a08a2489b11c0aa9e0331718963a537cd28cb1971d0064a49c0aa7923592617d5a280ac
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## Unreleased
8
+
9
+ ## [0.2.0](https://github.com/singlebrook/bunup/releases/tag/v0.2.0)
10
+
11
+ - Support Bundler 2
12
+ - Support gems installed from git sources
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  [![Build Status](https://travis-ci.org/singlebrook/bunup.svg?branch=master)](https://travis-ci.org/singlebrook/bunup)
3
+ ![Gem](https://img.shields.io/gem/v/bunup.svg)
3
4
 
4
5
  # Bunup
5
6
 
@@ -44,7 +45,7 @@ bunup rake rubocop
44
45
  ### Options
45
46
 
46
47
  * `--all`: Update all outdated gems. This is the default.
47
- * `-y` `--yes` `--assume-yes`: Answer "yes" to major version update prompts and run non-interactively
48
+ * `-y` `--yes` `--assume-yes [major, git]`: Answer "yes" to major version or git version update prompts and run non-interactively. Defaults to all.
48
49
 
49
50
  ## Development
50
51
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ['lib']
25
25
  spec.required_ruby_version = '>= 2.1'
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'bundler', '>= 1.16', '< 2.1'
28
28
  spec.add_development_dependency 'byebug', '~> 9.0'
29
29
  spec.add_development_dependency 'rake', '~> 10.0'
30
30
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -5,6 +5,10 @@ module Bunup
5
5
  E_DIRTY_GEMFILE = 'Gemfile and/or Gemfile.lock has changes that would ' \
6
6
  'be overwritten. Please stash or commit your changes before running ' \
7
7
  'bunup.'.freeze
8
+ GIT_REF_UPDATE_WARNING = 'WARNING: %<gem_name>s is installed from a git ' \
9
+ 'repo and is being updated from %<installed_version>s to ' \
10
+ '%<newest_version>s. This update could include breaking changes. ' \
11
+ 'Continue? [y/N] '.freeze
8
12
  MAJOR_VERSION_UPDATE_WARNING_FMT = 'WARNING: %<gem_name>s is being ' \
9
13
  'updated from %<installed_version>s to %<newest_version>s. This is ' \
10
14
  'a major version update with possible breaking changes. ' \
@@ -36,12 +40,12 @@ module Bunup
36
40
  end
37
41
 
38
42
  def build_gems
39
- bundle_outdated.split("\n").map do |line|
43
+ bundle_outdated.split("\n").map.with_object([]) do |line, gems|
40
44
  next unless Bundler::OUTDATED_PATTERN =~ line
41
45
 
42
46
  match_data = Bundler::OUTDATED_PATTERN.match(line)
43
- build_gem(match_data)
44
- end.compact
47
+ gems << build_gem(match_data)
48
+ end
45
49
  end
46
50
 
47
51
  def bundle_outdated
@@ -76,9 +80,26 @@ module Bunup
76
80
  def major_version_update?
77
81
  return false if @gem.newest_version.nil? || @gem.installed_version.nil?
78
82
 
79
- major_version = ->(version) { version.split('.')[0].to_i }
80
- major_version.call(@gem.newest_version) >
81
- major_version.call(@gem.installed_version)
83
+ @gem.newest_version.major > @gem.installed_version.major
84
+ end
85
+
86
+ # A major version update has breaking changes, according to Semantic
87
+ # Versioning (https://semver.org/spec/v2.0.0.html). Let's make sure the
88
+ # user is aware of that.
89
+ def prompt_for_git_ref_update
90
+ print format(
91
+ GIT_REF_UPDATE_WARNING,
92
+ gem_name: @gem.name,
93
+ installed_version: @gem.installed_version,
94
+ newest_version: @gem.newest_version
95
+ )
96
+ if @options[:assume_yes_for_git_update]
97
+ print "assuming yes\n"
98
+ else
99
+ unless STDIN.gets.chomp.casecmp('y').zero?
100
+ raise ::SystemExit.new(true, 'No update performed')
101
+ end
102
+ end
82
103
  end
83
104
 
84
105
  # A major version update has breaking changes, according to Semantic
@@ -91,7 +112,7 @@ module Bunup
91
112
  installed_version: @gem.installed_version,
92
113
  newest_version: @gem.newest_version
93
114
  )
94
- if @options.assume_yes
115
+ if @options[:assume_yes_for_major_version_update]
95
116
  print "assuming yes\n"
96
117
  else
97
118
  unless STDIN.gets.chomp.casecmp('y').zero?
@@ -116,6 +137,7 @@ module Bunup
116
137
  @gem = gem
117
138
  begin
118
139
  prompt_for_major_update if major_version_update?
140
+ prompt_for_git_ref_update if @gem.installed_from_git?
119
141
  update
120
142
  commit
121
143
  rescue ::SystemExit => e
@@ -14,19 +14,23 @@ module Bunup
14
14
 
15
15
  def initialize(name: nil, installed_version: nil, newest_version: nil)
16
16
  @name = name
17
- @installed_version = installed_version
18
- @newest_version = newest_version
17
+ @installed_version = Values::Version.new(installed_version)
18
+ @newest_version = Values::Version.new(newest_version)
19
19
  validate
20
20
  end
21
21
 
22
+ def installed_from_git?
23
+ installed_version.from_git? || newest_version.from_git?
24
+ end
25
+
22
26
  private
23
27
 
24
28
  def validate
25
29
  abort "Invalid gem name: #{name}" unless valid_name?
26
- unless valid_version?(installed_version)
30
+ unless installed_version.valid?
27
31
  abort "Invalid version for #{name}: #{installed_version}"
28
32
  end
29
- unless valid_version?(newest_version)
33
+ unless newest_version.valid?
30
34
  abort "Invalid version for #{name}: #{newest_version}"
31
35
  end
32
36
  end
@@ -34,9 +38,5 @@ module Bunup
34
38
  def valid_name?
35
39
  name =~ NAME_PATTERN
36
40
  end
37
-
38
- def valid_version?(version_string)
39
- ::Gem::Version.correct?(version_string)
40
- end
41
41
  end
42
42
  end
@@ -16,10 +16,25 @@ module Bunup
16
16
  options.all = true
17
17
  end
18
18
 
19
- assume_yes_msg = 'Answer "yes" to major version update prompts ' \
20
- 'and run non-interactively'
21
- opts.on('-y', '--yes', '--assume-yes', assume_yes_msg) do
22
- options.assume_yes = true
19
+ assume_yes_msg = 'Answer "yes" to all major or git version update ' \
20
+ 'prompts, or all, and run non-interactively. Defaults to all.'
21
+ opts.on(
22
+ '-y', '--yes', '--assume-yes [major, git]',
23
+ Array,
24
+ assume_yes_msg
25
+ ) do |list|
26
+ if list.nil?
27
+ options[:assume_yes_for_major_version_update] = true
28
+ options[:assume_yes_for_git_update] = true
29
+ else
30
+ list.each do |version_type|
31
+ case version_type.strip
32
+ when 'major'
33
+ then options[:assume_yes_for_major_version_update] = true
34
+ when 'git' then options[:assume_yes_for_git_update] = true
35
+ end
36
+ end
37
+ end
23
38
  end
24
39
 
25
40
  opts.on('-h', '--help', 'Prints this help') do
@@ -0,0 +1,21 @@
1
+ module Bunup
2
+ module Services
3
+ # Validate that version of gem installed from a git source is valid
4
+ class ValidateGitVersion
5
+ # https://stackoverflow.com/questions/468370/a-regex-to-match-a-sha1#468378
6
+ SHA_REGEX = /\b[0-9a-f]{5,40}\b/.freeze
7
+
8
+ def initialize(version_string)
9
+ @version_string = version_string
10
+ end
11
+
12
+ def perform
13
+ version, sha = @version_string.split(' ')
14
+ return false if sha.nil?
15
+
16
+ ::Gem::Version.correct?(version) &&
17
+ sha.match?(SHA_REGEX)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ module Bunup
2
+ module Values
3
+ # Parse and handle version strings
4
+ class Version
5
+ def initialize(version_string)
6
+ @version_string = version_string
7
+ end
8
+
9
+ def to_s
10
+ @version_string
11
+ end
12
+
13
+ def major
14
+ if from_git?
15
+ # '6.0.0.rc2 b6f1d19' => 6
16
+ @version_string.split(' ')[0].split('.')[0].to_i
17
+ else
18
+ # '6.0.0.rc2' => 6
19
+ @version_string.split('.')[0].to_i
20
+ end
21
+ end
22
+
23
+ def from_git?
24
+ Services::ValidateGitVersion.new(@version_string).perform
25
+ end
26
+
27
+ def nil?
28
+ @version_string == '' || @version_string.nil?
29
+ end
30
+
31
+ def valid?
32
+ ::Gem::Version.correct?(@version_string) ||
33
+ Services::ValidateGitVersion.new(@version_string).perform
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module Bunup
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Beck
@@ -10,22 +10,28 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-11-02 00:00:00.000000000 Z
13
+ date: 2019-09-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '1.16'
22
+ - - "<"
23
+ - !ruby/object:Gem::Version
24
+ version: '2.1'
22
25
  type: :development
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
- - - "~>"
29
+ - - ">="
27
30
  - !ruby/object:Gem::Version
28
31
  version: '1.16'
32
+ - - "<"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.1'
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: byebug
31
37
  requirement: !ruby/object:Gem::Requirement
@@ -109,6 +115,7 @@ files:
109
115
  - ".gitignore"
110
116
  - ".rubocop.yml"
111
117
  - ".travis.yml"
118
+ - CHANGELOG.md
112
119
  - CODE_OF_CONDUCT.md
113
120
  - Gemfile
114
121
  - LICENSE.txt
@@ -125,6 +132,8 @@ files:
125
132
  - lib/bunup/options.rb
126
133
  - lib/bunup/services/commiter.rb
127
134
  - lib/bunup/services/updater.rb
135
+ - lib/bunup/services/validate_git_version.rb
136
+ - lib/bunup/values/version.rb
128
137
  - lib/bunup/version.rb
129
138
  homepage: https://github.com/singlebrook/bunup
130
139
  licenses:
@@ -145,8 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
154
  - !ruby/object:Gem::Version
146
155
  version: '0'
147
156
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 2.7.6
157
+ rubygems_version: 3.0.3
150
158
  signing_key:
151
159
  specification_version: 4
152
160
  summary: Bundle update and commit to git with one command