rake_roll 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b9cc9d2a1d41becbc6477d915718b4464d6a2ae
4
+ data.tar.gz: c374754ef6e5a2d86a4898072e8a64ac8285fbb0
5
+ SHA512:
6
+ metadata.gz: eb1f1f3572c31b4b5d779aa794ccbe3677beda5a220ad9b3fa820b81793d5e22e732fbb39f0dbacc6c4dabfb91171b668ce1b988bae712ad5046d4473a4a2fa8
7
+ data.tar.gz: e7856cc595443774d22222cb248aad3a275828b53a67d9ade7840288190582a4f6db436cb0aa986832c72be6fde8f09b24021a5de7133c8c00565147d871807e
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rake_roll.gemspec
4
+ gemspec
5
+
6
+ gem "pry"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Stuart Hanscombe
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,61 @@
1
+ # RakeRoll
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rake_roll'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rake_roll
18
+
19
+ ## Usage
20
+
21
+ rake roll
22
+
23
+ rake roll # shows version and all options
24
+ rake roll:pre # Bump to 0.1.0a
25
+ rake roll:bump # Bump to 0.1.1
26
+ rake roll:major # Bump to 1.0.0
27
+ rake roll:minor # Bump to 0.2.0
28
+
29
+ The above will do a dry run, and show the changelog updates in the
30
+ terminal window
31
+
32
+ ROLLING OUT FOR REAL
33
+
34
+ To Roll out the command for real, (update the version, changelog and
35
+ push everything up on the current branch of the git repo) use:
36
+
37
+ rake roll:bump PUSH=true
38
+
39
+ INITIAL SETUP
40
+
41
+ Create a VERSION file with the tag 0.0.1 (and git tag 0.0.1) if a
42
+ version file does not already exist, it will then create CHANGELOG
43
+ file if one does not already exist, use:
44
+
45
+ rake roll:build
46
+
47
+ CHANGELOG
48
+
49
+ Only commits starting with * will be added to the changelog, example:
50
+
51
+ * BugFix: #1234 IE6 Positioning fix
52
+ * Feature: #1111 Adding rake_roll to the Gemfile
53
+ * HotFix: Don't Delete current users
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it ( http://github.com/<my-github-username>/rake_roll/fork )
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,36 @@
1
+ module RakeRoll
2
+
3
+ class Never
4
+
5
+ def line
6
+ lyrics.sample
7
+ end
8
+
9
+ def lyrics
10
+ [
11
+ "We're no strangers to love",
12
+ "You know the rules and so do I",
13
+ "A full commitment's what I'm thinking of",
14
+ "You wouldn't get this from any other guy",
15
+ "I just want to tell you how I'm feeling",
16
+ "Gotta make you understand",
17
+ "Never gonna give you up",
18
+ "Never gonna let you down",
19
+ "Never gonna run around and desert you",
20
+ "Never gonna make you cry",
21
+ "Never gonna say goodbye",
22
+ "Never gonna tell a lie and hurt you",
23
+ "We've known each other for so long",
24
+ "Your heart's been aching but you're too shy to say it",
25
+ "Inside we both know what's been going on",
26
+ "We know the game and we're gonna play it",
27
+ "And if you ask me how I'm feeling",
28
+ "Don't tell me you're too blind to see",
29
+ "(Ooh give you up)",
30
+ "(Ooh) Never gonna give, never gonna give (give you up)"
31
+ ]
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,128 @@
1
+ module RakeRoll
2
+ class Roller
3
+
4
+ attr_reader :current_version, :current_branch
5
+ attr_accessor :new_version
6
+
7
+ def initialize
8
+ @current_version = current_version
9
+ @current_branch = current_branch
10
+ @new_version = nil
11
+ end
12
+
13
+ def current_version
14
+ return @current_version if @current_version
15
+ if File.exist?("VERSION")
16
+ File.read("VERSION").chomp
17
+ else
18
+ build_version
19
+ end
20
+ end
21
+
22
+ def current_branch
23
+ @current_branch ||= `git rev-parse --abbrev-ref HEAD`.chomp
24
+ end
25
+
26
+ def new_version
27
+ @new_version ||= current_version.dup.to_s
28
+ end
29
+
30
+ def log_to_s
31
+ puts "----------------------"
32
+ puts "CHANGELOG"
33
+ puts parsed_git_log
34
+ if parsed_git_log.empty?
35
+ puts "WARNING: no new CHANGELOG commits added"
36
+ end
37
+ puts "----------------------"
38
+ end
39
+
40
+ def print_run_for_real_text(type)
41
+ log_to_s
42
+ puts "=> rake roll:#{type} PUSH=true (to run for real)"
43
+ puts "----------------------"
44
+ end
45
+
46
+ def print_versions
47
+ puts ""
48
+ puts "----------------------"
49
+ puts "Updating tag from #{current_version} to #{new_version}"
50
+ end
51
+
52
+ def parsed_git_log(tag=nil)
53
+ git_log(tag).split("\n").select{|line| line[0] == "*"}.collect do |line|
54
+ line.split(" | ").reverse.join(" | ")
55
+ end
56
+ end
57
+
58
+ def push
59
+ puts "Rake Rolling..."
60
+ if parsed_git_log.empty?
61
+ puts "WARNING: no new CHANGELOG commits added"
62
+ end
63
+ update_version
64
+ update_changelog
65
+ commit_changes
66
+ update_tag
67
+ push_tag_and_branch
68
+ puts RakeRoll::Never.new.line
69
+ end
70
+
71
+ private
72
+
73
+ def update_version
74
+ puts "updating version to #{new_version}"
75
+ File.open("VERSION", "w") {|f| f.write(new_version) }
76
+ end
77
+
78
+ def update_changelog
79
+ puts "updating changelog"
80
+ text = [new_version]
81
+ parsed_git_log.reverse.each do |line|
82
+ text << "\t#{line}"
83
+ end
84
+ original_file = "CHANGELOG"
85
+ new_file = "changelog.tmp"
86
+ File.open(new_file, "w") do |file|
87
+ file.puts text.join("\n")
88
+ File.foreach(original_file) do |line|
89
+ file.puts line
90
+ end
91
+ end
92
+ system("mv changelog.tmp CHANGELOG")
93
+ end
94
+
95
+ def commit_changes
96
+ puts "committing changes"
97
+ system("git commit -a -m 'Updating Version to #{new_version}'")
98
+ end
99
+
100
+ def update_tag
101
+ puts "updating tag to #{new_version}"
102
+ system("git tag #{new_version}")
103
+ end
104
+
105
+ def push_tag_and_branch
106
+ puts "pushing tag and branch"
107
+ system("git push origin #{}")
108
+ end
109
+
110
+ def format
111
+ "--pretty=format:'%s | %an | %h'"
112
+ end
113
+
114
+ def git_log(tag=nil)
115
+ tag ||= current_branch
116
+ `git log #{current_version}..#{tag} #{format}`
117
+ end
118
+
119
+ def build_version
120
+ File.open("VERSION", "w") {|f| f.write("0.0.1") }
121
+ File.open("CHANGELOG", "w") {|f| f.write("0.0.1") } unless File.exist?("CHANGELOG")
122
+ system('git add VERSION CHANGELOG')
123
+ system('git commit -a -m "Creating Version and Changelog version 0.0.1"')
124
+ system('git tag 0.0.1')
125
+ end
126
+
127
+ end
128
+ end
@@ -0,0 +1,79 @@
1
+ task :roll => :environment do
2
+ roller = RakeRoll::Roller.new
3
+ version = RakeRoll::Version.new(roller.current_version)
4
+ puts "----------------------"
5
+ puts "rake roll options are:"
6
+ puts "----------------------"
7
+ puts "rake roll:bump #{roller.current_version} => #{version.bump}"
8
+ puts "rake roll:pre #{roller.current_version} => #{version.pre}"
9
+ puts "rake roll:minor #{roller.current_version} => #{version.minor}"
10
+ puts "rake roll:major #{roller.current_version} => #{version.major}"
11
+ puts "----------------------"
12
+ puts "Above will do a dry run, Run with PUSH=true to run for real"
13
+ puts "----------------------"
14
+ puts RakeRoll::Never.new.line
15
+ roller.log_to_s
16
+ end
17
+
18
+ desc "bump the version, update the tag and changelog"
19
+ namespace :roll do
20
+
21
+ desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Version.new(RakeRoll::Roller.new.current_version).bump}"
22
+ task :bump => :environment do
23
+ roller = RakeRoll::Roller.new
24
+ version = RakeRoll::Version.new(roller.current_version)
25
+ if version
26
+ roller.new_version = version.bump
27
+ do_your_thing(roller, version, "bump")
28
+ else
29
+ puts "ERROR: Invalid Version Number #{roller.current_version}"
30
+ end
31
+ end
32
+
33
+ desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Version.new(RakeRoll::Roller.new.current_version).major}"
34
+ task :major => :environment do
35
+ roller = RakeRoll::Roller.new
36
+ version = RakeRoll::Version.new(roller.current_version)
37
+ if version
38
+ roller.new_version = version.major
39
+ do_your_thing(roller, version, "major")
40
+ else
41
+ puts "ERROR: Invalid Version Number #{roller.current_version}"
42
+ end
43
+ end
44
+
45
+ desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Version.new(RakeRoll::Roller.new.current_version).minor}"
46
+ task :minor => :environment do
47
+ roller = RakeRoll::Roller.new
48
+ version = RakeRoll::Version.new(roller.current_version)
49
+ if version
50
+ roller.new_version = version.minor
51
+ do_your_thing(roller, version, "minor")
52
+ else
53
+ puts "ERROR: Invalid Version Number #{roller.current_version}"
54
+ end
55
+ end
56
+
57
+ desc "#{RakeRoll::Roller.new.current_version} => #{RakeRoll::Version.new(RakeRoll::Roller.new.current_version).pre}"
58
+ task :pre => :environment do
59
+ roller = RakeRoll::Roller.new
60
+ version = RakeRoll::Version.new(roller.current_version)
61
+ if version
62
+ roller.new_version = version.pre
63
+ do_your_thing(roller, version, "pre")
64
+ else
65
+ puts "ERROR: Invalid Version Number #{roller.current_version}"
66
+ end
67
+ end
68
+
69
+
70
+ end
71
+
72
+ def do_your_thing(roller, version, type)
73
+ roller.print_versions
74
+ if ENV["PUSH"]
75
+ roller.push
76
+ else
77
+ roller.print_run_for_real_text(type)
78
+ end
79
+ end
@@ -0,0 +1,61 @@
1
+ module RakeRoll
2
+
3
+ class Version
4
+
5
+ attr_reader :current_version
6
+
7
+ def initialize(current_version)
8
+ @current_version = check_current_version(current_version)
9
+ end
10
+
11
+ def bump
12
+ nums = current_version.split(".")
13
+ last_number = nums[-1].scan(/\d/).first.to_i
14
+ last_number = last_number + 1
15
+ nums[-1] = last_number
16
+ nums.join(".")
17
+ end
18
+
19
+ def pre
20
+ nums = current_version.split(".")
21
+ pre_letter = nums[-1].scan(/\D/).first
22
+ if pre_letter
23
+ next_letter = pre_letter.next
24
+ nums[-1].gsub!(pre_letter, next_letter)
25
+ else
26
+ nums[-1] = nums[-1] + "a"
27
+ end
28
+ nums.join(".")
29
+ end
30
+
31
+ def minor
32
+ nums = current_version.split(".")
33
+ minor_number = nums[1].scan(/\d/).first.to_i
34
+ minor_number = minor_number + 1
35
+ nums[1] = minor_number.to_s
36
+ nums.last.gsub!(/\D/, "")
37
+ nums[-1] = "0" if nums.length == 3
38
+ nums.join(".")
39
+ end
40
+
41
+ def major
42
+ nums = current_version.split(".")
43
+ major_number = nums[0].scan(/\d/).first.to_i
44
+ major_number = major_number + 1
45
+ nums[0] = major_number
46
+ nums[-1] = "0"
47
+ nums[-2] = "0" if nums.length == 3
48
+ nums.join(".")
49
+ end
50
+
51
+ private
52
+
53
+ def check_current_version(current)
54
+ splits = current.split(".")
55
+ return false if splits.size < 2 || splits.size > 3
56
+ current
57
+ end
58
+
59
+ end
60
+
61
+ end
data/lib/rake_roll.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "rake"
2
+ require "rake_roll/version"
3
+ require "rake_roll/never"
4
+ require "rake_roll/roller"
5
+ import File.join(File.dirname(__FILE__), "rake_roll/tasks/roll.rake")
6
+
7
+ module RakeRoll
8
+
9
+ end
data/rake_roll.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rake_roll"
7
+ spec.version = "0.1.0"
8
+ spec.authors = ["Stuart Hanscombe"]
9
+ spec.email = ["hanscs1969@yahoo.co.uk"]
10
+ spec.summary = "RakeRoll: Git version tagger and changelog creator"
11
+ spec.description = "RakeRoll: Will version and tag a release and create an updated changelog of the git commits, parsing only commits that are written in a simple markup structure"
12
+ spec.homepage = "http://www.thelazycamel.com"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.5"
21
+ spec.add_development_dependency "rake", "~> 0"
22
+ spec.add_development_dependency "pry", "~> 0"
23
+ end
File without changes
File without changes
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake_roll
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stuart Hanscombe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-16 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: 'RakeRoll: Will version and tag a release and create an updated changelog
56
+ of the git commits, parsing only commits that are written in a simple markup structure'
57
+ email:
58
+ - hanscs1969@yahoo.co.uk
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/rake_roll.rb
69
+ - lib/rake_roll/never.rb
70
+ - lib/rake_roll/roller.rb
71
+ - lib/rake_roll/tasks/roll.rake
72
+ - lib/rake_roll/version.rb
73
+ - rake_roll.gemspec
74
+ - spec/lib/rake_roll/roller_spec.rb
75
+ - spec/lib/rake_roll/version_spec.rb
76
+ homepage: http://www.thelazycamel.com
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.2.0
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: 'RakeRoll: Git version tagger and changelog creator'
100
+ test_files:
101
+ - spec/lib/rake_roll/roller_spec.rb
102
+ - spec/lib/rake_roll/version_spec.rb