git_bumper 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: 9b8ae281cbee5393215f4851fbe2eca2baea9ab6
4
+ data.tar.gz: 4a183aad58abe42fd06ed5388a198c18d0e4c3ff
5
+ SHA512:
6
+ metadata.gz: 0bcb8968736411476cfccbebc2ef0d4b2691216777b76f40cf5dd6180c12713618fdc8bed010c2cd46469d1fb1567d695a3dfab72e724ddc006bb73f1827abb4
7
+ data.tar.gz: 78fa201911ebc984f39d4407bd33ed0a6bcdc9875fa0cc203ca11c40c193abda2417cdbac1600737fc246d6f98cc0e809a226cb2cc61bc336b621370f62d6b38
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1 @@
1
+ require: rubocop-rspec
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in git_bumper.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Lenon Marcel
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,58 @@
1
+ # GitBumper
2
+
3
+ [![Build Status][travis-badge]][travis-build]
4
+ [![Code Climate][cc-badge]][cc-details]
5
+ [![Test Coverage][cc-cov-badge]][cc-cov-details]
6
+
7
+ This gem provides a command-line utility to increment git tags.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'git_bumper'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install git_bumper
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
32
+ run `rake spec` to run the tests. You can also run `bin/console` for an
33
+ interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`.
36
+ To release a new version, update the version number in `version.rb`, and then
37
+ run `bundle exec rake release`, which will create a git tag for the version,
38
+ push git commits and tags, and push the `.gem`
39
+ file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at
44
+ https://github.com/lenon/git_bumper. This project is intended to be a safe,
45
+ welcoming space for collaboration, and contributors are expected to adhere to
46
+ the [Contributor Covenant](contributor-covenant.org) code of conduct.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the
51
+ [MIT License](http://opensource.org/licenses/MIT).
52
+
53
+ [travis-badge]: https://travis-ci.org/lenon/git_bumper.svg?branch=master
54
+ [travis-build]: https://travis-ci.org/lenon/git_bumper
55
+ [cc-badge]: https://codeclimate.com/github/lenon/git_bumper/badges/gpa.svg
56
+ [cc-details]: https://codeclimate.com/github/lenon/git_bumper
57
+ [cc-cov-badge]: https://codeclimate.com/github/lenon/git_bumper/badges/coverage.svg
58
+ [cc-cov-details]: https://codeclimate.com/github/lenon/git_bumper/coverage
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'git_bumper'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git_bumper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'git_bumper'
8
+ spec.version = GitBumper::VERSION
9
+ spec.authors = ['Lenon Marcel']
10
+ spec.email = ['lenon.marcel@gmail.com']
11
+
12
+ spec.summary = 'A CLI utility to bump git tags.'
13
+ spec.description = 'A CLI utility to bump git tags.'
14
+ spec.homepage = 'https://github.com/lenon/git_bumper'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ end
@@ -0,0 +1,36 @@
1
+ module GitBumper
2
+ # This object represents a git build tag. It expects the following format of
3
+ # tags:
4
+ # PREFIX.BUILD_NUMBER
5
+ # It provides some methods to parse and increment build numbers.
6
+ class BuildTag
7
+ REGEX = /\A([a-z]+)([0-9]+)\z/i
8
+
9
+ # Parses a string into a BuildTag object.
10
+ #
11
+ # @param str [String]
12
+ # @return [BuildTag] or false if str has an invalid format
13
+ def self.parse(str)
14
+ matches = str.scan(REGEX).flatten
15
+
16
+ return false if matches.empty?
17
+
18
+ new(matches[0], matches[1].to_i)
19
+ end
20
+
21
+ attr_reader :prefix
22
+ attr_accessor :build
23
+
24
+ # @param prefix [String]
25
+ # @param build [Fixnum]
26
+ def initialize(prefix, build)
27
+ @prefix = prefix
28
+ @build = build
29
+ end
30
+
31
+ # @return [String]
32
+ def to_s
33
+ "#{prefix}#{build}"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,31 @@
1
+ module GitBumper
2
+ # This module has some functions to deal with a git repository.
3
+ module Git
4
+ module_function
5
+
6
+ # Returns true if the current working directory has a git repository.
7
+ #
8
+ # @return [Boolean]
9
+ def repo?
10
+ system('git rev-parse --is-inside-work-tree >/dev/null 2>&1')
11
+ end
12
+
13
+ # Fetches all git tags.
14
+ def fetch_tags
15
+ system('git fetch --tags >/dev/null 2>&1')
16
+ end
17
+
18
+ # Returns the greatest tag.
19
+ def greatest_tag(prefix: 'v', tag_class: Tag)
20
+ output = `git tag --list --sort=-v:refname "#{prefix}[0-9]*" 2> /dev/null`
21
+
22
+ tags = output.split.collect do |tag|
23
+ tag_class.parse(tag)
24
+ end
25
+
26
+ tags.find do |tag|
27
+ tag
28
+ end || false
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,42 @@
1
+ module GitBumper
2
+ # This object represents a git tag. It expects the following format of tags:
3
+ # PREFIX.MAJOR.MINOR.PATCH
4
+ # It provides some methods to parse and increment version numbers.
5
+ class Tag
6
+ REGEX = /\A([a-z]+)([0-9]+)\.([0-9]+)\.([0-9]+)\z/i
7
+
8
+ # Parses a string into a Tag object.
9
+ #
10
+ # @param str [String]
11
+ # @return [Tag] or false if str has an invalid format
12
+ def self.parse(str)
13
+ matches = str.scan(REGEX).flatten
14
+
15
+ return false if matches.empty?
16
+
17
+ new(matches[0],
18
+ matches[1].to_i,
19
+ matches[2].to_i,
20
+ matches[3].to_i)
21
+ end
22
+
23
+ attr_reader :prefix
24
+ attr_accessor :major, :minor, :patch
25
+
26
+ # @param prefix [String]
27
+ # @param major [Fixnum]
28
+ # @param minor [Fixnum]
29
+ # @param patch [Fixnum]
30
+ def initialize(prefix, major, minor, patch)
31
+ @prefix = prefix
32
+ @major = major
33
+ @minor = minor
34
+ @patch = patch
35
+ end
36
+
37
+ # @return [String]
38
+ def to_s
39
+ "#{prefix}#{major}.#{minor}.#{patch}"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module GitBumper
2
+ VERSION = '0.1.0'
3
+ end
data/lib/git_bumper.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'git_bumper/version'
2
+ require 'git_bumper/tag'
3
+ require 'git_bumper/build_tag'
4
+ require 'git_bumper/git'
5
+
6
+ module GitBumper
7
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_bumper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Lenon Marcel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-11 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: rspec
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: A CLI utility to bump git tags.
56
+ email:
57
+ - lenon.marcel@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".rubocop.yml"
65
+ - ".travis.yml"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/setup
73
+ - git_bumper.gemspec
74
+ - lib/git_bumper.rb
75
+ - lib/git_bumper/build_tag.rb
76
+ - lib/git_bumper/git.rb
77
+ - lib/git_bumper/tag.rb
78
+ - lib/git_bumper/version.rb
79
+ homepage: https://github.com/lenon/git_bumper
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.5.1
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: A CLI utility to bump git tags.
103
+ test_files: []