git_toolbox 0.7.1 → 0.7.2

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
  SHA256:
3
- metadata.gz: a9a83558777ee286d804e64a714388d13b4ac16e15e724580f7957ea422ba8a2
4
- data.tar.gz: 8e76c6784c12e03f9cab918099a219e5e823441b90356c68b4cabc8e0bcf13fe
3
+ metadata.gz: 8a06dde4facc3e0dff5fe756ae0d5bbc3b373a71ee79f2b677f8a088ee72bf60
4
+ data.tar.gz: b9f3883565a800112d61a67bc15ec348cce8e1914037ef68e1fe3b15704c0024
5
5
  SHA512:
6
- metadata.gz: 89d357ca5cf79577e6a05e3d5aff6dccb227c593565d8c5fe7d634d7a76b2cbe568a3c3db6cc49c58d0edfe4418d5da99f39fb1c944dfd14e2267dcb35d3a5bf
7
- data.tar.gz: d5a06e808f81790b745ddf2ca031d6ca9c318e13c563aa78262488ec32ab8b98fca0b5d089b5f97b1ae321e76ca3825cd4018248b791490f85fb4c78dfaf1080
6
+ metadata.gz: 960f230cd4e90e82ad1ac61313d237071491eb7f1f7461ae7246d7e4af7c2f56d6c2b9731be61233b70df35bfd1fb87b4c5d12c710de21f967348ef351be5787
7
+ data.tar.gz: 996321047eff57ea6a066059659208c3ab6433686f125fbf5729b5c9f9574ff3320b38777b08daec98b5151a4863b367e7817eb3f4190c9d0f806ebb3128a07c
@@ -42,18 +42,25 @@ module Git
42
42
  return unless block_given?
43
43
 
44
44
  commits_from_version =
45
- `git --no-pager log --oneline --pretty=format:%s #{version.nil? ? '' : "^#{version}"} HEAD`
45
+ `git --no-pager log --oneline --pretty=format:%s #{version.nil? ? '' : "^#{version} HEAD"} 2>/dev/null`
46
46
  .split("\n")
47
+ .then { |value| $CHILD_STATUS.exitstatus.zero? ? value : [] }
47
48
  block.call(commits_from_version)
48
49
  end
49
50
 
50
51
  # Returns the last version and caches it for the next calls.
51
52
  def self.last_version
52
- @@last_version ||= `git describe --tags --abbrev=0`.strip
53
+ @@last_version ||=
54
+ `git describe --tags --abbrev=0 2>/dev/null`
55
+ .strip
56
+ .then { |value| value if $CHILD_STATUS.exitstatus.zero? }
53
57
  end
54
58
 
55
59
  # Returns the last release and caches it for the next calls.
56
60
  def self.last_release
57
- @@last_release ||= `git --no-pager tag --list | sed 's/+/_/' | sort -V | sed 's/_/+/' | tail -n 1`.strip
61
+ @@last_release ||=
62
+ `git --no-pager tag --list | sed 's/+/_/' | sort -V | sed 's/_/+/' | tail -n 1`
63
+ .strip
64
+ .then { |value| value unless value.empty? }
58
65
  end
59
66
  end
@@ -139,7 +139,7 @@ class Changelog < Command
139
139
  formatted_types = []
140
140
  changelog.except('feat', 'fix').each { |key, value| formatted_types.push(format_type(key, value)) }
141
141
  <<~CHANGELOG
142
- #{@format[:title].sub('%s', "Changelog from version #{from_version}")}
142
+ #{@format[:title].sub('%s', "Changelog from #{from_version.nil? ? 'first commit' : "version #{from_version}"}")}
143
143
  #{(formatted_features + formatted_fixes + formatted_types).join("\n").strip}
144
144
  CHANGELOG
145
145
  end
@@ -144,14 +144,20 @@ class Describe < Command
144
144
  end
145
145
 
146
146
  def describe_current_commit
147
- return Git.last_version if Git.with_commit_list_from(Git.last_version, &:empty?)
148
-
149
- puts "Last version: #{Git.last_version}" if @options[:diff]
147
+ if Git.with_commit_list_from(Git.last_version, &:empty?)
148
+ if Git.last_version.nil?
149
+ Common.error('Cannot describe an empty repository.')
150
+ else
151
+ Git.last_version
152
+ end
153
+ else
154
+ puts "Last version: #{Git.last_version}" if @options[:diff]
150
155
 
151
- current_commit_version = next_release
152
- create_signed_tag(current_commit_version) if @options[:create_tag]
156
+ current_commit_version = next_release
157
+ create_signed_tag(current_commit_version) if @options[:create_tag]
153
158
 
154
- current_commit_version
159
+ current_commit_version
160
+ end
155
161
  end
156
162
 
157
163
  def next_release
@@ -80,7 +80,10 @@ class Tree < Command
80
80
  TIME_REGEX = /(\([a-z0-9 ,]+\))/
81
81
  TIME_MINIMUM_PADDING = 2
82
82
 
83
+ # rubocop:disable Metrics/MethodLength
83
84
  def transform_log(text)
85
+ return 'This repository has no commit.' if text.empty?
86
+
84
87
  split_lines = text.split("\n").map { |element| element.split('§') }
85
88
  # The first line is always a commit line, so it always have a time reference
86
89
  first_line_time = split_lines.first[1]
@@ -110,6 +113,7 @@ class Tree < Command
110
113
  end
111
114
  .join("\n")
112
115
  end
116
+ # rubocop:enable Metrics/MethodLength
113
117
 
114
118
  def page_log(text)
115
119
  system("less -RfS <(echo -e '#{text}')")
data/lib/get/version.rb CHANGED
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module Get
21
- VERSION = '0.7.1'
21
+ VERSION = '0.7.2'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Speranza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-18 00:00:00.000000000 Z
11
+ date: 2023-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: optimist