releasetool 0.3.0 → 0.4.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: 983770392f1e8f1b9e2a4d1c7ca5fbf20d60a3c6927e9592dd2550d7b8b055e0
4
- data.tar.gz: 33e70854792ca8494b51bb5db8df0fe5eecda6c4058d14448097fb4da4b5777e
3
+ metadata.gz: 8a125cee11cd4ea5f8f7e0d11f1483c6d97e0d5b8e95f66a86641ac84e27ca1d
4
+ data.tar.gz: 45b0ec021a7e0067655a7c87d334b45687df6a2a4b21920b0b895c770a9045d6
5
5
  SHA512:
6
- metadata.gz: 50dcc0d3b1855bbfcdabb39fe51acf733702215599e0d36a9f17b04e0a99dd2db610cd1aaaa4f0b050488f9e0abc606ad5077f4c3b003e80dd6a3d155c1ef3b0
7
- data.tar.gz: 8dc72d2e9b6704f859d7812b39038b9e9c308d7e4c14975a9e1b8f4e2bf4ff62a69f0bc11a35c40ece91fe12f8cd77c50359750f5b615aac5a667b8c7de2c87b
6
+ metadata.gz: 0c4147c03ebf447fd56092d1348aa95fa5eb808d007ac9a39ce82344724fa5b09921a88628524b379408d4b40a64a0709f7f1aec8f4f4183ea63f37286f38868
7
+ data.tar.gz: a8c6d7e67bde87c0935175e12b75bc400dd0f425cafb8d2d7a318f0ba7ebfad28ba599cce13d65a01d4e74f69b6aab6f4015616021577640035fd8daa32d00df
data/.rubocop.yml ADDED
@@ -0,0 +1,117 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ #require:
4
+ # - rubocop-performance
5
+ # - rubocop-rspec
6
+
7
+ AllCops:
8
+ TargetRubyVersion: 2.7
9
+ DefaultFormatter: fuubar
10
+ Exclude:
11
+ - 'tmp/**/*'
12
+ DisplayCopNames: true
13
+ NewCops: enable
14
+ CacheRootDirectory: tmp # ie. tmp/rubocop_cache
15
+ UseCache: true
16
+
17
+ Gemspec/DevelopmentDependencies:
18
+ EnforcedStyle: gemspec
19
+
20
+ # Don't like this, it's too annoying
21
+ Layout/LineLength:
22
+ Max: 120
23
+ Enabled: false
24
+
25
+ Layout/ParameterAlignment:
26
+ EnforcedStyle: with_fixed_indentation
27
+
28
+ Lint/AmbiguousBlockAssociation:
29
+ Enabled: true
30
+ Exclude:
31
+ - "spec/**/*" # https://github.com/rubocop/rubocop/issues/4222
32
+
33
+ Lint/AssignmentInCondition:
34
+ AutoCorrect: false
35
+
36
+ Lint/UnusedBlockArgument:
37
+ AutoCorrect: false
38
+
39
+ Lint/UnusedMethodArgument:
40
+ AutoCorrect: false
41
+
42
+ Metrics/AbcSize:
43
+ Enabled: false
44
+ # I don't think this is something we want to enforce (yet?)
45
+
46
+ Metrics/BlockLength:
47
+ AllowedMethods:
48
+ - "no_commands" # thor
49
+ Exclude:
50
+ - "spec/**/*.rb"
51
+
52
+ Metrics/ClassLength:
53
+ Enabled: false
54
+
55
+ Metrics/CyclomaticComplexity:
56
+ Enabled: false
57
+
58
+ Metrics/MethodLength:
59
+ Enabled: false
60
+ # No (not yet)
61
+
62
+ Metrics/PerceivedComplexity:
63
+ Enabled: false
64
+
65
+ Naming/AccessorMethodName:
66
+ Enabled: false
67
+ # In theory this is good. In practice lots of false errors
68
+
69
+ ## I'm not very keen on this one
70
+ #Performance/TimesMap:
71
+ # Enabled: false
72
+
73
+ ## I can't see the value of this
74
+ #RSpec/DescribeClass:
75
+ # Enabled: false
76
+
77
+ #RSpec/EmptyExampleGroup:
78
+ # # we need to fix manually - e.g. fill it in or delete it
79
+ # AutoCorrect: false
80
+ #
81
+ ## prefer this
82
+ #RSpec/ExpectChange:
83
+ # EnforcedStyle: block
84
+ #
85
+ ## I can't see the value of this
86
+ #RSpec/MultipleMemoizedHelpers:
87
+ # Enabled: false
88
+ #
89
+ ## This is actually wrong and a mistake (`expect ... to receive ... and return ...` is good practice)
90
+ #RSpec/StubbedMock:
91
+ # Enabled: false
92
+
93
+
94
+ Style/BlockDelimiters:
95
+ Exclude:
96
+ - 'spec/**/*'
97
+
98
+ Style/Documentation:
99
+ Enabled: false
100
+ # Sounds good, but really?
101
+
102
+ Style/DoubleNegation:
103
+ Enabled: false
104
+ # double negation is an ok way to enforce true / false when assigning
105
+
106
+ Style/NumericLiterals:
107
+ Enabled: false
108
+ # This is a pain, most long numeric literals are things like ids or times as numbers
109
+
110
+ Style/StringLiterals:
111
+ Enabled: true
112
+ EnforcedStyle: double_quotes
113
+
114
+ Style/SymbolProc:
115
+ Enabled: true
116
+ AllowMethodsWithArguments: true
117
+ AllowComments: true
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,139 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config --exclude-limit 100`
3
+ # on 2023-09-11 13:28:02 UTC using RuboCop version 1.56.3.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
11
+ # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
12
+ # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
13
+ Naming/FileName:
14
+ Exclude:
15
+ - 'spec/fixtures/example_with_releases/config/initializers/00-version.rb'
16
+
17
+ # Offense count: 8
18
+ # Configuration parameters: ForbiddenDelimiters.
19
+ # ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$))
20
+ Naming/HeredocDelimiterNaming:
21
+ Exclude:
22
+ - 'lib/tasks/release_thor.rb'
23
+
24
+ # Offense count: 15
25
+ # Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
26
+ # SupportedStyles: snake_case, normalcase, non_integer
27
+ # AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
28
+ Naming/VariableNumber:
29
+ Exclude:
30
+ - 'spec/releasetool_spec.rb'
31
+ - 'spec/version_spec.rb'
32
+
33
+ # Offense count: 1
34
+ # This cop supports safe autocorrection (--autocorrect).
35
+ # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
36
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
37
+ # SupportedShorthandSyntax: always, never, either, consistent
38
+ Style/HashSyntax:
39
+ Exclude:
40
+ - 'Rakefile'
41
+
42
+ # Offense count: 6
43
+ # This cop supports unsafe autocorrection (--autocorrect-all).
44
+ # Configuration parameters: EnforcedStyle.
45
+ # SupportedStyles: literals, strict
46
+ Style/MutableConstant:
47
+ Exclude:
48
+ - 'lib/releasetool.rb'
49
+ - 'lib/releasetool/util.rb'
50
+ - 'lib/tasks/release_thor.rb'
51
+ - 'spec/fixtures/example_with_releases/config/initializers/00-version.rb'
52
+
53
+ # Offense count: 1
54
+ # This cop supports unsafe autocorrection (--autocorrect-all).
55
+ # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
56
+ # SupportedStyles: predicate, comparison
57
+ Style/NumericPredicate:
58
+ Exclude:
59
+ - 'spec/**/*'
60
+ - 'lib/tasks/release_thor.rb'
61
+
62
+ # Offense count: 2
63
+ # This cop supports safe autocorrection (--autocorrect).
64
+ # Configuration parameters: PreferredDelimiters.
65
+ Style/PercentLiteralDelimiters:
66
+ Exclude:
67
+ - 'releasetool.gemspec'
68
+
69
+ # Offense count: 3
70
+ # This cop supports safe autocorrection (--autocorrect).
71
+ # Configuration parameters: AllowedCompactTypes.
72
+ # SupportedStyles: compact, exploded
73
+ Style/RaiseArgs:
74
+ EnforcedStyle: compact
75
+
76
+ # Offense count: 2
77
+ # This cop supports safe autocorrection (--autocorrect).
78
+ Style/RedundantPercentQ:
79
+ Exclude:
80
+ - 'releasetool.gemspec'
81
+
82
+ # Offense count: 1
83
+ # This cop supports safe autocorrection (--autocorrect).
84
+ # Configuration parameters: EnforcedStyle.
85
+ # SupportedStyles: only_raise, only_fail, semantic
86
+ Style/SignalException:
87
+ Exclude:
88
+ - 'lib/releasetool/util.rb'
89
+
90
+ # Offense count: 1
91
+ # This cop supports unsafe autocorrection (--autocorrect-all).
92
+ Style/SlicingWithRange:
93
+ Exclude:
94
+ - 'lib/releasetool/version.rb'
95
+
96
+ # Offense count: 1
97
+ # This cop supports safe autocorrection (--autocorrect).
98
+ # Configuration parameters: AllowModifier.
99
+ Style/SoleNestedConditional:
100
+ Exclude:
101
+ - 'lib/releasetool/release.rb'
102
+
103
+ # Offense count: 1
104
+ # This cop supports unsafe autocorrection (--autocorrect-all).
105
+ # Configuration parameters: RequireEnglish, EnforcedStyle.
106
+ # SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
107
+ Style/SpecialGlobalVars:
108
+ Exclude:
109
+ - 'releasetool.gemspec'
110
+
111
+ # Offense count: 34
112
+ # This cop supports safe autocorrection (--autocorrect).
113
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
114
+ # SupportedStyles: single_quotes, double_quotes
115
+ Style/StringLiterals:
116
+ Exclude:
117
+ - 'Gemfile'
118
+ - 'bin/release'
119
+ - 'lib/releasetool/release.rb'
120
+ - 'lib/releasetool/util.rb'
121
+ - 'lib/tasks/release_thor.rb'
122
+ - 'releasetool.gemspec'
123
+ - 'spec/releasetool_spec.rb'
124
+ - 'spec/spec_helper.rb'
125
+ - 'spec/version_spec.rb'
126
+
127
+ # Offense count: 1
128
+ # This cop supports safe autocorrection (--autocorrect).
129
+ # Configuration parameters: EnforcedStyle.
130
+ # SupportedStyles: single_quotes, double_quotes
131
+ Style/StringLiteralsInInterpolation:
132
+ Exclude:
133
+ - 'lib/tasks/release_thor.rb'
134
+
135
+ # Offense count: 1
136
+ # This cop supports unsafe autocorrection (--autocorrect-all).
137
+ Style/ZeroLengthPredicate:
138
+ Exclude:
139
+ - 'lib/tasks/release_thor.rb'
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in releasetool.gemspec
data/README.md CHANGED
@@ -22,6 +22,8 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
+ ```release help```
26
+
25
27
  ### List existing tags
26
28
 
27
29
  ```release list```
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
data/bin/release CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  $LOAD_PATH << File.expand_path('../lib', File.dirname(__FILE__))
3
5
  require File.expand_path('../lib/tasks/release_thor.rb', File.dirname(__FILE__))
4
6
 
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "releasetool/util"
4
+ require "fileutils"
2
5
 
3
6
  module Releasetool
4
7
  class Release
@@ -6,6 +9,7 @@ module Releasetool
6
9
 
7
10
  def initialize(version, previous:)
8
11
  raise "Version must be a Releasetool::Version" unless version.is_a?(Releasetool::Version)
12
+
9
13
  if previous
10
14
  raise "Previous must be nil or a Releasetool::Version" unless version.is_a?(Releasetool::Version)
11
15
  end
@@ -18,10 +22,10 @@ module Releasetool
18
22
  commits = `git log #{@previous}..HEAD --pretty=format:"- %B"`
