git_version_bumper 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2bfd91f6e41b4524121fc7b2b2728eb96bf45d87
4
+ data.tar.gz: 89b146b16396ce92a0250b35a80ad0174399c3ac
5
+ SHA512:
6
+ metadata.gz: 84a2530d562238145784725fe62fb34c5cdb4e5f41bee15b4067f563f4baf215a788cba437168ad2b224548f67364999dabc8ff0846ee366f810d2c1ca52261a
7
+ data.tar.gz: ee5d9fdb313c4772a46404199b0c15a1bf9a2f82b9fee8610407d8e0177965bafab76cf2f58bfb0d9461d2c5a2e445d3603258ed2fb653ae60ea66290a6f9592
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,30 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - 2.1
8
+ - 2.2
9
+ - 2.3.0
10
+ - ruby-head
11
+ - jruby-19mode
12
+ - jruby-9.0.1.0
13
+ - rbx-3
14
+ env:
15
+ # this doesn't do anything for MRI or RBX, but it doesn't hurt them either
16
+ # for JRuby, it enables us to get more accurate coverage data
17
+ - JRUBY_OPTS="--debug"
18
+ matrix:
19
+ allow_failures:
20
+ - rvm: ruby-head
21
+ - rvm: rbx-3
22
+ fast_finish: true
23
+ before_install: gem update --remote bundler
24
+ install:
25
+ - bundle install --retry=3
26
+ script:
27
+ - bundle exec rspec
28
+ addons:
29
+ code_climate:
30
+ repo_token: d946fbe840359053ee5604eb18d4cd53c9da50bb2e6af66191385e49962be152
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in git_version_bumper.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'codeclimate-test-reporter', require: false
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Troy Rosenberg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ [![Code Climate](https://codeclimate.com/github/tmr08c/git_version_bumper/badges/gpa.svg)](https://codeclimate.com/github/tmr08c/git_version_bumper)
2
+ [![Test Coverage](https://codeclimate.com/github/tmr08c/git_version_bumper/badges/coverage.svg)](https://codeclimate.com/github/tmr08c/git_version_bumper/coverage)
3
+ [![Build Status](https://travis-ci.org/tmr08c/git_version_bumper.svg?branch=master)](https://travis-ci.org/tmr08c/git_version_bumper)
4
+
5
+ # GitVersionBumper
6
+
7
+ CLI tool to create version bump commit and tag witCLI tool to create version bump commit and tag with newest version in a Git repository. Versioning is based on [Semantic Versioning](http://semver.org/). Version bump types include `MAJOR`, `MINOR`, and `PATCH`.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'git_version_bumper'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install git_version_bumper
22
+
23
+ ## Usage
24
+
25
+ From within your Git repository you can run the gem using the `versionify`'s `bump` command in combination with a valid version bump type.
26
+
27
+ ```
28
+ versionify bump TYPE
29
+ ```
30
+
31
+ ### Version Bump Types
32
+
33
+ Valid version bump types include:
34
+
35
+ * MAJOR
36
+ * MINOR
37
+ * PATCH
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/tmr08c/git_version_bumper/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/versionify ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # frozen_string_literal: true
4
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
5
+ require 'git_version_bumper'
6
+
7
+ exit GitVersionBumper::CLI.start(ARGV)
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git_version_bumper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'git_version_bumper'
8
+ spec.version = GitVersionBumper::VERSION
9
+ spec.authors = ['Troy Rosenberg']
10
+ spec.email = ['tmr08c@gmail.com']
11
+ spec.summary = 'CLI tool to create version bump commit and tag with
12
+ newest version in a Git repository.'
13
+ spec.description = 'CLI tool to create version bump commit and tag with
14
+ newest version in a Git repository. Versioning is
15
+ based on [Semantic Versioning](http://semver.org/).
16
+ Version bump types include MAJOR, MINOR, and PATCH.
17
+ Once installed gem can be used in a Git repository by
18
+ running `versionify bump TYPE` '
19
+ spec.homepage = 'https://github.com/tmr08c/git_version_bumper/'
20
+ spec.license = 'MIT'
21
+
22
+ spec.files = `git ls-files -z`.split("\x0")
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_runtime_dependency 'git', '~> 1.2'
28
+ spec.add_runtime_dependency 'thor', '~> 0.19'
29
+
30
+ spec.add_development_dependency 'bundler', '~> 1.6'
31
+ spec.add_development_dependency 'rake'
32
+ spec.add_development_dependency 'rspec'
33
+ spec.add_development_dependency 'rubocop', '~> 0.36'
34
+ end
@@ -0,0 +1,55 @@
1
+ require 'thor'
2
+
3
+ module GitVersionBumper
4
+ # Handles logic associated with command line interface.
5
+ # Uses Thor to make interaction more pleasant.
6
+ class CLI < Thor
7
+ SUCCESS_EXIT_STATUS = 0
8
+ ERROR_EXIT_STATUS = 1
9
+
10
+ # Version number naming shema based on Semantic Versioning
11
+ # See http://semver.org/ for more details
12
+ MAJOR_VERSION_TYPE = 'MAJOR'.freeze
13
+ MINOR_VERSION_TYPE = 'MINOR'.freeze
14
+ PATCH_VERSION_TYPE = 'PATCH'.freeze
15
+ VALID_BUMP_TYPES = [
16
+ MAJOR_VERSION_TYPE,
17
+ MINOR_VERSION_TYPE,
18
+ PATCH_VERSION_TYPE
19
+ ].freeze
20
+
21
+ desc(
22
+ 'bump TYPE',
23
+ 'Bump the version of you application.' \
24
+ 'Where TYPE can be MAJOR, MINOR, or PATC'
25
+ )
26
+ def bump(version_type)
27
+ bumper = bumper_for(version_type)
28
+ bumper.bump
29
+ # add logic to check for accepted versions here
30
+ SUCCESS_EXIT_STATUS
31
+ rescue Errors::NotRepositoryError
32
+ $stderr.puts 'Error: Directory is not a repository'
33
+ ERROR_EXIT_STATUS
34
+ rescue Errors::InvalidVersionBumpType
35
+ $stderr.puts 'Error: Invalid TYPE for version bump.' \
36
+ " TYPE must be one of #{VALID_BUMP_TYPES.join(', ')}"
37
+ ERROR_EXIT_STATUS
38
+ end
39
+
40
+ private
41
+
42
+ def bumper_for(version_type)
43
+ case version_type.upcase
44
+ when MAJOR_VERSION_TYPE
45
+ GitVersionBumper::VersionBumper::MajorVersionBumper.new(FileUtils.pwd)
46
+ when MINOR_VERSION_TYPE
47
+ GitVersionBumper::VersionBumper::MinorVersionBumper.new(FileUtils.pwd)
48
+ when PATCH_VERSION_TYPE
49
+ GitVersionBumper::VersionBumper::PatchVersionBumper.new(FileUtils.pwd)
50
+ else
51
+ fail Errors::InvalidVersionBumpType
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,23 @@
1
+ module GitVersionBumper
2
+ # Base error class
3
+ # GitVersionBumper-specific exceptions should inherit from this class
4
+ class Error < StandardError; end
5
+
6
+ module Errors
7
+ # This error should be raised when attempting to use
8
+ # GitVersionBumper with a directory that is not a Git repository
9
+ class NotRepositoryError < GitVersionBumper::Error; end
10
+
11
+ # This error should be raised when attempting to use GitVersionBumper
12
+ # to bump a non-standard vesion type
13
+ #
14
+ # The currently allowed types are
15
+ #
16
+ # * MAJOR
17
+ # * MINOR
18
+ # * PATCH
19
+ #
20
+ # and are pulled from http://semver.org/
21
+ class InvalidVersionBumpType < GitVersionBumper::Error; end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module GitVersionBumper
2
+ VERSION = '1.0.0'.freeze
3
+ end
@@ -0,0 +1,64 @@
1
+ require 'git_version_bumper'
2
+ require 'git_version_bumper/version_bumper/null_tag'
3
+ require 'git'
4
+
5
+ module GitVersionBumper
6
+ module VersionBumper
7
+ # Parent class used for housing logic on how to handle increasing version
8
+ # number. This includes creating and tagging a version bump commit.
9
+ #
10
+ # This should be inheirted from to implement the logic for creating the
11
+ # `tag` associated with the new version.
12
+ class Bumper
13
+ VERSION_BUMP_COMMIT_MESSAGE = 'Version Bump.'.freeze
14
+
15
+ def initialize(path)
16
+ @git = git_object(path)
17
+ end
18
+
19
+ def bump
20
+ commit
21
+ tag
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :git
27
+
28
+ def commit
29
+ git.commit(VERSION_BUMP_COMMIT_MESSAGE, allow_empty: true)
30
+ end
31
+
32
+ def tag
33
+ fail NotImplementedError
34
+ end
35
+
36
+ def current_version
37
+ @current_version ||= current_tag.name.sub('v', '')
38
+ end
39
+
40
+ def current_tag
41
+ @current_tag ||=
42
+ git.tags.last || VersionBumper::NullTag.new
43
+ end
44
+
45
+ def current_major_version
46
+ @current_major_version ||= Integer(current_version.split('.').first)
47
+ end
48
+
49
+ def current_minor_version
50
+ @current_minor_version ||= Integer(current_version.split('.')[1])
51
+ end
52
+
53
+ def current_patch_version
54
+ @current_patch_version ||= Integer(current_version.split('.').last)
55
+ end
56
+
57
+ def git_object(path)
58
+ Git.open(path)
59
+ rescue ArgumentError
60
+ raise Errors::NotRepositoryError
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,14 @@
1
+ require 'git_version_bumper/version_bumper/bumper'
2
+
3
+ module GitVersionBumper
4
+ module VersionBumper
5
+ # Implementation of Bumper that increases the major version number.
6
+ class MajorVersionBumper < Bumper
7
+ private
8
+
9
+ def tag
10
+ git.add_tag("v#{current_major_version + 1}.0.0")
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require 'git_version_bumper/version_bumper/bumper'
2
+
3
+ module GitVersionBumper
4
+ module VersionBumper
5
+ # Implementation of Bumper that increases the minor version number.
6
+ class MinorVersionBumper < Bumper
7
+ private
8
+
9
+ def tag
10
+ git.add_tag("v#{current_major_version}.#{current_minor_version + 1}.0")
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module GitVersionBumper
2
+ module VersionBumper
3
+ # Null Object represenation of Git::Object::Tag
4
+ class NullTag
5
+ def initialize; end
6
+
7
+ def name
8
+ 'v0.0.0'.freeze
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ require 'git_version_bumper/version_bumper/bumper'
2
+
3
+ module GitVersionBumper
4
+ module VersionBumper
5
+ # Implementation of Bumper that increases the patch version number.
6
+ class PatchVersionBumper < Bumper
7
+ private
8
+
9
+ def tag
10
+ git.add_tag(
11
+ "v#{current_major_version}." \
12
+ "#{current_minor_version}." \
13
+ "#{current_patch_version + 1}"
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ require 'git_version_bumper/version'
2
+ require 'git_version_bumper/errors'
3
+ require 'git_version_bumper/cli'
4
+ require 'git_version_bumper/version_bumper/major_version_bumper'
5
+ require 'git_version_bumper/version_bumper/minor_version_bumper'
6
+ require 'git_version_bumper/version_bumper/patch_version_bumper'
7
+
8
+ # Module to namespace logic that is a part of the GitVersionBumper gem
9
+ module GitVersionBumper
10
+ end
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,132 @@
1
+ require 'git_version_bumper'
2
+ require 'spec_helper'
3
+
4
+ describe GitVersionBumper::CLI do
5
+ describe '#bump' do
6
+ context 'when a type is not given' do
7
+ subject { described_class.new }
8
+
9
+ it 'should error' do
10
+ expect { subject.bump }.to raise_error(ArgumentError)
11
+ end
12
+ end
13
+
14
+ context 'when a type is given' do
15
+ context 'when the type is not a valid type' do
16
+ it 'should return an error exit status' do
17
+ expect(subject.bump('foo')).to eq 1
18
+ end
19
+
20
+ it 'should print the valid options' do
21
+ expect { subject.bump('foo') }.to output(/MAJOR/).to_stderr
22
+ expect { subject.bump('foo') }.to output(/MINOR/).to_stderr
23
+ expect { subject.bump('foo') }.to output(/PATCH/).to_stderr
24
+ end
25
+ end
26
+
27
+ context 'when the type is valid' do
28
+ context 'when the type is PATCH' do
29
+ let(:type) { 'PATCH' }
30
+ let(:bumper) do
31
+ instance_double(
32
+ GitVersionBumper::VersionBumper::PatchVersionBumper,
33
+ bump: true
34
+ )
35
+ end
36
+
37
+ it 'should use a PatchVersionBumper' do
38
+ expect(GitVersionBumper::VersionBumper::PatchVersionBumper)
39
+ .to receive(:new)
40
+ .with(FileUtils.pwd)
41
+ .and_return(bumper)
42
+ expect(bumper).to receive(:bump)
43
+
44
+ subject.bump(type)
45
+ end
46
+ end
47
+
48
+ context 'when the type is MINOR' do
49
+ let(:type) { 'MINOR' }
50
+ let(:bumper) do
51
+ instance_double(
52
+ GitVersionBumper::VersionBumper::MinorVersionBumper,
53
+ bump: true
54
+ )
55
+ end
56
+
57
+ it 'should use a MinorVersionBumper' do
58
+ expect(GitVersionBumper::VersionBumper::MinorVersionBumper)
59
+ .to receive(:new)
60
+ .with(FileUtils.pwd)
61
+ .and_return(bumper)
62
+ expect(bumper).to receive(:bump)
63
+
64
+ subject.bump(type)
65
+ end
66
+ end
67
+
68
+ context 'when the type is MAJOR' do
69
+ let(:type) { 'MAJOR' }
70
+ let(:bumper) do
71
+ instance_double(
72
+ GitVersionBumper::VersionBumper::MajorVersionBumper,
73
+ bump: true
74
+ )
75
+ end
76
+
77
+ it 'should user a MajorVersionBumper' do
78
+ expect(GitVersionBumper::VersionBumper::MajorVersionBumper)
79
+ .to receive(:new)
80
+ .with(FileUtils.pwd)
81
+ .and_return(bumper)
82
+ expect(bumper).to receive(:bump)
83
+
84
+ subject.bump(type)
85
+ end
86
+ end
87
+
88
+ context 'when the type is MINOR' do
89
+ end
90
+
91
+ context 'when the type is PATCH' do
92
+ end
93
+ end
94
+ end
95
+
96
+ context "when the directory isn't a repositroy" do
97
+ subject { described_class.new }
98
+
99
+ before do
100
+ FileUtils.chdir('/tmp')
101
+ end
102
+
103
+ it 'should return an error exit status' do
104
+ expect(subject.bump('MAJOR')).to eq 1
105
+ end
106
+
107
+ it 'give an error message' do
108
+ expect { subject.bump('MAJOR') }.to output(/repository/).to_stderr
109
+ end
110
+
111
+ after do
112
+ FileUtils.chdir(File.realpath("#{__FILE__}/.."))
113
+ end
114
+ end
115
+
116
+ context 'when the directory is a repository' do
117
+ subject { described_class.new }
118
+ let(:bumper) { double('bumper', bump: true) }
119
+
120
+ it 'should return a successful exit status' do
121
+ with_repo do
122
+ expect(subject)
123
+ .to receive(:bumper_for)
124
+ .with('MAJOR')
125
+ .and_return(bumper)
126
+
127
+ expect(subject.bump('MAJOR')).to eq 0
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,125 @@
1
+ # Based on Rubocop
2
+ # https://github.com/bbatsov/rubocop/blob/master/spec/support/coverage.rb
3
+ if ENV['TRAVIS']
4
+ require 'codeclimate-test-reporter'
5
+ CodeClimate::TestReporter.start
6
+ end
7
+
8
+ # This file was generated by the `rspec --init` command. Conventionally, all
9
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
10
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
11
+ # this file to always be loaded, without a need to explicitly require it in any
12
+ # files.
13
+ #
14
+ # Given that it is always loaded, you are encouraged to keep this file as
15
+ # light-weight as possible. Requiring heavyweight dependencies from this file
16
+ # will add to the boot time of your test suite on EVERY test run, even for an
17
+ # individual file that may not need all of that loaded. Instead, consider making
18
+ # a separate helper file that requires the additional dependencies and performs
19
+ # the additional setup, and require it from the spec files that actually need
20
+ # it.
21
+ #
22
+ # The `.rspec` file also contains a few flags that are not defaults but that
23
+ # users commonly want.
24
+ #
25
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
26
+ RSpec.configure do |config|
27
+ # rspec-expectations config goes here. You can use an alternate
28
+ # assertion/expectation library such as wrong or the stdlib/minitest
29
+ # assertions if you prefer.
30
+ config.expect_with :rspec do |expectations|
31
+ # This option will default to `true` in RSpec 4. It makes the `description`
32
+ # and `failure_message` of custom matchers include text for helper methods
33
+ # defined using `chain`, e.g.:
34
+ # be_bigger_than(2).and_smaller_than(4).description
35
+ # # => "be bigger than 2 and smaller than 4"
36
+ # ...rather than:
37
+ # # => "be bigger than 2"
38
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
39
+ end
40
+
41
+ # rspec-mocks config goes here. You can use an alternate test double
42
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
43
+ config.mock_with :rspec do |mocks|
44
+ # Prevents you from mocking or stubbing a method that does not exist on
45
+ # a real object. This is generally recommended, and will default to
46
+ # `true` in RSpec 4.
47
+ mocks.verify_partial_doubles = true
48
+ end
49
+
50
+ # The settings below are suggested to provide a good initial experience
51
+ # with RSpec, but feel free to customize to your heart's content.
52
+
53
+ # rubocop:disable Style/BlockComments
54
+
55
+ =begin
56
+ # These two settings work together to allow you to limit a spec run
57
+ # to individual examples or groups you care about by tagging them with
58
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
59
+ # get run.
60
+ config.filter_run :focus
61
+ config.run_all_when_everything_filtered = true
62
+
63
+ # Allows RSpec to persist some state between runs in order to support
64
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
65
+ # you configure your source control system to ignore this file.
66
+ config.example_status_persistence_file_path = "spec/examples.txt"
67
+
68
+ # Limits the available syntax to the non-monkey patched syntax that is
69
+ # recommended. For more details, see:
70
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
71
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
72
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
73
+ config.disable_monkey_patching!
74
+
75
+ # This setting enables warnings. It's recommended, but in some cases may
76
+ # be too noisy due to issues in dependencies.
77
+ config.warnings = true
78
+
79
+ # Many RSpec users commonly either run the entire suite or an individual
80
+ # file, and it's useful to allow more verbose output when running an
81
+ # individual spec file.
82
+ if config.files_to_run.one?
83
+ # Use the documentation formatter for detailed output,
84
+ # unless a formatter has already been configured
85
+ # (e.g. via a command-line flag).
86
+ config.default_formatter = 'doc'
87
+ end
88
+
89
+ # Print the 10 slowest examples and example groups at the
90
+ # end of the spec run, to help surface which specs are running
91
+ # particularly slow.
92
+ config.profile_examples = 10
93
+
94
+ # Run specs in random order to surface order dependencies. If you find an
95
+ # order dependency and want to debug it, you can fix the order by providing
96
+ # the seed, which is printed after each run.
97
+ # --seed 1234
98
+ config.order = :random
99
+
100
+ # Seed global randomization in this process using the `--seed` CLI option.
101
+ # Setting this allows you to use `--seed` to deterministically reproduce
102
+ # test failures related to randomization by passing the same `--seed` value
103
+ # as the one that triggered the failure.
104
+ Kernel.srand config.seed
105
+ =end
106
+
107
+ # rubocop:enable Style/BlockComments
108
+
109
+ def with_repo(path = 'tmp/testRepo')
110
+ FileUtils.mkdir_p(path)
111
+ FileUtils.chdir(path)
112
+
113
+ # Make directory a repository
114
+ `git init`
115
+
116
+ # Set up config for repository
117
+ `git config user.name "GitVersionBumper"`
118
+ `git config user.email "gitversionbumper@example.com"`
119
+
120
+ yield
121
+ ensure
122
+ FileUtils.rm_rf(path)
123
+ FileUtils.chdir(File.realpath("#{__FILE__}/../../"))
124
+ end
125
+ end
@@ -0,0 +1,25 @@
1
+ require 'git_version_bumper'
2
+ require 'git_version_bumper/version_bumper/bumper'
3
+
4
+ describe GitVersionBumper::VersionBumper::Bumper do
5
+ describe '.new' do
6
+ context 'when the path given is not a repo' do
7
+ it 'should raise an exception' do
8
+ expect { described_class.new('') }
9
+ .to raise_error(GitVersionBumper::Errors::NotRepositoryError)
10
+ end
11
+ end
12
+ end
13
+
14
+ describe '#bump' do
15
+ let(:repo_path) { '/tmp/repo' }
16
+
17
+ subject { described_class.new(repo_path) }
18
+
19
+ it 'should have to be implemented in a child class' do
20
+ with_repo(repo_path) do
21
+ expect { subject.bump }.to raise_error(NotImplementedError)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,61 @@
1
+ require 'git_version_bumper/version_bumper/major_version_bumper'
2
+ require 'spec_helper'
3
+
4
+ describe GitVersionBumper::VersionBumper::MajorVersionBumper do
5
+ describe '.bump' do
6
+ describe 'commit message' do
7
+ let(:repo_path) { '/tmp/repo' }
8
+
9
+ subject { described_class.new(repo_path) }
10
+
11
+ it 'should create a "Version Bump" commit' do
12
+ with_repo(repo_path) do
13
+ commit_list = `git log`
14
+ expect(commit_list).to be_empty
15
+
16
+ subject.bump
17
+
18
+ commit_list = `git log`
19
+ expect(commit_list).to match(/Version Bump/)
20
+ end
21
+ end
22
+ end
23
+
24
+ context 'when there are no existing tags' do
25
+ let(:repo_path) { '/tmp/noTagRepo' }
26
+
27
+ subject { described_class.new(repo_path) }
28
+
29
+ it 'should create a v1.0.0 tag' do
30
+ with_repo(repo_path) do
31
+ tag_list = `git tag -l`
32
+ expect(tag_list).to be_empty
33
+
34
+ subject.bump
35
+
36
+ tag_list = `git tag -l`
37
+ expect(tag_list).to match(/v1.0.0/)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ context 'when there are existing tags' do
44
+ let(:repo_path) { '/tmp/tagRepo' }
45
+
46
+ subject { described_class.new(repo_path) }
47
+
48
+ it 'update the version to the next major version' do
49
+ with_repo(repo_path) do
50
+ # create an existing tag in the repo
51
+ `git commit --allow-empty -m 'commit'`
52
+ `git tag 'v2.3.4'`
53
+
54
+ subject.bump
55
+
56
+ tag_list = `git tag -l`
57
+ expect(tag_list).to match(/v3.0.0/)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'git_version_bumper/version_bumper/minor_version_bumper'
3
+
4
+ describe GitVersionBumper::VersionBumper::MinorVersionBumper do
5
+ describe '#bump' do
6
+ describe 'commit message' do
7
+ let(:repo_path) { '/tmp/repo' }
8
+
9
+ subject { described_class.new(repo_path) }
10
+
11
+ it 'should create a "Version Bump" commit' do
12
+ with_repo(repo_path) do
13
+ commit_list = `git log`
14
+ expect(commit_list).to be_empty
15
+
16
+ subject.bump
17
+
18
+ commit_list = `git log`
19
+ expect(commit_list).to match(/Version Bump/)
20
+ end
21
+ end
22
+ end
23
+
24
+ context 'when there are no existing tags' do
25
+ let(:repo_path) { '/tmp/noTagRepo' }
26
+
27
+ subject { described_class.new(repo_path) }
28
+
29
+ it 'should create a v0.1.0 tag' do
30
+ with_repo(repo_path) do
31
+ tag_list = `git tag -l`
32
+ expect(tag_list).to be_empty
33
+
34
+ subject.bump
35
+
36
+ tag_list = `git tag -l`
37
+ expect(tag_list).to match(/v0.1.0/)
38
+ end
39
+ end
40
+
41
+ context 'when there are existing tags' do
42
+ let(:repo_path) { '/tmp/taggedRepo' }
43
+
44
+ subject { described_class.new(repo_path) }
45
+
46
+ it 'should increase the minor version tag' do
47
+ with_repo(repo_path) do
48
+ `git commit --allow-empty -m 'commit'`
49
+ `git tag 'v1.2.3'`
50
+
51
+ subject.bump
52
+
53
+ tag_list = `git tag -l`
54
+ expect(tag_list).to match(/v1.3.0/)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ require 'git_version_bumper/version_bumper/null_tag'
3
+
4
+ describe GitVersionBumper::VersionBumper::NullTag do
5
+ describe '#name' do
6
+ subject { described_class.new }
7
+
8
+ it 'return version 0' do
9
+ expect(subject.name).to eq 'v0.0.0'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'git_version_bumper/version_bumper/patch_version_bumper'
3
+
4
+ describe GitVersionBumper::VersionBumper::PatchVersionBumper do
5
+ describe '#bump' do
6
+ describe 'commit message' do
7
+ let(:repo_path) { '/tmp/repo' }
8
+
9
+ subject { described_class.new(repo_path) }
10
+
11
+ it 'should create a "Version Bump" commit' do
12
+ with_repo(repo_path) do
13
+ commit_list = `git log`
14
+ expect(commit_list).to be_empty
15
+
16
+ subject.bump
17
+
18
+ commit_list = `git log`
19
+ expect(commit_list).to match(/Version Bump/)
20
+ end
21
+ end
22
+ end
23
+
24
+ context 'when there are no existing tags' do
25
+ let(:repo_path) { '/tmp/noTagRepo' }
26
+
27
+ subject { described_class.new(repo_path) }
28
+
29
+ it 'should create a v0.0.1 tag' do
30
+ with_repo(repo_path) do
31
+ tag_list = `git tag -l`
32
+ expect(tag_list).to be_empty
33
+
34
+ subject.bump
35
+
36
+ tag_list = `git tag -l`
37
+ expect(tag_list).to match(/v0.0.1/)
38
+ end
39
+ end
40
+
41
+ context 'when there are existing tags' do
42
+ let(:repo_path) { '/tmp/taggedRepo' }
43
+
44
+ subject { described_class.new(repo_path) }
45
+
46
+ it 'should increase the patch number in the next tag' do
47
+ with_repo(repo_path) do
48
+ `git commit --allow-empty -m 'commit'`
49
+ `git tag 'v2.6.8'`
50
+
51
+ subject.bump
52
+
53
+ tag_list = `git tag -l`
54
+ expect(tag_list).to match(/v2.6.9/)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_version_bumper
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Troy Rosenberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: git
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.19'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.19'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.36'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.36'
97
+ description: "CLI tool to create version bump commit and tag with\n newest
98
+ version in a Git repository. Versioning is\n based on [Semantic
99
+ Versioning](http://semver.org/).\n Version bump types include
100
+ MAJOR, MINOR, and PATCH.\n Once installed gem can be used
101
+ in a Git repository by\n running `versionify bump TYPE` "
102
+ email:
103
+ - tmr08c@gmail.com
104
+ executables:
105
+ - versionify
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - ".travis.yml"
112
+ - Gemfile
113
+ - LICENSE.txt
114
+ - README.md
115
+ - Rakefile
116
+ - bin/versionify
117
+ - git_version_bumper.gemspec
118
+ - lib/git_version_bumper.rb
119
+ - lib/git_version_bumper/cli.rb
120
+ - lib/git_version_bumper/errors.rb
121
+ - lib/git_version_bumper/version.rb
122
+ - lib/git_version_bumper/version_bumper/bumper.rb
123
+ - lib/git_version_bumper/version_bumper/major_version_bumper.rb
124
+ - lib/git_version_bumper/version_bumper/minor_version_bumper.rb
125
+ - lib/git_version_bumper/version_bumper/null_tag.rb
126
+ - lib/git_version_bumper/version_bumper/patch_version_bumper.rb
127
+ - spec/cli_spec.rb
128
+ - spec/spec_helper.rb
129
+ - spec/version_bumper/bumper_spec.rb
130
+ - spec/version_bumper/major_version_bumper_spec.rb
131
+ - spec/version_bumper/minor_version_bumper_spec.rb
132
+ - spec/version_bumper/null_tag_spec.rb
133
+ - spec/version_bumper/patch_version_bumper_spec.rb
134
+ homepage: https://github.com/tmr08c/git_version_bumper/
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.2.2
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: CLI tool to create version bump commit and tag with newest version in a Git
158
+ repository.
159
+ test_files:
160
+ - spec/cli_spec.rb
161
+ - spec/spec_helper.rb
162
+ - spec/version_bumper/bumper_spec.rb
163
+ - spec/version_bumper/major_version_bumper_spec.rb
164
+ - spec/version_bumper/minor_version_bumper_spec.rb
165
+ - spec/version_bumper/null_tag_spec.rb
166
+ - spec/version_bumper/patch_version_bumper_spec.rb
167
+ has_rdoc: