bumpversion 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3699698a3463f71a63171e8885e7c66e9b257690
4
+ data.tar.gz: 16f26db58256b17d32b43e93fd93c130101c30ba
5
+ SHA512:
6
+ metadata.gz: 3c1a45d30f2bde21b57281109580669828cd35248d9f8ffcdc2f38eea360018f0ac6947abc6c17fb9d5708f495390b2d5687de694174847332d22ef84dec51bf
7
+ data.tar.gz: d07c9c102acd9cf85a85d6580da88be2bbaec796a2df8d55692da3869249a3ab19a0b3ddd9ae85fdcdc6281dcf6d1bfefa355be82b270d9f4685c36285c3513d
@@ -0,0 +1,9 @@
1
+ [bumpversion]
2
+ current-version=0.3.0
3
+ file=lib/bumpversion/version.rb
4
+ git-commit=yes
5
+ git-tag=yes
6
+ git-push=yes
7
+ pre-commit-hooks=github_changelog_generator --future-release %{new_version}
8
+ pos-commit-hooks=gem build bumpversion.gemspec; gem push *.gem; rm *.gem
9
+ git-extra-add=CHANGELOG.md
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ spec/files/VERSION
11
+ spec/files/bumpversion.cfg
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,16 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Metrics/LineLength:
4
+ Enabled: false
5
+
6
+ Style/StringLiterals:
7
+ EnforcedStyle: double_quotes
8
+
9
+ Metrics/ClassLength:
10
+ Enabled: false
11
+
12
+ Metrics/MethodLength:
13
+ Enabled: false
14
+
15
+ Documentation:
16
+ Enabled: false
@@ -0,0 +1,105 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-09-18 03:18:40 +0000 using RuboCop version 0.34.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ Lint/UnusedBlockArgument:
12
+ Exclude:
13
+ - 'lib/bumpversion/bump_string.rb'
14
+
15
+ # Offense count: 6
16
+ # Configuration parameters: AllowURI, URISchemes.
17
+ Metrics/LineLength:
18
+ Max: 161
19
+
20
+ # Offense count: 1
21
+ # Configuration parameters: CountComments.
22
+ Metrics/MethodLength:
23
+ Max: 13
24
+
25
+ # Offense count: 1
26
+ # Cop supports --auto-correct.
27
+ Performance/StringReplacement:
28
+ Exclude:
29
+ - 'lib/bumpversion/parser_file.rb'
30
+
31
+ # Offense count: 2
32
+ # Cop supports --auto-correct.
33
+ Style/ColonMethodCall:
34
+ Exclude:
35
+ - 'lib/bumpversion/parser.rb'
36
+
37
+ # Offense count: 5
38
+ Style/Documentation:
39
+ Exclude:
40
+ - 'lib/bumpversion.rb'
41
+ - 'lib/bumpversion/bump_string.rb'
42
+ - 'lib/bumpversion/parser.rb'
43
+ - 'lib/bumpversion/parser_file.rb'
44
+ - 'lib/bumpversion/version.rb'
45
+
46
+ # Offense count: 8
47
+ # Cop supports --auto-correct.
48
+ # Configuration parameters: AllowForAlignment.
49
+ Style/ExtraSpacing:
50
+ Exclude:
51
+ - 'spec/bumpversion_spec.rb'
52
+
53
+ # Offense count: 9
54
+ # Cop supports --auto-correct.
55
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
56
+ Style/HashSyntax:
57
+ Enabled: false
58
+
59
+ # Offense count: 3
60
+ # Cop supports --auto-correct.
61
+ Style/NegatedIf:
62
+ Exclude:
63
+ - 'lib/bumpversion/bump_string.rb'
64
+ - 'lib/bumpversion/parser_file.rb'
65
+
66
+ # Offense count: 2
67
+ # Cop supports --auto-correct.
68
+ # Configuration parameters: PreferredDelimiters.
69
+ Style/PercentLiteralDelimiters:
70
+ Exclude:
71
+ - 'bumpversion.gemspec'
72
+
73
+ # Offense count: 2
74
+ # Cop supports --auto-correct.
75
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
76
+ Style/SignalException:
77
+ Exclude:
78
+ - 'bumpversion.gemspec'
79
+ - 'lib/bumpversion/parser.rb'
80
+
81
+ # Offense count: 4
82
+ # Cop supports --auto-correct.
83
+ # Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles.
84
+ Style/SpaceAroundBlockParameters:
85
+ Exclude:
86
+ - 'lib/bumpversion/bump_string.rb'
87
+ - 'lib/bumpversion/parser_file.rb'
88
+
89
+ # Offense count: 2
90
+ # Cop supports --auto-correct.
91
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
92
+ Style/SpaceInsideHashLiteralBraces:
93
+ Enabled: false
94
+
95
+ # Offense count: 46
96
+ # Cop supports --auto-correct.
97
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
98
+ Style/StringLiterals:
99
+ Enabled: false
100
+
101
+ # Offense count: 2
102
+ # Cop supports --auto-correct.
103
+ Style/UnneededPercentQ:
104
+ Exclude:
105
+ - 'bumpversion.gemspec'
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ before_install: gem update --system
3
+ rvm:
4
+ - 2.2.2
5
+ script:
6
+ - bundle exec rake
7
+ notifications:
8
+ email:
9
+ recipients:
10
+ - dlanileonardo@gmail.com
11
+ on_success: never
12
+ on_failure: change
13
+ addons:
14
+ code_climate:
15
+ repo_token: d4414bf80101ee909af5f04154416c9cccc5cd4c5d779c8a0f9aa2c4036cf68b
@@ -0,0 +1,29 @@
1
+ # Change Log
2
+
3
+ ## [0.3.0](https://github.com/dlanileonardo/bumpversion/tree/0.3.0) (2016-04-27)
4
+ **Implemented enhancements:**
5
+
6
+ - Push tag to Remote [\#15](https://github.com/dlanileonardo/bumpversion/issues/15)
7
+ - Improve Output [\#10](https://github.com/dlanileonardo/bumpversion/issues/10)
8
+ - Git Commits and Tags [\#2](https://github.com/dlanileonardo/bumpversion/issues/2)
9
+ - System Hooks [\#1](https://github.com/dlanileonardo/bumpversion/issues/1)
10
+ - Update README.md [\#19](https://github.com/dlanileonardo/bumpversion/pull/19) ([dlanileonardo](https://github.com/dlanileonardo))
11
+ - Pretty Output [\#18](https://github.com/dlanileonardo/bumpversion/pull/18) ([dlanileonardo](https://github.com/dlanileonardo))
12
+ - Git Extra file to commit [\#11](https://github.com/dlanileonardo/bumpversion/pull/11) ([dlanileonardo](https://github.com/dlanileonardo))
13
+ - Git Operations [\#9](https://github.com/dlanileonardo/bumpversion/pull/9) ([dlanileonardo](https://github.com/dlanileonardo))
14
+ - Pre commit Hook [\#8](https://github.com/dlanileonardo/bumpversion/pull/8) ([dlanileonardo](https://github.com/dlanileonardo))
15
+ - Improve Rspec [\#4](https://github.com/dlanileonardo/bumpversion/pull/4) ([dlanileonardo](https://github.com/dlanileonardo))
16
+
17
+ **Merged pull requests:**
18
+
19
+ - Bumpversion [\#20](https://github.com/dlanileonardo/bumpversion/pull/20) ([dlanileonardo](https://github.com/dlanileonardo))
20
+ - Remove unecessary files [\#17](https://github.com/dlanileonardo/bumpversion/pull/17) ([dlanileonardo](https://github.com/dlanileonardo))
21
+ - Adjusts to Work [\#16](https://github.com/dlanileonardo/bumpversion/pull/16) ([dlanileonardo](https://github.com/dlanileonardo))
22
+ - Adjusts to Work [\#14](https://github.com/dlanileonardo/bumpversion/pull/14) ([dlanileonardo](https://github.com/dlanileonardo))
23
+ - Adjusts to Work [\#13](https://github.com/dlanileonardo/bumpversion/pull/13) ([dlanileonardo](https://github.com/dlanileonardo))
24
+ - Author and Spec [\#12](https://github.com/dlanileonardo/bumpversion/pull/12) ([dlanileonardo](https://github.com/dlanileonardo))
25
+ - waffle.io Badge [\#6](https://github.com/dlanileonardo/bumpversion/pull/6) ([waffle-iron](https://github.com/waffle-iron))
26
+
27
+
28
+
29
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bumpversion.gemspec
4
+ gemspec
5
+
6
+ gem 'trollop', '>= 2.1'
7
+ gem 'parseconfig', '>= 1.0'
8
+ gem 'colorize', '>= 0.7'
9
+ gem 'git', '>= 1.2.9'
10
+
11
+ group :test do
12
+ gem 'rubocop', '~>0.31'
13
+ gem 'coveralls', '~>0.8', require: false
14
+ gem 'simplecov', '~>0.10', require: false
15
+ gem "codeclimate-test-reporter", "~>0.4"
16
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 TODO: Write your name
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.
@@ -0,0 +1,69 @@
1
+ # Bumpversion
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bumpversion`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ # Code Status
8
+
9
+
10
+
11
+ Service | Status
12
+ --------|----------
13
+ Issues Ready to Work|[![Waffle.io](https://img.shields.io/waffle/label/dlanileonardo/bumpversion/in%20progress.svg?maxAge=2592000&style=flat-square)](https://waffle.io/dlanileonardo/bumpversion)
14
+ Gems Version|[![Gem](https://img.shields.io/gem/v/bumpversion.svg?maxAge=2592000&style=flat-square)](http://badge.fury.io/rb/bumpversion)
15
+ Code Climate|[![Code Climate](https://img.shields.io/codeclimate/github/kabisaict/flow.svg?maxAge=2592000&style=flat-square)](https://codeclimate.com/github/dlanileonardo/bumpversion)
16
+ Coverage|[![Code Climate](https://img.shields.io/codeclimate/coverage/github/dlanileonardo/bumpversion.svg?maxAge=2592000&style=flat-square)](https://codeclimate.com/github/dlanileonardo/bumpversion/coverage)
17
+ Build Status|[![Travis](https://img.shields.io/travis/dlanileonardo/bumpversion.svg?maxAge=2592000&style=flat-square)](https://travis-ci.org/dlanileonardo/bumpversion)
18
+
19
+ ## Installation
20
+
21
+ $ gem install bumpversion
22
+
23
+ ## Usage
24
+
25
+ 1. Create .bumpversion.cfg file in project root folder.
26
+
27
+ Example:
28
+
29
+ ```
30
+ [bumpversion]
31
+ current-version=33.0.2
32
+ pre-commit-hooks=github_changelog_generator --future-release %{new_version}
33
+ git-extra-add=CHANGELOG.md
34
+ git-commit=yes
35
+ git-tag=yes
36
+ git-push=yes
37
+ ```
38
+
39
+ 2. Run command with argument [major, minor, patch]:
40
+
41
+ ```
42
+ $ bumpversion patch
43
+ ```
44
+
45
+ 3. Enjoy
46
+
47
+ ## Options
48
+
49
+ Options can be passed in arguments with -- or in .cfg file wihout --.
50
+
51
+ Option|Description
52
+ --------|----------
53
+ part|The part of the version to increase, [major, minor, patch] (default: minor)
54
+ file|The file that will be modified can be multi-files separated by comma. <br /> Example: VERSION, GEMNAME.gemspec, version.rb (Default: VERSION)
55
+ config-file|The file contains config this program (default: .bumpversion.cfg)
56
+ current-version|The current version of the software package before bumping
57
+ new-version| The version of the software package after the increment. <br /> If not given will be automatically determined.
58
+ git-commit|Whether to create a commit using Git.
59
+ git-tag|Whether to create a tag, that is the new version, prefixed with the character "v". If you are using git
60
+ git-push|Pushes Tags and Commit to origin Git
61
+ git-user|Name from User to Create Commit (default: Auto Bump)
62
+ git-email|Email from User to Create Email (default: auto@bump.io)
63
+ git-extra-add|Extra files to add in git commit (default: )
64
+ pre-commit-hooks|Call sh commands before commits after Bumpversion separated by ;
65
+ pos-commit-hooks|Call sh commands after commits separated by ;
66
+
67
+ ## License
68
+
69
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ #! /usr/bin/env ruby
2
+ require_relative '../lib/bumpversion'
3
+ Bumpversion::Bumpversion.new.run
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bumpversion/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'bumpversion'
8
+ spec.version = Bumpversion::VERSION
9
+ spec.default_executable = "bumpversion"
10
+ spec.authors = ['Dlani Mendes']
11
+ spec.email = ['dlanileonardo@gmail.com']
12
+ spec.date = `date +"%Y-%m-%d"`.strip!
13
+
14
+ spec.summary = 'Auto Bump Version to any project'
15
+ spec.description = 'Bump version by params or config file with Hooks! :).'
16
+ spec.homepage = 'https://github.com/dlanileonardo/bumpversion'
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.bindir = 'bin'
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_runtime_dependency("trollop", ["~> 2.1"])
26
+ spec.add_runtime_dependency("parseconfig", ["~> 1.0"])
27
+ spec.add_runtime_dependency("colorize", ["~> 0.7"])
28
+ spec.add_runtime_dependency("git", ['~> 1.2', '>= 1.2.9'])
29
+
30
+ spec.add_development_dependency('bundler', ['~> 1.10'])
31
+ spec.add_development_dependency('rake', ['~> 10.0'])
32
+ spec.add_development_dependency('rspec', ['~> 0'])
33
+ end
@@ -0,0 +1,58 @@
1
+ require_relative 'bumpversion/version'
2
+ require_relative 'bumpversion/parser'
3
+ require_relative 'bumpversion/parser_file'
4
+ require_relative 'bumpversion/bump_string'
5
+ require_relative 'bumpversion/reader'
6
+ require_relative 'bumpversion/writer'
7
+ require_relative 'bumpversion/git_operation'
8
+ require_relative 'bumpversion/hook'
9
+ require_relative 'bumpversion/pretty_output'
10
+
11
+ module Bumpversion
12
+ class Bumpversion
13
+ def initialize(arguments = nil)
14
+ PrettyOutput.start("Bump your project ... ☺ ")
15
+
16
+ PrettyOutput.begin("Parsing Options Start")
17
+ parser = Parser.new @options, arguments
18
+ @options = parser.parse
19
+ PrettyOutput.sucess("Done!")
20
+
21
+ PrettyOutput.begin("Parsing File Start")
22
+ parser_file = ParseFile.new @options
23
+ @options = parser_file.parse
24
+ PrettyOutput.sucess("Done!")
25
+
26
+ PrettyOutput.begin("Bump String")
27
+ bump_string = BumpString.new @options
28
+ @options = bump_string.bump
29
+ PrettyOutput.sucess("Done!")
30
+ @git = GitOperation.new @options
31
+ end
32
+
33
+ def run
34
+ PrettyOutput.begin("Reading Files")
35
+ reader = Reader.new @options
36
+ PrettyOutput.sucess("Done!")
37
+
38
+ PrettyOutput.begin("Writing Files")
39
+ writer = Writer.new @options, reader
40
+ writer.write!
41
+ PrettyOutput.sucess("Done!")
42
+
43
+ PrettyOutput.begin("Pre Commit Hooks")
44
+ Hook.pre_commit_hook @options
45
+ PrettyOutput.sucess("Done!")
46
+
47
+ PrettyOutput.begin("Git Operations")
48
+ @git.do!
49
+ PrettyOutput.sucess("Done!")
50
+
51
+ PrettyOutput.begin("Pos Commit Hooks")
52
+ Hook.pos_commit_hook @options
53
+ PrettyOutput.sucess("Done!")
54
+
55
+ PrettyOutput.finish("Your project was Bumped with sucess! #{@options[:current_version]} → #{@options[:new_version]} ☺ ")
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,49 @@
1
+ module Bumpversion
2
+ class BumpString
3
+ def initialize(options)
4
+ @options = options
5
+ end
6
+
7
+ def dictionary
8
+ { major: 1, minor: 2, patch: 3 }
9
+ end
10
+
11
+ def key_part
12
+ @options[:part].to_sym
13
+ end
14
+
15
+ def pattern
16
+ /([0-9]+)\.([0-9]+)\.([0-9]+)/
17
+ end
18
+
19
+ def matched
20
+ match = pattern.match(@options[:current_version])
21
+ matched = {}
22
+ dictionary.each { |part, number| matched[part] = match[number].to_i }
23
+ matched
24
+ end
25
+
26
+ def update_version(matched_version)
27
+ bumped = false
28
+ matched_version.each do | part, number |
29
+ matched_version[part] = 0 if bumped
30
+
31
+ if part == key_part
32
+ matched_version[part] += 1
33
+ bumped = true
34
+ end
35
+ end
36
+
37
+ matched_version
38
+ end
39
+
40
+ def bump
41
+ unless @options[:new_version]
42
+ matched_version = update_version(matched)
43
+ new_version_hash = matched_version.map { |_key, value| value.to_s }
44
+ @options[:new_version] = new_version_hash.join('.')
45
+ end
46
+ @options
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,41 @@
1
+ require 'git'
2
+
3
+ module Bumpversion
4
+ class GitOperation
5
+ def initialize(options)
6
+ @options = options
7
+ @git = Git.init
8
+ Git.init('.')
9
+ end
10
+
11
+ def config!
12
+ @git.config('user.name', @options[:git_user])
13
+ @git.config('user.email', @options[:git_email])
14
+ end
15
+
16
+ def commit!
17
+ if @options[:git_commit]
18
+ file = @options[:file].split(',') + [@options[:config_file]]
19
+ file += @options[:git_extra_add].split(',') if @options[:git_extra_add]
20
+ @git.add(file)
21
+ @git.commit("Bump version: #{@options[:current_version]} → #{@options[:new_version]}")
22
+ end
23
+ end
24
+
25
+ def tag!
26
+ @git.add_tag("v#{@options[:new_version]}") if @options[:git_tag]
27
+ end
28
+
29
+ def push!
30
+ @git.push if @options[:git_push]
31
+ @git.push(@git.remote.name, @git.branch.name, {:tags => true}) if @options[:git_push] && @options[:git_tag]
32
+ end
33
+
34
+ def do!
35
+ config!
36
+ commit!
37
+ tag!
38
+ push!
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+
2
+ module Bumpversion
3
+ class Hook
4
+ def self.call_system(key_hook,options)
5
+ return false unless options[key_hook]
6
+ command = options[key_hook] % options
7
+ PrettyOutput.info "Executing command: #{command}"
8
+ system("#{command} 1> /dev/null") if command
9
+ end
10
+
11
+ def self.pos_commit_hook(options)
12
+ call_system(:pos_commit_hooks, options)
13
+ end
14
+
15
+ def self.pre_commit_hook(options)
16
+ call_system(:pre_commit_hooks, options)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,55 @@
1
+ require 'trollop'
2
+
3
+ module Bumpversion
4
+ class Parser
5
+ def initialize(options, arguments = nil)
6
+ @args = arguments || ARGV
7
+ @options = options
8
+ end
9
+
10
+ def mount_banner
11
+ Trollop::Parser.new do
12
+ banner <<-EOS
13
+ Bumpversion 0.1.0
14
+
15
+ Usage:
16
+ bumpversion [options]
17
+ where [options] are:
18
+ EOS
19
+ opt :help, 'Show this help!'
20
+ opt :part, 'The part of the version to increase, [major, minor, patch]', default: 'minor'
21
+ opt :file, 'The file that will be modified can be multi-files separated by comma.
22
+ Example: VERSION, GEMNAME.gemspec, version.rb', default: 'VERSION', type: :string
23
+ opt :config_file, 'The file contains config this program', default: '.bumpversion.cfg', type: :string
24
+ opt :current_version, 'The current version of the software package before bumping ', type: :string
25
+ opt :new_version, 'The version of the software package after the increment. \
26
+ If not given will be automatically determined.', required: false, type: :string
27
+
28
+ opt :git_commit, 'Whether to create a commit using Git.', required: false, default: false, type: :boolean
29
+ opt :git_tag, 'Whether to create a tag, that is the new version, prefixed with the character "v". If you are using git',
30
+ required: false, default: false, type: :boolean
31
+ opt :git_push, 'Pushes Tags and Commit to origin Git', reuired: false, default: false, type: :boolean
32
+ opt :git_user, 'Name from User to Create Commit', required: false, default: "Auto Bump", type: :string
33
+ opt :git_email, 'Email from User to Create Email', required: false, default: "auto@bump.io", type: :string
34
+ opt :git_extra_add, 'Extra files to add in git commit', required: false, default: "", type: :string
35
+
36
+ opt :pre_commit_hooks, 'Call sh commands before commits after Bumpversion separated by ;',
37
+ required: false, type: :string
38
+ opt :pos_commit_hooks, 'Call sh commands after commits separated by ;',
39
+ required: false, type: :string
40
+ end
41
+ end
42
+
43
+ def parse
44
+ banner = mount_banner
45
+ @options = Trollop.with_standard_exception_handling banner do
46
+ fail Trollop::HelpNeeded if @args.empty?
47
+ banner.parse @args
48
+ end
49
+
50
+ Trollop.die if @options[:help]
51
+
52
+ @options
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,29 @@
1
+ require 'parseconfig'
2
+
3
+ module Bumpversion
4
+ class ParseFile
5
+ def initialize(options)
6
+ @options = options
7
+ end
8
+
9
+ def parse
10
+ return @options unless File.exist?(@options[:config_file])
11
+ config = ParseConfig.new(@options[:config_file])
12
+ merge(@options, config['bumpversion']) if config && config['bumpversion']
13
+ end
14
+
15
+ def merge(options, parseconfig)
16
+ parseconfig.each do |key, value|
17
+ key = key.tr('-', '_')
18
+ key_given = "#{key}_given"
19
+ key_given_file = "#{key_given}_file"
20
+
21
+ unless options[key_given.to_sym]
22
+ options[key.to_sym] = value
23
+ options[key_given_file.to_sym] = value
24
+ end
25
+ end
26
+ options
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require 'colorize'
2
+
3
+ module Bumpversion
4
+ class PrettyOutput
5
+ def self.start(msg)
6
+ puts "→ #{msg}".white
7
+ end
8
+
9
+ def self.finish(msg)
10
+ puts "→ #{msg}".white
11
+ end
12
+
13
+ def self.begin(msg)
14
+ puts " → #{msg}".blue
15
+ end
16
+
17
+ def self.info(msg)
18
+ puts " → #{msg}".blue
19
+ end
20
+
21
+ def self.sucess(msg)
22
+ puts " → #{msg} √".green
23
+ end
24
+
25
+ def self.error(msg)
26
+ puts " → #{msg} ✖".red
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,28 @@
1
+ module Bumpversion
2
+ class Reader
3
+ def initialize(options)
4
+ @options = options
5
+ @files_to_write = []
6
+ end
7
+
8
+ attr_reader :files_to_write
9
+
10
+ def validate!
11
+ files_to_write.each do |file_to_write|
12
+ fail "Current Version not found in #{file_to_write[:filename]} file" unless file_to_write[:content].include? @options[:current_version]
13
+ end
14
+ end
15
+
16
+ def reader!
17
+ files_to_read = @options[:file].split(",")
18
+ files_to_read.each do |file_to_read|
19
+ files_to_write << {
20
+ filename: file_to_read,
21
+ content: File.read(file_to_read)
22
+ }
23
+ end
24
+
25
+ validate!
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Bumpversion
2
+ VERSION = '0.3.0'
3
+ end
@@ -0,0 +1,42 @@
1
+ module Bumpversion
2
+ class Writer
3
+ def initialize(options, reader)
4
+ @options = options
5
+ @reader = reader
6
+ end
7
+
8
+ def reader_files
9
+ @reader.reader!
10
+ @reader.files_to_write
11
+ end
12
+
13
+ def content_config_file
14
+ @content_config_file ||= File.read(@options[:config_file])
15
+ end
16
+
17
+ def validate!
18
+ file_exists = File.exist? @options[:config_file]
19
+ file_has_current_version = (file_exists && content_config_file.include?("current-version"))
20
+ file_current_version_match = file_has_current_version && content_config_file.include?(@options[:current_version])
21
+ valid = !file_exists || !file_has_current_version || file_current_version_match
22
+
23
+ fail "Version File does not Match with Current Version" unless valid
24
+ end
25
+
26
+ def update_config_file!
27
+ new_content = content_config_file.gsub(@options[:current_version], @options[:new_version])
28
+ File.write(@options[:config_file], new_content)
29
+ end
30
+
31
+ def write!
32
+ reader_files.each do |file_to_write|
33
+ validate!
34
+
35
+ new_content = file_to_write[:content].gsub(@options[:current_version], @options[:new_version])
36
+ File.write(file_to_write[:filename], new_content)
37
+
38
+ update_config_file!
39
+ end
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bumpversion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Dlani Mendes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: trollop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: parseconfig
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: git
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.2.9
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.2'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.2.9
75
+ - !ruby/object:Gem::Dependency
76
+ name: bundler
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.10'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.10'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '10.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '10.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ description: Bump version by params or config file with Hooks! :).
118
+ email:
119
+ - dlanileonardo@gmail.com
120
+ executables:
121
+ - bumpversion
122
+ extensions: []
123
+ extra_rdoc_files: []
124
+ files:
125
+ - ".bumpversion.cfg"
126
+ - ".gitignore"
127
+ - ".rspec"
128
+ - ".rubocop.yml"
129
+ - ".rubocop_todo.yml"
130
+ - ".travis.yml"
131
+ - CHANGELOG.md
132
+ - CODE_OF_CONDUCT.md
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - README.md
136
+ - Rakefile
137
+ - bin/bumpversion
138
+ - bumpversion.gemspec
139
+ - lib/bumpversion.rb
140
+ - lib/bumpversion/bump_string.rb
141
+ - lib/bumpversion/git_operation.rb
142
+ - lib/bumpversion/hook.rb
143
+ - lib/bumpversion/parser.rb
144
+ - lib/bumpversion/parser_file.rb
145
+ - lib/bumpversion/pretty_output.rb
146
+ - lib/bumpversion/reader.rb
147
+ - lib/bumpversion/version.rb
148
+ - lib/bumpversion/writer.rb
149
+ homepage: https://github.com/dlanileonardo/bumpversion
150
+ licenses:
151
+ - MIT
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.6.4
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Auto Bump Version to any project
173
+ test_files: []