19
23
  notes = commits.gsub("\n\n", "\n")
20
24
  notes_file = "#{DIR}/#{@version}.md"
21
- if File.exists?(notes_file)
22
- puts "-"*80
25
+ if File.exist?(notes_file)
26
+ puts "-" * 80
23
27
  puts " File '#{notes_file}' already exists (appending)"
24
- puts "-"*80
28
+ puts "-" * 80
25
29
  File.open(notes_file, 'a') do |f|
26
30
  f.puts("\n\nAPPENDED:\n\n")
27
31
  f.puts(notes)
@@ -33,22 +37,20 @@ module Releasetool
33
37
  f.puts(notes)
34
38
  end
35
39
  puts "written to #{notes_file}"
36
- if edit
37
- system("open #{notes_file}")
38
- end
39
- end
40
- if File.exists?(VERSION_FILE)
41
- from_version = @previous.to_s_without_v
42
- to_version = @version.to_s_without_v
43
- guarded_system("cat #{VERSION_FILE} | sed s/#{from_version}/#{to_version.gsub('.', '\.')}/ > #{VERSION_FILE}.tmp")
44
- guarded_system("mv #{VERSION_FILE}.tmp #{VERSION_FILE}")
40
+ system("open #{notes_file}") if edit
45
41
  end
