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 +4 -4
- data/lib/get/commons/git.rb +10 -3
- data/lib/get/subcommand/changelog/changelog.rb +1 -1
- data/lib/get/subcommand/describe/describe.rb +12 -6
- data/lib/get/subcommand/tree/tree.rb +4 -0
- data/lib/get/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a06dde4facc3e0dff5fe756ae0d5bbc3b373a71ee79f2b677f8a088ee72bf60
|
4
|
+
data.tar.gz: b9f3883565a800112d61a67bc15ec348cce8e1914037ef68e1fe3b15704c0024
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 960f230cd4e90e82ad1ac61313d237071491eb7f1f7461ae7246d7e4af7c2f56d6c2b9731be61233b70df35bfd1fb87b4c5d12c710de21f967348ef351be5787
|
7
|
+
data.tar.gz: 996321047eff57ea6a066059659208c3ab6433686f125fbf5729b5c9f9574ff3320b38777b08daec98b5151a4863b367e7817eb3f4190c9d0f806ebb3128a07c
|
data/lib/get/commons/git.rb
CHANGED
@@ -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}"}
|
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 ||=
|
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 ||=
|
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
|
-
|
148
|
-
|
149
|
-
|
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
|
-
|
152
|
-
|
156
|
+
current_commit_version = next_release
|
157
|
+
create_signed_tag(current_commit_version) if @options[:create_tag]
|
153
158
|
|
154
|
-
|
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
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.
|
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-
|
11
|
+
date: 2023-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: optimist
|