rake-gitversion 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c891f94d6d42dcb61c6921f1784d387471ddcc04
4
+ data.tar.gz: bd21fbe61ed0ac8236655e65c11b2cc997877631
5
+ SHA512:
6
+ metadata.gz: 3c0ae4714202b7f898ec276d8e7b537d88e07bab851af4295f04cd9674495b25246a8f1829c55188530dcf30e5fd3f7437d79731401928731a008474d19f81a5
7
+ data.tar.gz: 3265071b9f233af6aeca348e3a7bb9966ffea26036699e10ce836e6e5984fcec50b1c50ba453c3f1637a0a4171b403533fb24bdc7c3914e7e024d9d5f48bbd77
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ VERSION
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.7
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rake-gitversion.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Stephan Klatt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Rake::Gitversion
2
+
3
+ This gem adds a task 'set_version' to rake, which uses annotated tags and the
4
+ 'git describe' command to get a version string and save it to a VERSION file.
5
+ The patch number of the version string is the number of commits since the last
6
+ version tag.
7
+ If the git tree is dirty, minor is increased and the version marked as
8
+ prerelease by adding '.dev'.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'rake-gitversion'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install rake-gitversion
25
+
26
+ ## Usage
27
+
28
+ In your Rakefile:
29
+
30
+ ```ruby
31
+ require 'rake/gitversion'
32
+ ```
33
+
34
+ Add an annotated version tag:
35
+
36
+ ```git tag -a -m 'minor' v0.1```
37
+
38
+ Run rake set_version
39
+
40
+
41
+ In your version.rb, use:
42
+
43
+ ```ruby
44
+ # Version of gem and module
45
+ VERSION = begin
46
+ File.read('VERSION')
47
+ rescue
48
+ '0.pre'
49
+ end.freeze
50
+ ```
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bundle install` to install dependencies.
55
+ Then, run `rake test` to run the tests.
56
+
57
+ To install this gem onto your local machine, run `bundle exec rake install`.
58
+ To release a new version, update the version number in `version.rb`, and then
59
+ run `bundle exec rake release`, which will create a git tag for the version,
60
+ push git commits and tags, and push the `.gem` file to
61
+ [rubygems.org](https://rubygems.org).
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at
66
+ https://github.com/skladd/rake-gitversion.
67
+
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the
72
+ [MIT License](http://opensource.org/licenses/MIT).
73
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,51 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'rake/gitversion/version'
4
+ require 'bundler'
5
+
6
+ module Rake
7
+ module Gitversion
8
+ extend Rake::DSL if defined? Rake::DSL
9
+
10
+ # Path to VERSION file
11
+ VERSION_FILE_PATH = 'VERSION'.freeze # Todo: ensure correct directory
12
+
13
+ # Get version from git via 'git describe'.
14
+ # Requires annotated git tags in format 'v<MAJOR>.<MINOR>' like 'v4.11'
15
+ # @param git_desc [String] output from 'git describe --long --dirty=-dirty'
16
+ def self.version_from_git(git_desc = nil)
17
+ if git_desc.nil?
18
+ git_desc = `git describe --long --dirty=-dirty`
19
+ if git_desc.empty?
20
+ raise("ERROR: git describe failed. Make sure you are in git and" +
21
+ " there are annotated version tags like v0.1.")
22
+ end
23
+ end
24
+ match = git_desc.match(/v(\d+)\.(\d+)-(\d+)-\w+(-dirty)?/)
25
+ raise "'#{git_desc}' has invalid format" unless match
26
+ patchlevel = match[4] ? "#{match[3].to_i + 1}.dev" : match[3]
27
+ "#{match[1]}.#{match[2]}.#{patchlevel}"
28
+ end
29
+
30
+ # Create Rake task 'set_version' which writes generated
31
+ # version string to VERSION file.
32
+ def self.install_rake_tasks
33
+ desc('Get version from git and save to VERSION file')
34
+ task(:set_version) do
35
+ version = version_from_git
36
+ path = VERSION_FILE_PATH
37
+
38
+ begin
39
+ File.open(path, 'w') do |file|
40
+ file.write(version)
41
+ end
42
+ rescue StandardError => error
43
+ pp error
44
+ raise("File #{path} unwritable.")
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ ::Rake::Gitversion.install_rake_tasks
@@ -0,0 +1,5 @@
1
+ module Rake
2
+ module Gitversion
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rake/gitversion/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'rake-gitversion'
8
+ spec.version = Rake::Gitversion::VERSION
9
+ spec.authors = ['Stephan Klatt']
10
+ spec.email = ['stephan.klatt@gmail.com']
11
+
12
+ spec.summary = 'Get version from git and write it to file'
13
+ spec.description = 'Get version from git tags and commits since then and'
14
+ ' write it to VERSION file'
15
+ spec.homepage = 'https://github.com/skladd/rake-gitversion'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.10'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'minitest', '~> 5.9'
26
+ spec.add_development_dependency 'minitest-reporters', '~> 1.1'
27
+ spec.add_development_dependency 'mocha', '~> 1.1'
28
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake-gitversion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephan Klatt
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-reporters
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.1'
83
+ description: Get version from git tags and commits since then and
84
+ email:
85
+ - stephan.klatt@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/rake/gitversion.rb
97
+ - lib/rake/gitversion/version.rb
98
+ - rake-gitversion.gemspec
99
+ homepage: https://github.com/skladd/rake-gitversion
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.4.8
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Get version from git and write it to file
123
+ test_files: []