42
+ return unless File.exist?(Releasetool::Util.version_file)
43
+
44
+ from_version = @previous.to_s_without_v
45
+ to_version = @version.to_s_without_v
46
+ guarded_system("cat #{Releasetool::Util.version_file} | sed s/#{from_version}/#{to_version.gsub('.', '\.')}/ > #{Releasetool::Util.version_file}.tmp")
47
+ guarded_system("mv #{Releasetool::Util.version_file}.tmp #{Releasetool::Util.version_file}")
46
48
  end
47
49
 
48
50
  private
49
51
 
50
52
  def ensure_dir
51
- Dir.mkdir(DIR) unless File.exists?(DIR)
53
+ FileUtils.mkdir_p(DIR)
52
54
  end
53
55
 
54
56
  def headers
@@ -62,20 +64,17 @@ module Releasetool
62
64
  def ensured_template_file
63
65
  ensure_dir
64
66
  template_file = "#{DIR}/#{TEMPLATE_FILE}"
65
- create_template_file(template_file) unless File.exists?(template_file)
67
+ create_template_file(template_file) unless File.exist?(template_file)
66
68
  template_file
67
69
  end
68
70
 
69
71
  def create_template_file(template_file)
70
- File.open(template_file, "w") do |f|
71
- f.write <<~FILEEND
72
+ File.write(template_file, <<~FILEEND)
72
73
  $VERSION Release Notes
