incr 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8a3dac55072e2ed0833b9c979c22128a371b5aa
4
- data.tar.gz: 1666ac7d4d8636eac128c3e7ed72983a31395385
3
+ metadata.gz: ddf50651ee57b760d253bb3e7d275d8bd382636d
4
+ data.tar.gz: 4461847a7d0f909d2be997f825606211b7b5328b
5
5
  SHA512:
6
- metadata.gz: 2dc7f3010a7c1c81f3dd0618be1a3cc83646d131af98d26e4d3725de32612a1945d759da932f0293b0e9bfb96429eb359b250d13b0e4994dfc696972e57575cf
7
- data.tar.gz: 7a4dfb44e61584d3c4c584adb2c934f694885e7ee69f605efa2a9d8c0d6406de0479a01be4da347d0aec795ea8f744d123af792a27888e82bfab5f7065c38b33
6
+ metadata.gz: cc0ad79e813e7fae4bb8e91f151bae7cf07187e533e3eb612c71ad5a258f59c067cd493f5eecac84153b52724a05ad9101cfd104229ac7010ae6e357f7064c27
7
+ data.tar.gz: 6a17f0eaba6a2233e182ed14412e628447aa19db2bffe268d3b2fcb876ba19d843458866aeb5e5366eff0afacc9b64d8e8ebd95842a26bb163ef6bad5b20d590
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- incr (0.1.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.0
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
- ## Installation
14
+ ## What does `incr` do?
15
15
 
16
- ```shell
17
- ~> gem install incr
18
- ```
16
+ The process is detailed as follow:
19
17
 
20
- incr depends on the [Rugged](https://github.com/libgit2/rugged) Ruby bindings for [libgit2](https://libgit2.github.com/). You need to have `CMake` and `pkg-config` installed on your system to be able to build the included version of libgit2.
21
- On OS X, after installing [Homebrew](https://brew.sh/), you can get CMake with:
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
- ~> brew install cmake
31
+ ~> gem install incr
25
32
  ```
26
33
 
27
34
  ## Usage
@@ -20,5 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_runtime_dependency('gli', '2.17.1')
22
22
  spec.add_runtime_dependency('sem_version', '2.0.1')
23
- spec.add_runtime_dependency('rugged', '0.26.0')
23
+ spec.add_runtime_dependency('git', '1.3.0')
24
24
  end
@@ -1,4 +1,4 @@
1
- require 'incr/service/git'
1
+ require 'incr/service/repository'
2
2
  require 'incr/service/version'
3
3
  require 'incr/service/file_helper'
4
4
  require 'incr/command/npm'
@@ -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.replace(MIXFILE_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
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
- git = Incr::Service::Git.new('.')
24
- git.add(MIXFILE_FILENAME)
25
- oid = git.commit(new_version.to_s)
26
- git.tag("v#{new_version.to_s}", oid)
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
@@ -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.replace(PACKAGE_JSON_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
25
- Incr::Service::FileHelper.replace(PACKAGE_LOCK_JSON_FILENAME, version_pattern(old_version.to_s), version_pattern(new_version.to_s))
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
- git = Incr::Service::Git.new('.')
30
- git.add(PACKAGE_JSON_FILENAME)
31
- git.add(PACKAGE_LOCK_JSON_FILENAME)
32
- oid = git.commit(new_version.to_s)
33
- git.tag("v#{new_version.to_s}", oid)
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.replace(filename, old_text, new_text)
4
+ def self.replace_once(filename, old_text, new_text)
5
5
  old_content = File.read(filename)
6
- new_content = old_content.gsub(/#{Regexp.escape(old_text)}/, new_text)
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
@@ -1,3 +1,3 @@
1
1
  module Incr
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
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.2.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: 2017-12-21 00:00:00.000000000 Z
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: rugged
42
+ name: git
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.26.0
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: 0.26.0
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/git.rb
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.13
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
@@ -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