git_topic 0.2.1 → 0.2.2

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
2
  SHA1:
3
- metadata.gz: a78e853f3748e22b11099cbb12d637596b6a073f
4
- data.tar.gz: c563916e2cb7f05401fb5d1b4f4f972cc6cc6562
3
+ metadata.gz: e8f1c24c1b4142264dc07264c30a643eaaa77143
4
+ data.tar.gz: 3ae34a090719fbabd42fa3b4627f1f0660fc34e7
5
5
  SHA512:
6
- metadata.gz: f5dab730cbd9a30b332ed22bd42d94dfec7f84a83357ef0838c7c8b4d5fe8d814c3d00a429959845e477548fb7f9469c29608fc74207c9f2587f4ede35bd061b
7
- data.tar.gz: f97b8a6b4b563e72481910d472d7d5e2db5c734253d0aec224add2455229995dad48fee49ebcda4dd3ac18586c66f0b0bdf79dcdc9ae3561be32bcaa25680359
6
+ metadata.gz: 1dc2315a42e587f02d70962282c431413c1fdc42327f8635bd93f9a9dfde77cc9f4b243837cee669125d7a0bbcbe9ac555a115bfb9e39d0f943afdfe2364d893
7
+ data.tar.gz: 59e5adeb6b5cee7fa5eb49d4db88f6d9594e6bffbdabf94d51e164f4ab6a3c67d96331ef49ecff022b922e782b986017080d06144160bff20f826d251298e328
data/README.md CHANGED
@@ -26,7 +26,7 @@ Install it yourself as:
26
26
 
27
27
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
28
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `OVERCOMMIT_DISABLED=1 bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
30
 
31
31
  ## Contributing
32
32
 
@@ -12,43 +12,55 @@ module GitTopic
12
12
 
13
13
  private
14
14
 
15
+ Branch = Struct.new('Branch', :name, :rev)
16
+
15
17
  def print_header
16
- printf " %-20s %s\n", 'Branch', 'Summary'
18
+ printf " %-20s %-7s %s\n", 'Branch', 'Rev', 'Summary'
17
19
  puts '-' * 80
18
20
  end
19
21
 
20
22
  def print_contents
21
- branches, current_branch = parse_branch
22
- branches.each do |branch_name|
23
+ branches, current_branch = parse_branches
24
+ branches.each do |branch|
23
25
  begin
24
- print_line(current_branch, branch_name)
26
+ print_line(current_branch, branch)
25
27
  rescue EOFError => _ex
26
28
  nop
27
29
  end
28
30
  end
29
31
  end
30
32
 
31
- def parse_branch
33
+ def parse_branches
32
34
  branches = []
33
35
  current_branch = nil
34
- _stdin, stdout, _stderr, _wait_thr = *Open3.popen3('git branch')
36
+ _stdin, stdout, _stderr, _wait_thr = *Open3.popen3('git branch -v')
35
37
  stdout.each do |line|
36
- matched = line.match(/\s*(\* )?(.*)/)
37
- next unless matched
38
- branches << branch_name = matched[2]
39
- current_branch = branch_name if matched[1]
38
+ branch_name, rev, current_branch = parse_branch(line)
39
+ branches << Branch.new(branch_name, rev)
40
40
  end
41
41
  [branches, current_branch]
42
42
  end
43
43
 
44
- def print_line(current_branch, branch_name)
44
+ def parse_branch(line)
45
+ matched = line.match(/\s*(\* )?(\S+)\s+(\S+)\s+(.*)/)
46
+ raise 'cannot parse branch' unless matched
47
+ branch_name = matched[2]
48
+ current_branch = nil
49
+ current_branch = branch_name if matched[1]
50
+ rev = matched[3]
51
+ [branch_name, rev, current_branch]
52
+ end
53
+
54
+ def print_line(current_branch, branch)
55
+ branch_name = branch.name
56
+ rev = branch.rev
45
57
  description = get_description_of branch_name
46
58
  branch_format = if branch_name == current_branch
47
59
  "* #{green}#{bold}%-20s#{clear}"
48
60
  else
49
61
  " #{bold}%-20s#{clear}"
50
62
  end
51
- printf "#{branch_format} %s", branch_name, description
63
+ printf "#{branch_format} %s %s", branch_name, rev, description
52
64
  end
53
65
 
54
66
  def get_description_of(branch)
@@ -1,3 +1,3 @@
1
1
  module GitTopic
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_topic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Kondo