73
-
74
+
74
75
  *Changes since $PREVIOUS*
75
76
 
76
- FILEEND
77
- end
77
+ FILEEND
78
78
  end
79
-
80
79
  end
81
80
  end
@@ -1,13 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
4
+
1
5
  module Releasetool
2
6
  module Util
3
-
4
7
  DIR = "release_notes"
5
- VERSION_FILE = ENV['RELEASETOOL_VERSION_FILE'] || "config/initializers/00-version.rb" #rails out of box
6
8
  TEMPLATE_FILE = "__TEMPLATE__.md" # relative to DIR
7
9
  RELEASE_MARKER_FILE = ".RELEASE_NEW_VERSION" # should be a config var
8
10
 
11
+ def self.version_file
12
+ # rails out of box
13
+ ENV['RELEASETOOL_VERSION_FILE'] || "config/initializers/00-version.rb"
14
+ end
15
+
9
16
  def stored_version
10
17
  fail Thor::Error.new("No stored version... did you forget to do release start?") unless File.exist?(RELEASE_MARKER_FILE)
18
+
11
19
  File.read(RELEASE_MARKER_FILE).strip
12
20
  end
13
21
 
@@ -19,5 +27,13 @@ module Releasetool
19
27
  puts command
20
28
  system(command) or raise Thor::Error.new("Couldn't '#{command}'")
21
29
  end
30
+
31
+ def guarded_capture(command)
32
+ puts command
33
+ output = `#{command}`
34
+ raise Thor::Error.new("Couldn't '#{command}'") unless $CHILD_STATUS
35
+
36
+ output
37
+ end
22
38
  end
23
39
  end
@@ -1,8 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Releasetool
2
4
  class Version
3
5
  attr_reader :ident
6
+
4
7
  def initialize(ident)
5
8
  raise "Not a valid version identifier: #{ident.inspect}" unless ident.is_a?(String)
9
+
6
10
  @ident = ident
7
11
  end
8
12
 
@@ -43,9 +47,11 @@ module Releasetool
43
47
  end
44
48
 
45
49
  private
46
- def incremented(v)
47
- raise "Can't work out next version from #{self}" unless v.to_i.to_s == v
48
- v.to_i + 1
50
+
51
+ def incremented(number)
52
+ raise "Can't work out next version from #{self}" unless number.to_i.to_s == number
53
+
54
+ number.to_i + 1
49
55
  end
50
56
 
51
57
  def segments
data/lib/releasetool.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "releasetool/release"
2
4
 
3
5
  module Releasetool
4
- VERSION = "0.3.0"
6
+ VERSION = "0.4.0"
5
7
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'thor'
4
+ require "releasetool"
2
5
  require "releasetool/release"
3
6
  require "releasetool/util"
4
7
  require "releasetool/version"
5
8
 
6
9
  class Release < Thor
7
-
8
10
  include Releasetool::Util
9
11
  desc "list", <<-END
10
12
  show a list of tags ordered by date (just a git listing).
@@ -38,7 +40,7 @@ class Release < Thor
38
40
  # ========================
39
41
 
40
42
  method_option :since, type: :string, desc: "since commit_ref (or will use most recent tag)", required: false,
41
- aliases: 's'
43
+ aliases: 's'
42
44
  method_option :edit, type: :boolean, desc: "edit", required: false, aliases: 'e'
43
45
  method_option :minor, type: :boolean, desc: "minor version", required: false, default: false
