incr 0.2.0 → 0.3.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 +4 -4
- data/README.md +14 -7
- data/incr.gemspec +1 -1
- data/lib/incr.rb +1 -1
- data/lib/incr/command/mix.rb +5 -5
- data/lib/incr/command/npm.rb +7 -7
- data/lib/incr/service/file_helper.rb +2 -2
- data/lib/incr/service/repository.rb +23 -0
- data/lib/incr/version.rb +1 -1
- metadata +7 -7
- data/lib/incr/service/git.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddf50651ee57b760d253bb3e7d275d8bd382636d
|
4
|
+
data.tar.gz: 4461847a7d0f909d2be997f825606211b7b5328b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc0ad79e813e7fae4bb8e91f151bae7cf07187e533e3eb612c71ad5a258f59c067cd493f5eecac84153b52724a05ad9101cfd104229ac7010ae6e357f7064c27
|
7
|
+
data.tar.gz: 6a17f0eaba6a2233e182ed14412e628447aa19db2bffe268d3b2fcb876ba19d843458866aeb5e5366eff0afacc9b64d8e8ebd95842a26bb163ef6bad5b20d590
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
incr (0.
|
4
|
+
incr (0.3.0)
|
5
|
+
git (= 1.3.0)
|
5
6
|
gli (= 2.17.1)
|
6
|
-
rugged (= 0.26.0)
|
7
7
|
sem_version (= 2.0.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
+
git (1.3.0)
|
12
13
|
gli (2.17.1)
|
13
|
-
rugged (0.26.0)
|
14
14
|
sem_version (2.0.1)
|
15
15
|
|
16
16
|
PLATFORMS
|
@@ -20,4 +20,4 @@ DEPENDENCIES
|
|
20
20
|
incr!
|
21
21
|
|
22
22
|
BUNDLED WITH
|
23
|
-
1.16.
|
23
|
+
1.16.1
|
data/README.md
CHANGED
@@ -11,17 +11,24 @@
|
|
11
11
|
<a href="https://travis-ci.org/jcouture/incr"><img src="http://img.shields.io/travis/jcouture/incr.svg" /></a>
|
12
12
|
</p>
|
13
13
|
|
14
|
-
##
|
14
|
+
## What does `incr` do?
|
15
15
|
|
16
|
-
|
17
|
-
~> gem install incr
|
18
|
-
```
|
16
|
+
The process is detailed as follow:
|
19
17
|
|
20
|
-
|
21
|
-
|
18
|
+
* Find the relevant file(s) (e.g.: `package.json` and `package-lock.json` or `mix.exs`).
|
19
|
+
* Determine the existing version number.
|
20
|
+
* Increment the specified segment. If you increment the minor segment, the patch segment is set to 0 and the same goes for the major segment, the minor and patch segments are set to 0.
|
21
|
+
* Write the newly incremented version number in the relevant file(s).
|
22
|
+
* Create a new `git commit` with the relevant file with the version number as the default message (e.g.: 0.2.1).
|
23
|
+
* Create a new `git tag` pointing to the new `git commit` with the version number prefixed by a 'v' as the name (e.g.: v0.2.1).
|
24
|
+
* 💥
|
25
|
+
|
26
|
+
## Installation
|
27
|
+
|
28
|
+
### incr
|
22
29
|
|
23
30
|
```shell
|
24
|
-
~>
|
31
|
+
~> gem install incr
|
25
32
|
```
|
26
33
|
|
27
34
|
## Usage
|
data/incr.gemspec
CHANGED
data/lib/incr.rb
CHANGED
data/lib/incr/command/mix.rb
CHANGED
@@ -16,14 +16,14 @@ module Incr
|
|
16
16
|
file_version = file_content.match(/version:\W*\"(\d*.\d*.\d*)",/)[1]
|
17
17
|
old_version = SemVersion.new(file_version)
|
18
18
|
new_version = Incr::Service::Version.increment_segment(old_version, @segment)
|
19
|
-
Incr::Service::FileHelper.
|
19
|
+
Incr::Service::FileHelper.replace_once(MIXFILE_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
|
20
20
|
|
21
21
|
puts "v#{new_version.to_s}"
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
repository = Incr::Service::Repository.new('.')
|
24
|
+
repository.add(MIXFILE_FILENAME)
|
25
|
+
repository.commit(new_version.to_s)
|
26
|
+
repository.tag("v#{new_version.to_s}")
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
data/lib/incr/command/npm.rb
CHANGED
@@ -21,16 +21,16 @@ module Incr
|
|
21
21
|
old_version = SemVersion.new(file_version)
|
22
22
|
new_version = Incr::Service::Version.increment_segment(old_version, @segment)
|
23
23
|
|
24
|
-
Incr::Service::FileHelper.
|
25
|
-
Incr::Service::FileHelper.
|
24
|
+
Incr::Service::FileHelper.replace_once(PACKAGE_JSON_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
|
25
|
+
Incr::Service::FileHelper.replace_once(PACKAGE_LOCK_JSON_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
|
26
26
|
|
27
27
|
puts "v#{new_version.to_s}"
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
repository = Incr::Service::Repository.new('.')
|
30
|
+
repository.add(PACKAGE_JSON_FILENAME)
|
31
|
+
repository.add(PACKAGE_LOCK_JSON_FILENAME)
|
32
|
+
repository.commit(new_version.to_s)
|
33
|
+
repository.tag("v#{new_version.to_s}")
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Incr
|
2
2
|
module Service
|
3
3
|
class FileHelper
|
4
|
-
def self.
|
4
|
+
def self.replace_once(filename, old_text, new_text)
|
5
5
|
old_content = File.read(filename)
|
6
|
-
new_content = old_content.
|
6
|
+
new_content = old_content.sub(/#{Regexp.escape(old_text)}/, new_text)
|
7
7
|
File.open(filename, 'w') { |file| file << new_content }
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'git'
|
2
|
+
|
3
|
+
module Incr
|
4
|
+
module Service
|
5
|
+
class Repository
|
6
|
+
def initialize(path)
|
7
|
+
@git = Git.init(path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def add(filename)
|
11
|
+
@git.add(filename)
|
12
|
+
end
|
13
|
+
|
14
|
+
def commit(message)
|
15
|
+
@git.commit(message)
|
16
|
+
end
|
17
|
+
|
18
|
+
def tag(name)
|
19
|
+
@git.add_tag(name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/incr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Philippe Couture
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.0.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: git
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.3.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.3.0
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- jcouture@gmail.com
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- lib/incr/command/mix.rb
|
73
73
|
- lib/incr/command/npm.rb
|
74
74
|
- lib/incr/service/file_helper.rb
|
75
|
-
- lib/incr/service/
|
75
|
+
- lib/incr/service/repository.rb
|
76
76
|
- lib/incr/service/version.rb
|
77
77
|
- lib/incr/version.rb
|
78
78
|
homepage: https://github.com/jcouture/incr
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.6.
|
99
|
+
rubygems_version: 2.6.14
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Tasteful utility to increment the version number and create a corresponding
|
data/lib/incr/service/git.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'rugged'
|
2
|
-
|
3
|
-
module Incr
|
4
|
-
module Service
|
5
|
-
class Git
|
6
|
-
def initialize(path)
|
7
|
-
@repository = Rugged::Repository.new(path)
|
8
|
-
@index = @repository.index
|
9
|
-
@author = @repository.head.target.author
|
10
|
-
end
|
11
|
-
|
12
|
-
def add(filename)
|
13
|
-
@index.add(filename)
|
14
|
-
@index.write
|
15
|
-
end
|
16
|
-
|
17
|
-
def commit(message)
|
18
|
-
options = {}
|
19
|
-
options[:tree] = @index.write_tree(@repository)
|
20
|
-
|
21
|
-
author = @author.clone
|
22
|
-
author[:time] = Time.now
|
23
|
-
|
24
|
-
options[:author] = author
|
25
|
-
options[:committer] = author
|
26
|
-
options[:message] ||= message
|
27
|
-
options[:parents] = @repository.empty? ? [] : [ @repository.head.target ].compact
|
28
|
-
options[:update_ref] = 'HEAD'
|
29
|
-
|
30
|
-
Rugged::Commit.create(@repository, options)
|
31
|
-
end
|
32
|
-
|
33
|
-
def tag(name, target)
|
34
|
-
author = @author.clone
|
35
|
-
author[:time] = Time.now
|
36
|
-
|
37
|
-
# annotation = {
|
38
|
-
# tagger: author,
|
39
|
-
# message: 'a message?'
|
40
|
-
# }
|
41
|
-
# @repository.tags.create(name, target, annotation)
|
42
|
-
@repository.tags.create(name, target)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|