auto_tag_version 1.0.0 → 1.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/auto_tag_version/utils.rb +14 -2
- data/lib/auto_tag_version/version.rb +1 -1
- data/lib/tasks/autotag.rake +5 -2
- data/spec/lib/auto_tag_version/utils_spec.rb +30 -7
- metadata +1 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e41f580e63a00ffd61c7d7b340f015f5a6d84241
|
4
|
+
data.tar.gz: 6bebe7e6d370d207877dc15dffd14de581ff67fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 156d514ebad28258cd565abd14bf1e049fcc4dd7635b8d36a42114d9be28163d67e7d873b3a01b91655ceeb6561fbf7ac4b6126eb2db356540bfc1f8e1681f38
|
7
|
+
data.tar.gz: ecaf8601a425649e0d390eabe497be6592ff8232926c59623b867eb0f9fce65ccdadc4a235d7940d5a4e2c7bf7c9a8175b2e00d1e7fed93ab0a7582424ee1f1e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -6,12 +6,20 @@ module AutoTagVersion
|
|
6
6
|
commit_and_create_tag
|
7
7
|
end
|
8
8
|
|
9
|
+
def print_last_tag_information
|
10
|
+
if last_git_tag == tag
|
11
|
+
puts "Everything OK! Last git tag created: #{last_git_tag}"
|
12
|
+
else
|
13
|
+
puts "Something goes wrong with the tag creation. Check your git log."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
private
|
10
18
|
attr_reader :tag
|
11
19
|
|
12
20
|
def content
|
13
|
-
content = "module #{app}; VERSION = '#{tag}'; end\n"
|
14
|
-
content += "# This file
|
21
|
+
content = "module #{app}; VERSION = '#{tag}'; end\n\n"
|
22
|
+
content += "# This file was created automatically by auto_tag_version gem\n"
|
15
23
|
content += "# Documentation at https://github.com/rafaelbiriba/auto_tag_version"
|
16
24
|
end
|
17
25
|
|
@@ -30,5 +38,9 @@ module AutoTagVersion
|
|
30
38
|
def commit_and_create_tag
|
31
39
|
`git add #{version_file} && git commit -m "Bumping version #{tag}" && git tag #{tag}`
|
32
40
|
end
|
41
|
+
|
42
|
+
def last_git_tag
|
43
|
+
`git describe --abbrev=0 --tags`.strip
|
44
|
+
end
|
33
45
|
end
|
34
46
|
end
|
data/lib/tasks/autotag.rake
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
desc "Create/Update the APP VERSION and create the git tag. USAGE: rake autotag TAG=0.0.0"
|
2
2
|
task :autotag do
|
3
|
+
tag = ENV["TAG"]
|
3
4
|
if !defined?(Rails)
|
4
5
|
puts "Rails app not found!"
|
5
|
-
elsif
|
6
|
+
elsif tag.blank?
|
6
7
|
puts "TAG not found! USAGE: rake autotag TAG=0.0.0"
|
7
8
|
else
|
8
|
-
|
9
|
+
puts "Creating #{tag} tag..."
|
10
|
+
AutoTagVersion.tag!(tag)
|
11
|
+
AutoTagVersion.print_last_tag_information
|
9
12
|
end
|
10
13
|
end
|
@@ -6,21 +6,28 @@ describe AutoTagVersion do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
module Rails; def self.application; end; end
|
9
|
-
module APP; end
|
9
|
+
module APP; end
|
10
10
|
|
11
|
-
let(:tag_version) { "
|
11
|
+
let(:tag_version) { "#{rand(9)}.#{rand(9)}.#{rand(9)}" }
|
12
12
|
let(:app) { APP }
|
13
|
-
let(:
|
13
|
+
let(:app_version_file) { "config/initializers/app_version.rb" }
|
14
|
+
let(:git_add_cmd) { "git add #{app_version_file} && git commit -m \"Bumping version #{tag_version}\" && git tag #{tag_version}" }
|
15
|
+
|
14
16
|
|
15
17
|
before do
|
16
18
|
allow(Rails).to receive_message_chain("application.class.parent_name").and_return(app.to_s)
|
19
|
+
allow(subject).to receive(:`).with(git_add_cmd)
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
FileUtils.rm(app_version_file) if File.exist?(app_version_file)
|
17
24
|
end
|
18
25
|
|
19
26
|
describe ".tag!" do
|
20
27
|
context "VERSION variable available" do
|
21
28
|
before do
|
22
29
|
subject.tag!(tag_version)
|
23
|
-
load(
|
30
|
+
load(app_version_file)
|
24
31
|
end
|
25
32
|
|
26
33
|
it "should save the correct tag version" do
|
@@ -29,12 +36,28 @@ describe AutoTagVersion do
|
|
29
36
|
end
|
30
37
|
|
31
38
|
context "git integration" do
|
32
|
-
let(:git_msg) { "git add #{app_version_path} && git commit -m \"Bumping version #{tag_version}\" && git tag #{tag_version}" }
|
33
|
-
|
34
39
|
it "should run the correct git command" do
|
35
|
-
expect(subject).to receive(:`).with(
|
40
|
+
expect(subject).to receive(:`).with(git_add_cmd)
|
36
41
|
subject.tag!(tag_version)
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
45
|
+
|
46
|
+
describe ".print_last_tag_information" do
|
47
|
+
let(:git_tags_cmd) { "git describe --abbrev=0 --tags" }
|
48
|
+
|
49
|
+
before do
|
50
|
+
allow(subject).to receive(:`).with(git_tags_cmd).and_return(tag_version)
|
51
|
+
subject.tag!(tag_version)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should print successful message" do
|
55
|
+
expect { subject.print_last_tag_information }.to output("Everything OK! Last git tag created: #{tag_version}\n").to_stdout
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should print successful message" do
|
59
|
+
allow(subject).to receive(:`).with(git_tags_cmd).and_return("test.0.1")
|
60
|
+
expect { subject.print_last_tag_information }.to output("Something goes wrong with the tag creation. Check your git log.\n").to_stdout
|
61
|
+
end
|
62
|
+
end
|
40
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_tag_version
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Biriba
|
@@ -81,7 +81,6 @@ files:
|
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
83
|
- auto_tag_version.gemspec
|
84
|
-
- config/initializers/app_version.rb
|
85
84
|
- lib/auto_tag_version.rb
|
86
85
|
- lib/auto_tag_version/railtie.rb
|
87
86
|
- lib/auto_tag_version/utils.rb
|