44
46
 
@@ -46,14 +48,11 @@ class Release < Thor
46
48
  Start a release by doing a prepare, and storing the target release in #{RELEASE_MARKER_FILE}.
47
49
  END
48
50
 
49
- def start(specified_version=nil)
50
- if File.exists?(RELEASE_MARKER_FILE)
51
- raise Thor::Error.new("Can't start when already started on a version. release abort or release finish")
52
- end
51
+ def start(specified_version = nil)
52
+ raise Thor::Error.new("Can't start when already started on a version. release abort or release finish") if File.exist?(RELEASE_MARKER_FILE)
53
+
53
54
  version = next_version(specified_version)
54
- File.open(RELEASE_MARKER_FILE, 'w') do |f|
55
- f.write(version)
56
- end
55
+ File.write(RELEASE_MARKER_FILE, version)
57
56
  Releasetool::Release.new(version, previous: previous_version).prepare(edit: options[:edit])
58
57
  end
59
58
 
@@ -63,11 +62,13 @@ class Release < Thor
63
62
  If no version given, it will use the version stored by release start
64
63
  END
65
64
 
66
- def commit(version=nil)
67
- version ||= stored_version
65
+ # should take release commit --edit which allows you to edit, or --no-edit (default) which allows you to just skip
66
+ method_option :edit, type: :boolean, desc: "edit", aliases: 'e', default: false
67
+ def commit(version = nil)
68
+ version || stored_version
68
69
  guarded_system("git add #{DIR}")
69
- guarded_system("git add #{VERSION_FILE}") if File.exists?(VERSION_FILE)
70
- guarded_system("git commit #{DIR} #{File.exists?(VERSION_FILE) ? VERSION_FILE : ''} -e -m\"#{DEFAULT_COMMIT_MESSAGE}\"")
70
+ guarded_system("git add #{Releasetool::Util.version_file}") if File.exist?(Releasetool::Util.version_file)
71
+ guarded_system("git commit #{DIR} #{File.exist?(Releasetool::Util.version_file) ? Releasetool::Util.version_file : ''} #{options[:edit] ? '-e' : nil} -m\"#{DEFAULT_COMMIT_MESSAGE}\"")
71
72
  end
72
73
 
73
74
  desc "tag (NEW_VERSION)", <<-END
@@ -75,9 +76,10 @@ class Release < Thor
75
76
  If no version given, it will use the version stored by release start
76
77
  END
77
78
 
78
- def tag(version=nil)
79
+ def tag(version = nil)
79
80
  version ||= stored_version
80
- guarded_system("git tag -a #{version}")
81
+ last_useful_commit = guarded_capture("git log head^^..head^ --pretty=format:%s").strip.split("\n").first.strip
82
+ guarded_system("git tag -a #{version} -e -m \"#{last_useful_commit}\"")
81
83
  end
82
84
 
83
85
  desc "push (NEW_VERSION)", <<-END
@@ -85,7 +87,7 @@ class Release < Thor
85
87
  If no version given, it will use the version stored by release start.
86
88
  END
87
89
 
88
- def push(version=nil)
90
+ def push(version = nil)
89
91
  version ||= stored_version
90
92
  guarded_system("git push")
91
93
  guarded_system("git push origin #{version}")
@@ -100,10 +102,18 @@ class Release < Thor
100
102
  remove_stored_version
101
103
  end
102
104
 
105
+ map %w[--version -v] => :__print_version
106
+
107
+ desc "--version, -v", "print the version"
108
+ def __print_version
109
+ say "Releasetool v#{Releasetool::VERSION}"
110
+ end
111
+
103
112
  protected
104
113
 
105
114
  def next_version(specified)
106
115
  return Releasetool::Version.new(specified) if specified
116
+
107
117
  if options[:major]
108
118
  previous_version.next_major
109
119
  elsif options[:minor]
@@ -0,0 +1,7 @@
1
+ v0.4.0 Release Notes
2
+
3
+ *Changes since v0.3.0*
4
+
5
+ * `release commit` now doesn't require you to edit message by default. If you want to edit use `release commit --edit`
6
+ * `release tag` now gives you the previous log message as the default tag message (useful in case of release a single-issue/commit)
7
+ * `release --version` to print version
data/releasetool.gemspec CHANGED
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'releasetool'
5
6
 
@@ -15,12 +16,14 @@ Gem::Specification.new do |spec|
15
16
 
16
17
  spec.files = `git ls-files`.split($/)
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = '>= 2.7.0'
20
21
 
