git_version_bumper 1.0.1 → 1.0.2
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 +4 -4
- data/.travis.yml +17 -4
- data/README.md +2 -2
- data/lib/git_version_bumper/cli.rb +3 -3
- data/lib/git_version_bumper/version.rb +1 -1
- data/lib/git_version_bumper/version_bumper/bumper.rb +5 -10
- data/lib/git_version_bumper/version_bumper/tag.rb +50 -0
- data/spec/{cli_spec.rb → git_version_bumper/cli_spec.rb} +0 -0
- data/spec/{version_bumper → git_version_bumper/version_bumper}/bumper_spec.rb +0 -0
- data/spec/{version_bumper → git_version_bumper/version_bumper}/major_version_bumper_spec.rb +0 -0
- data/spec/{version_bumper → git_version_bumper/version_bumper}/minor_version_bumper_spec.rb +0 -0
- data/spec/{version_bumper → git_version_bumper/version_bumper}/patch_version_bumper_spec.rb +0 -0
- data/spec/git_version_bumper/version_bumper/tag_spec.rb +129 -0
- data/spec/spec_helper.rb +3 -3
- metadata +16 -17
- data/lib/git_version_bumper/version_bumper/null_tag.rb +0 -12
- data/spec/version_bumper/null_tag_spec.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 059b9f2b4333be286ce491c7834d60cba29e839a
|
4
|
+
data.tar.gz: de0b99447a776e61712e5b969503a5d771f79858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7726edb6070885b8bac2df462aa8981ae392ef88c7b8df974cd25c37766cd74b352972a4a29cfd6c4374925c8a83cc1aa179b8935073fdbfa5722874cf06d1d1
|
7
|
+
data.tar.gz: 1b82e0f7c9162615c86849b0f36806abbb6142a5e985f494989dd67424d1bd652981d14535a7e5ea856904b6c6e6400fbb9737a41dca7d79b5b8a405703e26c3
|
data/.travis.yml
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- CC_TEST_REPORTER_ID=d946fbe840359053ee5604eb18d4cd53c9da50bb2e6af66191385e49962be152
|
1
4
|
sudo: false
|
2
5
|
cache: bundler
|
3
6
|
language: ruby
|
@@ -6,10 +9,16 @@ rvm:
|
|
6
9
|
- 2.0.0
|
7
10
|
- 2.1
|
8
11
|
- 2.2
|
9
|
-
- 2.3
|
12
|
+
- 2.3
|
13
|
+
- 2.4.0
|
14
|
+
- 2.4.1
|
15
|
+
- 2.4.2
|
10
16
|
- ruby-head
|
11
17
|
- jruby-19mode
|
12
18
|
- jruby-9.0.1.0
|
19
|
+
- jruby-9.1.5.0
|
20
|
+
- jruby-9.1.9.0
|
21
|
+
- jruby-head
|
13
22
|
- rbx-3
|
14
23
|
env:
|
15
24
|
# this doesn't do anything for MRI or RBX, but it doesn't hurt them either
|
@@ -18,13 +27,17 @@ env:
|
|
18
27
|
matrix:
|
19
28
|
allow_failures:
|
20
29
|
- rvm: ruby-head
|
30
|
+
- rvm: jruby-head
|
21
31
|
- rvm: rbx-3
|
22
32
|
fast_finish: true
|
23
33
|
before_install: gem update --remote bundler
|
24
34
|
install:
|
25
35
|
- bundle install --retry=3
|
36
|
+
before_script:
|
37
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
38
|
+
- chmod +x ./cc-test-reporter
|
39
|
+
- ./cc-test-reporter before-build
|
26
40
|
script:
|
27
41
|
- bundle exec rspec
|
28
|
-
|
29
|
-
|
30
|
-
repo_token: d946fbe840359053ee5604eb18d4cd53c9da50bb2e6af66191385e49962be152
|
42
|
+
after_script:
|
43
|
+
- if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT; fi
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# GitVersionBumper
|
6
6
|
|
7
|
-
CLI tool to create version bump commit and tag
|
7
|
+
CLI 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
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
From within your Git repository you can run the gem using the `versionify
|
25
|
+
From within your Git repository you can run the gem using the `versionify bump` command, in combination with a valid version bump type.
|
26
26
|
|
27
27
|
```
|
28
28
|
versionify bump TYPE
|
@@ -42,11 +42,11 @@ module GitVersionBumper
|
|
42
42
|
def bumper_for(version_type)
|
43
43
|
case version_type.upcase
|
44
44
|
when MAJOR_VERSION_TYPE
|
45
|
-
|
45
|
+
VersionBumper::MajorVersionBumper.new(FileUtils.pwd)
|
46
46
|
when MINOR_VERSION_TYPE
|
47
|
-
|
47
|
+
VersionBumper::MinorVersionBumper.new(FileUtils.pwd)
|
48
48
|
when PATCH_VERSION_TYPE
|
49
|
-
|
49
|
+
VersionBumper::PatchVersionBumper.new(FileUtils.pwd)
|
50
50
|
else
|
51
51
|
fail Errors::InvalidVersionBumpType
|
52
52
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'git_version_bumper'
|
2
|
-
require 'git_version_bumper/version_bumper/
|
2
|
+
require 'git_version_bumper/version_bumper/tag'
|
3
3
|
require 'git'
|
4
4
|
|
5
5
|
module GitVersionBumper
|
@@ -33,25 +33,20 @@ module GitVersionBumper
|
|
33
33
|
fail NotImplementedError
|
34
34
|
end
|
35
35
|
|
36
|
-
def current_version
|
37
|
-
@current_version ||= current_tag.name.sub('v', '')
|
38
|
-
end
|
39
|
-
|
40
36
|
def current_tag
|
41
|
-
@current_tag ||=
|
42
|
-
git.tags.last || VersionBumper::NullTag.new
|
37
|
+
@current_tag ||= Tag.current(git)
|
43
38
|
end
|
44
39
|
|
45
40
|
def current_major_version
|
46
|
-
@current_major_version ||=
|
41
|
+
@current_major_version ||= current_tag.major
|
47
42
|
end
|
48
43
|
|
49
44
|
def current_minor_version
|
50
|
-
@current_minor_version ||=
|
45
|
+
@current_minor_version ||= current_tag.minor
|
51
46
|
end
|
52
47
|
|
53
48
|
def current_patch_version
|
54
|
-
@current_patch_version ||=
|
49
|
+
@current_patch_version ||= current_tag.patch
|
55
50
|
end
|
56
51
|
|
57
52
|
def git_object(path)
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module GitVersionBumper
|
2
|
+
module VersionBumper
|
3
|
+
# Local represenation of Git::Object::Tag
|
4
|
+
# Created to allow for custom sorting of git tags
|
5
|
+
class Tag
|
6
|
+
include Comparable
|
7
|
+
|
8
|
+
attr_reader :major, :minor, :patch
|
9
|
+
|
10
|
+
def initialize(major, minor, patch)
|
11
|
+
@major = Integer(major)
|
12
|
+
@minor = Integer(minor)
|
13
|
+
@patch = Integer(patch)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.current(git_object)
|
17
|
+
tags = git_object.tags
|
18
|
+
return Tag.new(0, 0, 0) if tags.empty?
|
19
|
+
|
20
|
+
tags
|
21
|
+
.map { |tag| Tag.from_name(tag.name) }
|
22
|
+
.sort
|
23
|
+
.last
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.from_name(tag_name)
|
27
|
+
tag_name = tag_name.sub('v', '')
|
28
|
+
major, minor, patch = tag_name.split('.')
|
29
|
+
|
30
|
+
Tag.new(major, minor, patch)
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
"v#{major}.#{minor}.#{patch}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def <=>(other)
|
38
|
+
if major == other.major
|
39
|
+
if minor == other.minor
|
40
|
+
patch <=> other.patch
|
41
|
+
else
|
42
|
+
minor <=> other.minor
|
43
|
+
end
|
44
|
+
else
|
45
|
+
major <=> other.major
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'git'
|
3
|
+
require 'git_version_bumper/version_bumper/tag'
|
4
|
+
|
5
|
+
describe GitVersionBumper::VersionBumper::Tag do
|
6
|
+
describe '.current' do
|
7
|
+
context 'when there are no tags' do
|
8
|
+
it 'start with version 0.0.0' do
|
9
|
+
with_repo do
|
10
|
+
git_object = Git.open('./')
|
11
|
+
current_tag = described_class.current(git_object)
|
12
|
+
|
13
|
+
expect(current_tag.to_s).to eq 'v0.0.0'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when there are tags' do
|
19
|
+
context 'when there is only one version tag' do
|
20
|
+
it 'returns the single version tag' do
|
21
|
+
with_repo do
|
22
|
+
tag('v1.0.0')
|
23
|
+
git_object = Git.open('./')
|
24
|
+
|
25
|
+
current_tag = described_class.current(git_object)
|
26
|
+
|
27
|
+
expect(current_tag.to_s).to eq 'v1.0.0'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when there are multiple version tags' do
|
33
|
+
it 'returns the highest version' do
|
34
|
+
with_repo do
|
35
|
+
tag('v0.0.9')
|
36
|
+
tag('v0.0.10')
|
37
|
+
tag('v0.0.11')
|
38
|
+
|
39
|
+
git_object = Git.open('./')
|
40
|
+
|
41
|
+
current_tag = described_class.current(git_object)
|
42
|
+
|
43
|
+
expect(current_tag.to_s).to eq 'v0.0.11'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.from_name' do
|
51
|
+
it 'can map a version string formatted like "vX.Y.Z"' do
|
52
|
+
tag = described_class.from_name('v1.2.3')
|
53
|
+
|
54
|
+
expect(tag.major).to eq(1)
|
55
|
+
expect(tag.minor).to eq(2)
|
56
|
+
expect(tag.patch).to eq(3)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#<=>' do
|
61
|
+
describe '#>' do
|
62
|
+
it 'compares major, minor, and patch' do
|
63
|
+
expect(described_class.new(2, 3, 4) > described_class.new(0, 0, 1))
|
64
|
+
.to be_truthy
|
65
|
+
expect(described_class.new(2, 3, 4) > described_class.new(0, 5, 6))
|
66
|
+
.to be_truthy
|
67
|
+
expect(described_class.new(2, 3, 4) > described_class.new(1, 2, 3))
|
68
|
+
.to be_truthy
|
69
|
+
|
70
|
+
expect(described_class.new(2, 3, 4) > described_class.new(2, 3, 5))
|
71
|
+
.to be_falsey
|
72
|
+
expect(described_class.new(2, 3, 4) > described_class.new(2, 4, 0))
|
73
|
+
.to be_falsey
|
74
|
+
expect(described_class.new(2, 3, 4) > described_class.new(3, 0, 0))
|
75
|
+
.to be_falsey
|
76
|
+
|
77
|
+
expect(described_class.new(2, 3, 4) > described_class.new(2, 3, 4))
|
78
|
+
.to be_falsey
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#<' do
|
83
|
+
it 'compares major, minor, and patch' do
|
84
|
+
expect(described_class.new(2, 3, 4) < described_class.new(2, 3, 5))
|
85
|
+
.to be_truthy
|
86
|
+
expect(described_class.new(2, 3, 4) < described_class.new(3, 0, 0))
|
87
|
+
.to be_truthy
|
88
|
+
expect(described_class.new(2, 3, 4) < described_class.new(2, 4, 0))
|
89
|
+
.to be_truthy
|
90
|
+
|
91
|
+
expect(described_class.new(2, 3, 4) < described_class.new(0, 0, 1))
|
92
|
+
.to be_falsey
|
93
|
+
expect(described_class.new(2, 3, 4) < described_class.new(0, 5, 6))
|
94
|
+
.to be_falsey
|
95
|
+
expect(described_class.new(2, 3, 4) < described_class.new(1, 2, 3))
|
96
|
+
.to be_falsey
|
97
|
+
|
98
|
+
expect(described_class.new(2, 3, 4) < described_class.new(2, 3, 4))
|
99
|
+
.to be_falsey
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#==' do
|
104
|
+
it 'compares major, minor, and patch' do
|
105
|
+
expect(described_class.new(2, 3, 4) == described_class.new(2, 3, 4))
|
106
|
+
.to be_truthy
|
107
|
+
|
108
|
+
expect(described_class.new(2, 3, 4) == described_class.new(2, 3, 5))
|
109
|
+
.to be_falsey
|
110
|
+
expect(described_class.new(2, 3, 4) == described_class.new(3, 0, 0))
|
111
|
+
.to be_falsey
|
112
|
+
expect(described_class.new(2, 3, 4) == described_class.new(2, 4, 0))
|
113
|
+
.to be_falsey
|
114
|
+
|
115
|
+
expect(described_class.new(2, 3, 4) == described_class.new(0, 0, 1))
|
116
|
+
.to be_falsey
|
117
|
+
expect(described_class.new(2, 3, 4) == described_class.new(0, 5, 6))
|
118
|
+
.to be_falsey
|
119
|
+
expect(described_class.new(2, 3, 4) == described_class.new(1, 2, 3))
|
120
|
+
.to be_falsey
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def tag(tag_name)
|
126
|
+
`git commit --message='test commit' --allow-empty`
|
127
|
+
`git tag -a #{tag_name} -m '#{tag_name}'`
|
128
|
+
end
|
129
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Based on Rubocop
|
2
2
|
# https://github.com/bbatsov/rubocop/blob/master/spec/support/coverage.rb
|
3
3
|
if ENV['TRAVIS']
|
4
|
-
require '
|
5
|
-
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start
|
6
6
|
end
|
7
7
|
|
8
8
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
@@ -119,7 +119,7 @@ RSpec.configure do |config|
|
|
119
119
|
|
120
120
|
yield
|
121
121
|
ensure
|
122
|
-
FileUtils.rm_rf(path)
|
123
122
|
FileUtils.chdir(File.realpath("#{__FILE__}/../../"))
|
123
|
+
FileUtils.rm_rf(path)
|
124
124
|
end
|
125
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_version_bumper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Troy Rosenberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -122,15 +122,15 @@ files:
|
|
122
122
|
- lib/git_version_bumper/version_bumper/bumper.rb
|
123
123
|
- lib/git_version_bumper/version_bumper/major_version_bumper.rb
|
124
124
|
- lib/git_version_bumper/version_bumper/minor_version_bumper.rb
|
125
|
-
- lib/git_version_bumper/version_bumper/null_tag.rb
|
126
125
|
- lib/git_version_bumper/version_bumper/patch_version_bumper.rb
|
127
|
-
-
|
126
|
+
- lib/git_version_bumper/version_bumper/tag.rb
|
127
|
+
- spec/git_version_bumper/cli_spec.rb
|
128
|
+
- spec/git_version_bumper/version_bumper/bumper_spec.rb
|
129
|
+
- spec/git_version_bumper/version_bumper/major_version_bumper_spec.rb
|
130
|
+
- spec/git_version_bumper/version_bumper/minor_version_bumper_spec.rb
|
131
|
+
- spec/git_version_bumper/version_bumper/patch_version_bumper_spec.rb
|
132
|
+
- spec/git_version_bumper/version_bumper/tag_spec.rb
|
128
133
|
- 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
134
|
homepage: https://github.com/tmr08c/git_version_bumper/
|
135
135
|
licenses:
|
136
136
|
- MIT
|
@@ -151,17 +151,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.5.1
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: CLI tool to create version bump commit and tag with newest version in a Git
|
158
158
|
repository.
|
159
159
|
test_files:
|
160
|
-
- spec/cli_spec.rb
|
160
|
+
- spec/git_version_bumper/cli_spec.rb
|
161
|
+
- spec/git_version_bumper/version_bumper/bumper_spec.rb
|
162
|
+
- spec/git_version_bumper/version_bumper/major_version_bumper_spec.rb
|
163
|
+
- spec/git_version_bumper/version_bumper/minor_version_bumper_spec.rb
|
164
|
+
- spec/git_version_bumper/version_bumper/patch_version_bumper_spec.rb
|
165
|
+
- spec/git_version_bumper/version_bumper/tag_spec.rb
|
161
166
|
- 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:
|
@@ -1,12 +0,0 @@
|
|
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
|