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 +4 -4
- data/README.md +1 -1
- data/lib/git_topic/commands/list.rb +24 -12
- data/lib/git_topic/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8f1c24c1b4142264dc07264c30a643eaaa77143
|
4
|
+
data.tar.gz: 3ae34a090719fbabd42fa3b4627f1f0660fc34e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
22
|
-
branches.each do |
|
23
|
+
branches, current_branch = parse_branches
|
24
|
+
branches.each do |branch|
|
23
25
|
begin
|
24
|
-
print_line(current_branch,
|
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
|
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
|
-
|
37
|
-
|
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
|
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)
|
data/lib/git_topic/version.rb
CHANGED