21
22
  spec.add_dependency 'thor', '>= 0.18'
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 2.1"
24
25
  spec.add_development_dependency "rake"
25
26
  spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "rubocop", "1.56.3"
28
+ spec.metadata['rubygems_mfa_required'] = 'true'
26
29
  end
@@ -1,40 +1,42 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'fileutils'
3
- require File.expand_path('../../lib/tasks/release_thor', __FILE__)
5
+ require File.expand_path('../lib/tasks/release_thor', __dir__)
4
6
 
5
- describe Releasetool do
7
+ RSpec.describe Releasetool do
6
8
  it 'should have a version number' do
7
9
  expect(Releasetool::VERSION).not_to be_nil
8
10
  end
9
11
  end
10
12
 
11
- describe Release, quietly: true do
13
+ RSpec.describe Release, quietly: true do
12
14
  subject { Release.new }
13
- TMPDIR = File.expand_path('../../tmp/testing', __FILE__)
14
- ROOT_DIR = File.expand_path('../..', __FILE__)
15
+ let(:tmpdir) { File.expand_path('../tmp/testing', __dir__) }
16
+ let(:root_dir) { File.expand_path('..', __dir__) }
15
17
  before {
16
- FileUtils.rmtree(TMPDIR)
17
- FileUtils.mkdir_p(TMPDIR)
18
- FileUtils.chdir(TMPDIR)
18
+ FileUtils.rmtree(tmpdir)
19
+ FileUtils.mkdir_p(tmpdir)
20
+ FileUtils.chdir(tmpdir)
19
21
  system('tar -xf ../../spec/fixtures/example_with_releases.tar')
20
22
  }
21
23
  after {
22
- FileUtils.chdir(ROOT_DIR)
24
+ FileUtils.chdir(root_dir)
23
25
  }
24
26
  it "should respond to list" do
25
27
  subject.list
26
28
  end
27
29
 
28
- let(:mock_target){ instance_double(Releasetool::Release)}
29
- let(:v_0_0_1) {Releasetool::Version.new("v0.0.1")}
30
- let(:v_0_0_2) {Releasetool::Version.new("v0.0.2")}
31
- let(:v_0_0_3) {Releasetool::Version.new("v0.0.3")}
32
- let(:v_0_1_0) {Releasetool::Version.new("v0.1.0")}
33
- let(:v_1_0_0) {Releasetool::Version.new("v1.0.0")}
30
+ let(:mock_target) { instance_double(Releasetool::Release) }
31
+ let(:v_0_0_1) { Releasetool::Version.new("v0.0.1") }
32
+ let(:v_0_0_2) { Releasetool::Version.new("v0.0.2") }
33
+ let(:v_0_0_3) { Releasetool::Version.new("v0.0.3") }
34
+ let(:v_0_1_0) { Releasetool::Version.new("v0.1.0") }
35
+ let(:v_1_0_0) { Releasetool::Version.new("v1.0.0") }
34
36
 
35
- context "start" do
37
+ describe "start" do
36
38
  context "with a since" do
37
- subject { Release.new([], {since: 'v0.0.2'}, {}) }
39
+ subject { Release.new([], { since: 'v0.0.2' }, {}) }
38
40
  it "it should do a prepare and store a file" do
39
41
  expect(Releasetool::Release).to receive(:new).with(v_0_0_3, previous: v_0_0_2).and_return(mock_target)
40
42
  expect(mock_target).to receive(:prepare)
@@ -44,13 +46,13 @@ describe Release, quietly: true do
44
46
  allow(Releasetool::Release).to receive(:new).with(v_0_0_3, previous: v_0_0_2).and_return(mock_target)
45
47
  allow(mock_target).to receive(:prepare)
46
48
  expect { subject.start('v0.0.3') }.to change {
47
- File.exist?(File.join(TMPDIR, '.RELEASE_NEW_VERSION'))
48
- }
49
- expect(File.read(File.join(TMPDIR, '.RELEASE_NEW_VERSION')).to_s).to eq('v0.0.3')
49
+ File.exist?(File.join(tmpdir, '.RELEASE_NEW_VERSION'))
50
+ }
51
+ expect(File.read(File.join(tmpdir, '.RELEASE_NEW_VERSION')).to_s).to eq('v0.0.3')
50
52
  end
51
53
 
52
54
  it "with existing release-version file, it should freak out" do
53
- FileUtils.touch(File.join(TMPDIR, '.RELEASE_NEW_VERSION'))
55
+ FileUtils.touch(File.join(tmpdir, '.RELEASE_NEW_VERSION'))
54
56
  expect { subject.start('v0.0.3') }.to raise_error
