git_bumper 0.1.2 → 0.1.3

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: 242f97c1afcd0a3b35fdb21a3cdbe077aefb5348
4
- data.tar.gz: 6a349f3457a478ed0c43a323e6579604e6ff7b63
3
+ metadata.gz: 9682904c029feef4497ed753c1873d937a667c92
4
+ data.tar.gz: bbe4c5ad8b6188d5e895fc2b336b5247cd5c7596
5
5
  SHA512:
6
- metadata.gz: 3ed798d97e37762dbf386d1caf574cf3017c040485e5826ed000263c5fab921d9f0c3fa8518dd24cabe20265f28ffa463ce9e9a0665e19cdcf05da9fbc85f3a1
7
- data.tar.gz: fa64bac181c82fad8989a9ee35197025ae9d811a1c7cd97b80c33dec6767a76e528ea0ffd9a513f876a2e287ddcf82d1d35e21da88e343018c42fbe7245cc250
6
+ metadata.gz: c107927ae9436ce86902e2cf03618e82e1ee4d223616f082ad3ebe7b6c70ff41cccc95dea33ed449df5b1315b4e1e9c9ea876dcc983173ddeb26a2b949fc801d
7
+ data.tar.gz: 7198165452a5d9e6df934cf9b97373aa394770cbc536e860e437815683f2eecf6f38e17e3ae0ccfca7a18d60d9cf9aa7b7f3d99fe6abc9da80720550ee1c0160
@@ -1,8 +1,7 @@
1
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.
2
+ # This object represents a "build" tag. These tags are expected to have the
3
+ # format PREFIX.BUILD_NUMBER (e.g. v1, v2, a1, a2).
4
+ # It provides some methods to parse, increment and compare tags.
6
5
  class BuildTag
7
6
  REGEX = /\A([a-z]+)([0-9]+)\z/i
8
7
 
@@ -37,5 +36,9 @@ module GitBumper
37
36
  def increment(*)
38
37
  @build += 1
39
38
  end
39
+
40
+ def <=>(other)
41
+ build <=> other.build
42
+ end
40
43
  end
41
44
  end
@@ -22,7 +22,7 @@ module GitBumper
22
22
 
23
23
  puts "The old tag is #{old_tag}"
24
24
  puts "The new tag will be #{new_tag}"
25
- puts 'Push to origin? (y/N)'
25
+ puts 'Push to origin? (Y/n)'
26
26
 
27
27
  return error('Aborted.') unless prompt_yes
28
28
 
@@ -42,7 +42,8 @@ module GitBumper
42
42
  end
43
43
 
44
44
  def prompt_yes
45
- STDIN.gets.chomp.to_s =~ /y(es)?/i
45
+ input = STDIN.gets.chomp.to_s
46
+ input.empty? || input =~ /\Ay(es)?\z/i
46
47
  end
47
48
 
48
49
  def greatest_tag
@@ -17,11 +17,14 @@ module GitBumper
17
17
 
18
18
  # Returns the greatest tag.
19
19
  def greatest_tag(prefix: 'v', klass: Tag)
20
- output = `git tag --list --sort=-v:refname "#{prefix}[0-9]*" 2> /dev/null`
20
+ output = `git tag --list 2> /dev/null`
21
21
 
22
- tags = output.split.collect do |tag|
23
- klass.parse(tag)
24
- end
22
+ tags = output
23
+ .split
24
+ .map { |t| klass.parse(t) }
25
+ .select { |t| t && t.prefix == prefix }
26
+ .sort
27
+ .reverse
25
28
 
26
29
  tags.find do |tag|
27
30
  tag
@@ -1,7 +1,7 @@
1
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.
2
+ # This object represents a common tag in the format
3
+ # PREFIX.MAJOR.MINOR.PATCH (e.g. v1.0.0, v2.1.3, v0.1.0).
4
+ # It provides some methods to parse, increment and compare tags.
5
5
  class Tag
6
6
  REGEX = /\A([a-z]+)([0-9]+)\.([0-9]+)\.([0-9]+)\z/i
7
7
 
@@ -50,5 +50,9 @@ module GitBumper
50
50
  @patch += 1
51
51
  end
52
52
  end
53
+
54
+ def <=>(other)
55
+ [major, minor, patch] <=> [other.major, other.minor, other.patch]
56
+ end
53
57
  end
54
58
  end
@@ -1,3 +1,3 @@
1
1
  module GitBumper
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_bumper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lenon Marcel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-13 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler