thicket 0.1.4 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 78d11e58027823d2bc19891269bdcf93c6b8d5ed8396cef5fe275f75282e27c9
4
- data.tar.gz: 99e6feb765c64cb6359b8014d26014812620d76185424695fa07103cf480c57f
2
+ SHA1:
3
+ metadata.gz: c541a3fa38a35509b3833a3f584359a661b34f2e
4
+ data.tar.gz: d4d781ec4b428b1e1f439bb807a1a91c3e0fe33d
5
5
  SHA512:
6
- metadata.gz: 99a311df3ab8cddbc14ac9d9d52f16a51762c9505f9eca6aae22a069eb486b351e6cdc45bc935a53e806bc83111f9daf8579ff8d4bad7561b3bd359529117143
7
- data.tar.gz: 4130465a692a997d098b30f776c7bfe46ed04bf1c53c93f927fb6c7066dd9569ce1eea4e32668f183570dd24d65627643f2883f900ba8b8ee3f9ba2848cfddae
6
+ metadata.gz: c782cf435c8eb5cf9b753982a2415403ed0c0b872b97f2fea9391e71d9e66bdb5936f2f72c21cd18b481707cfa15158499f9efa012c6bd006d8a60c5f23e1ddf
7
+ data.tar.gz: 6229ade1765ded8520550923aafa07046b94306b490a6747ff22604d036e5fbcdc600b4c8076305c0a9ab7c0c71838c197bfbe0c16d03b55e13e429b642d5a3f
data/lib/thicket/log.rb CHANGED
@@ -26,7 +26,7 @@ module Thicket
26
26
 
27
27
  puts "..."
28
28
  puts "Stopped after #{@options[:limit]} commits. More commit history exists."
29
- exit
29
+ break
30
30
  end
31
31
  rescue Errno::EPIPE, SystemExit, Interrupt
32
32
  exit
@@ -41,6 +41,7 @@ module Thicket
41
41
 
42
42
  line.match(LOG_PARSE_REGEX) do |matcher|
43
43
  line = process_date_time(matcher[1], line, matcher[3])
44
+ line = process_refs(matcher[3], line) if matcher[3] && @options[:consolidate_refs]
44
45
  line = process_message_prefix(matcher[4], line) if @options[:color_prefixes]
45
46
  line = process_author_name(matcher[2], line)
46
47
  @count_parsed += 1
@@ -61,6 +62,60 @@ module Thicket
61
62
  line.sub(time_string, to_sub)
62
63
  end
63
64
 
65
+ # Takes an input log string and a refs list, and formats the refs list in a
66
+ # more consolidated way.
67
+ def process_refs(refs, line)
68
+ original_refs = refs
69
+ main_remote = @options[:main_remote] || "origin"
70
+ refs = strip_color(refs).split(",").map(&:strip)
71
+ tags = []
72
+
73
+ head_ref_index = refs.find_index { |r| r.start_with?("HEAD -> ") }
74
+
75
+ refs_to_delete = []
76
+ refs.each do |r|
77
+ refs_to_delete << r if r == "#{main_remote}/HEAD"
78
+ next if r.start_with?("#{main_remote}/")
79
+
80
+ ref_without_head = r.delete("HEAD -> ")
81
+ branch = "#{main_remote}/#{ref_without_head}"
82
+ if refs.include?(branch)
83
+ refs_to_delete << branch
84
+ r << "#"
85
+ end
86
+
87
+ if r.start_with?("tag:")
88
+ tag = r
89
+ tag.slice!("tag: ")
90
+
91
+ refs_to_delete << r
92
+ tags << tag
93
+ end
94
+ end
95
+
96
+ refs[head_ref_index].sub!("HEAD -> ", "@") if head_ref_index
97
+ refs.delete_if { |r| refs_to_delete.include? r }
98
+
99
+ refs = if refs.any?
100
+ "(#{refs.join(", ")})"
101
+ else
102
+ ""
103
+ end
104
+
105
+ substitute = if tags.any?
106
+ tags = "\e[35m[#{tags.join(", ")}]\e[0m"
107
+ if refs.empty?
108
+ tags
109
+ else
110
+ "#{refs} #{tags}"
111
+ end
112
+ else
113
+ refs
114
+ end
115
+
116
+ line.sub("(#{original_refs})", substitute)
117
+ end
118
+
64
119
  # Takes an input log string and commit message, finds commit messages
65
120
  # prefixes, and darkens them.
66
121
  def process_message_prefix(message, line)
@@ -19,7 +19,7 @@ module Thicket
19
19
  args = Options.new("world")
20
20
 
21
21
  opt_parser = ::OptionParser.new do |opts|
22
- opts.banner = "Usage: thicket [options] <command>"
22
+ opts.banner = "Usage: thicket [options]"
23
23
 
24
24
  opts.on("-v", "--version", "Print the version number") do |v|
25
25
  args.name = v
@@ -42,11 +42,21 @@ module Thicket
42
42
  @options[:limit] = limit
43
43
  end
44
44
 
45
- opts.on("-a", "--all", TrueClass, "Displays all branches on all remotes.") do |all|
45
+ opts.on("-a", "--all", TrueClass, "Displays all branches on all remotes") do |all|
46
46
  args.name = all
47
47
  @options[:all] = all
48
48
  end
49
49
 
50
+ opts.on("-r", "--refs", TrueClass, "Consolidate the refs list") do |refs|
51
+ args.name = refs
52
+ @options[:consolidate_refs] = refs
53
+ end
54
+
55
+ opts.on("--main-remote=MAIN_REMOTE", String, "The name of the primary remote, defaults to 'origin'") do |main_remote|
56
+ args.name = main_remote
57
+ @options[:main_remote] = main_remote
58
+ end
59
+
50
60
  opts.on("-p", "--color-prefixes", TrueClass, "Adds coloring to commit message prefixes.") do |prefixes|
51
61
  args.name = prefixes
52
62
  @options[:color_prefixes] = prefixes
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Thicket
4
4
  #:nodoc:
5
- VERSION ||= "0.1.4"
5
+ VERSION ||= "0.1.6"
6
6
  end
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thicket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Thurlow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-27 00:00:00.000000000 Z
11
+ date: 2019-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: as-duration
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: factory_bot
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faker
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  - !ruby/object:Gem::Dependency
14
56
  name: guard
15
57
  requirement: !ruby/object:Gem::Requirement
@@ -143,7 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
185
  - !ruby/object:Gem::Version
144
186
  version: '0'
145
187
  requirements: []
146
- rubygems_version: 3.0.3
188
+ rubyforge_project:
189
+ rubygems_version: 2.5.2.3
147
190
  signing_key:
148
191
  specification_version: 4
149
192
  summary: An opinionated replacement for git's log command.