55
57
  end
56
58
  end
@@ -72,7 +74,7 @@ describe Release, quietly: true do
72
74
  end
73
75
 
74
76
  context "without a new version but with --minor modifier" do
75
- subject { Release.new([], {minor: true}, {}) }
77
+ subject { Release.new([], { minor: true }, {}) }
76
78
 
77
79
  it "it should use next minor level" do
78
80
  expect(Releasetool::Release).to receive(:new).with(v_0_1_0, previous: v_0_0_1).and_return(mock_target)
@@ -82,7 +84,7 @@ describe Release, quietly: true do
82
84
  end
83
85
 
84
86
  context "without a new version but with --major modifier" do
85
- subject { Release.new([], {major: true}, {}) }
87
+ subject { Release.new([], { major: true }, {}) }
86
88
 
87
89
  it "it should use next minor level" do
88
90
  expect(Releasetool::Release).to receive(:new).with(v_1_0_0, previous: v_0_0_1).and_return(mock_target)
@@ -92,9 +94,31 @@ describe Release, quietly: true do
92
94
  end
93
95
  end
94
96
 
97
+ describe "commit" do
98
+ before {
99
+ allow(ENV).to receive(:[]).with('RELEASETOOL_VERSION_FILE').and_return(nil) # in case it is defined...
100
+ expect(subject).to receive(:guarded_system).with("git add release_notes")
101
+ expect(subject).to receive(:guarded_system).with("git add config/initializers/00-version.rb")
102
+ }
103
+ context "with no args" do
104
+ it "outputs without -e" do
105
+ expect(subject).to receive(:guarded_system).with("git commit release_notes config/initializers/00-version.rb -m\"#{Release::DEFAULT_COMMIT_MESSAGE}\"")
106
+ subject.commit('v0.0.3')
107
+ end
108
+ end
109
+
110
+ context "with --edit" do
111
+ subject { Release.new([], { edit: true }, {}) }
112
+ it "outputs with e" do
113
+ expect(subject).to receive(:guarded_system).with("git commit release_notes config/initializers/00-version.rb -e -m\"#{Release::DEFAULT_COMMIT_MESSAGE}\"")
114
+ subject.commit('v0.0.3')
115
+ end
116
+ end
117
+ end
118
+
95
119
  describe "latest" do
96
120
  it "outputs latest version" do
97
- expect{subject.latest}.to output("v0.0.1\n").to_stdout
121
+ expect { subject.latest }.to output("v0.0.1\n").to_stdout
98
122
  end
99
123
  end
100
124
 
@@ -110,7 +134,6 @@ describe Release, quietly: true do
110
134
  end
111
135
  end
112
136
 
113
-
114
137
  # describe 'CLI' do
115
138
  # it "should work with source and no target" do
116
139
  # puts "CLI"
@@ -137,5 +160,4 @@ describe Release, quietly: true do
137
160
  # }.strip).not_to eq('')
138
161
  # end
139
162
  # end
140
-
141
163
  end
data/spec/spec_helper.rb CHANGED
@@ -1,17 +1,17 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
4
  require 'releasetool'
3
5
 
4
6
  RSpec.configure do |config|
5
7
  config.around quietly: true do |example|
6
- RSpec.configure do |config|
7
- original_stderr = $stderr
8
- original_stdout = $stdout
9
- # Redirect stderr and stdout
10
- $stderr = File.open(File::NULL, "w")
11
- $stdout = File.open(File::NULL, "w")
12
- example.run
13
- $stderr = original_stderr
14
- $stdout = original_stdout
15
- end
8
+ original_stderr = $stderr
9
+ original_stdout = $stdout
10
+ # Redirect stderr and stdout
11
+ $stderr = File.open(File::NULL, "w")
12
+ $stdout = File.open(File::NULL, "w")
13
+ example.run
14
+ $stderr = original_stderr
15
+ $stdout = original_stdout
16
16
  end
17
17
  end
data/spec/version_spec.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  require "releasetool/version"
@@ -21,9 +23,9 @@ describe Releasetool::Version do
21
23
  end
22
24
 
23
25
  describe "next_patch" do
24
- let(:v_0_0_1) {Releasetool::Version.new("v0.0.1")}
25
- let(:v_0_0_2) {Releasetool::Version.new("v0.0.2")}
26
- let(:v_0_0_3) {Releasetool::Version.new("v0.0.3")}
26
+ let(:v_0_0_1) { Releasetool::Version.new("v0.0.1") }
27
+ let(:v_0_0_2) { Releasetool::Version.new("v0.0.2") }
28
+ let(:v_0_0_3) { Releasetool::Version.new("v0.0.3") }
27
29
 
28
30
  it "is next" do
29
31
  expect(v_0_0_1.next_patch).to eq(v_0_0_2)
@@ -34,9 +36,9 @@ describe Releasetool::Version do
34
36
  end
35
37
 
36
38
  describe "next_minor" do
37
- let(:v_0_0_1) {Releasetool::Version.new("v0.0.1")}
38
- let(:v_0_1_0) {Releasetool::Version.new("v0.1.0")}
39
- let(:v_0_2_0) {Releasetool::Version.new("v0.2.0")}
39
+ let(:v_0_0_1) { Releasetool::Version.new("v0.0.1") }
40
+ let(:v_0_1_0) { Releasetool::Version.new("v0.1.0") }
41
+ let(:v_0_2_0) { Releasetool::Version.new("v0.2.0") }
40
42
 
41
43
  it "is next" do
42
44
  expect(v_0_0_1.next_minor).to eq(v_0_1_0)
@@ -47,9 +49,9 @@ describe Releasetool::Version do
47
49
  end
48
50
 
49
51
  describe "next_major" do
50
- let(:v_0_1_1) {Releasetool::Version.new("v0.1.1")}
51
- let(:v_1_0_0) {Releasetool::Version.new("v1.0.0")}
52
- let(:v_2_0_0) {Releasetool::Version.new("v2.0.0")}
52
+ let(:v_0_1_1) { Releasetool::Version.new("v0.1.1") }
53
+ let(:v_1_0_0) { Releasetool::Version.new("v1.0.0") }
54
+ let(:v_2_0_0) { Releasetool::Version.new("v2.0.0") }
53
55
 
54
56
  it "is next" do
55
57
  expect(v_0_1_1.next_major).to eq(v_1_0_0)
@@ -60,11 +62,8 @@ describe Releasetool::Version do
60
62
  end
61
63
 
62
64
  describe "==" do
63
- let(:v_0_0_2) {Releasetool::Version.new("v0.0.2")}
65
+ let(:v_0_0_2) { Releasetool::Version.new("v0.0.2") }
64
66
 
65
- it "is self same" do
66
- expect(v_0_0_2 == v_0_0_2).to be_truthy
67
- end
68
67
  it "is same if other is a version of same" do
69
68
  expect(v_0_0_2 == Releasetool::Version.new("v0.0.2")).to be_truthy
70
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releasetool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Diggins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.56.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.56.3
69
83
  description: Some release-related functions, initially just release notes management
70
84
  and creation
71
85
  email:
@@ -76,6 +90,8 @@ extensions: []
76
90
  extra_rdoc_files: []
77
91
  files:
78
92
  - ".gitignore"
93
+ - ".rubocop.yml"
94
+ - ".rubocop_todo.yml"
79
95
  - Gemfile
80
96
  - LICENSE.txt
81
97
  - README.md
@@ -94,6 +110,7 @@ files:
94
110
  - release_notes/v0.1.1.md
95
111
  - release_notes/v0.2.0.md
96
112
  - release_notes/v0.3.0.md
113
+ - release_notes/v0.4.0.md
97
114
  - releasetool.gemspec
98
115
  - spec/fixtures/example_with_releases.tar
99
116
  - spec/releasetool_spec.rb
@@ -102,7 +119,8 @@ files:
102
119
  homepage: ''
103
120
  licenses:
104
121
  - MIT
105
- metadata: {}
122
+ metadata:
123
+ rubygems_mfa_required: 'true'
106
124
  post_install_message:
107
125
  rdoc_options: []
108
126
  require_paths:
@@ -111,19 +129,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
111
129
  requirements:
112
130
  - - ">="
113
131
  - !ruby/object:Gem::Version
114
- version: '0'
132
+ version: 2.7.0
115
133
  required_rubygems_version: !ruby/object:Gem::Requirement
116
134
  requirements:
117
135
  - - ">="
118
136
  - !ruby/object:Gem::Version
119
137
  version: '0'
120
138
  requirements: []
121
- rubygems_version: 3.2.5
139
+ rubygems_version: 3.1.6
122
140
  signing_key:
123
141
  specification_version: 4
124
142
  summary: Release management tools
125
- test_files:
126
- - spec/fixtures/example_with_releases.tar
127
- - spec/releasetool_spec.rb
128
- - spec/spec_helper.rb
129
- - spec/version_spec.rb
143
+ test_files: []