git_topic 0.3.0 → 0.3.3
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/.ruby-version +1 -0
- data/README.md +7 -6
- data/lib/git_topic/cli.rb +9 -2
- data/lib/git_topic/commands/delete.rb +16 -0
- data/lib/git_topic/formatter/branches.rb +22 -8
- data/lib/git_topic/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1baf0a34af6aca737041298f5329a0c0b3d4e345
|
4
|
+
data.tar.gz: 87b679a9b0b08b827353a9288e69c5984a36da84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5973e1121b69e5dfb64ebb39bcfbff820c80e7b1e22ab067f515936c91b3894c4627c47293c4f0163f4782c5f87433497af5337ea0143e59e2211ce6d8c3e349
|
7
|
+
data.tar.gz: 3d6947e15e2a44e44b8d61f306a61594c3b8257483c44212d704602886179b3cc95a33ef69592555e20d05b6e9f4752528bfeaa86a6106122e41c9a69636fa8c
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# git_topic
|
1
|
+
# git_topic
|
2
2
|
|
3
3
|

|
4
4
|
|
@@ -13,12 +13,13 @@ Install it yourself as:
|
|
13
13
|
## Usage
|
14
14
|
|
15
15
|
Commands:
|
16
|
-
git-topic [list] # Show managed topics
|
17
|
-
git-topic edit [branch_name]
|
18
|
-
git-topic show [branch_name]
|
19
|
-
|
16
|
+
git-topic [list] [-a] # Show managed topics
|
17
|
+
git-topic edit [branch_name] # Edit topic description
|
18
|
+
git-topic show [branch_name] # Show topic description
|
19
|
+
git-topic add topic_name # Remember topic
|
20
|
+
git-topic delete topic_name # Delete topic
|
21
|
+
|
20
22
|
Plan to support:
|
21
|
-
git-topic add topic_name # Remember topic
|
22
23
|
git-topic start topic_name # Transfer topic_name to branch to implement code
|
23
24
|
git-topic publish [branch_name] # Create pull request using branch description
|
24
25
|
|
data/lib/git_topic/cli.rb
CHANGED
@@ -5,6 +5,7 @@ require 'open3'
|
|
5
5
|
|
6
6
|
require 'git_topic/version'
|
7
7
|
require 'git_topic/commands/add'
|
8
|
+
require 'git_topic/commands/delete'
|
8
9
|
require 'git_topic/commands/edit'
|
9
10
|
require 'git_topic/commands/list'
|
10
11
|
require 'git_topic/commands/show'
|
@@ -15,8 +16,8 @@ module GitTopic
|
|
15
16
|
default_command :list
|
16
17
|
|
17
18
|
desc 'list', 'Show managed topics'
|
18
|
-
option :version, aliases: 'v'
|
19
|
-
option :all, aliases: 'a'
|
19
|
+
option :version, aliases: 'v', desc: 'Show version'
|
20
|
+
option :all, aliases: 'a', desc: 'Show all information'
|
20
21
|
def list
|
21
22
|
# Show version if -v specified
|
22
23
|
if options[:version]
|
@@ -51,6 +52,12 @@ module GitTopic
|
|
51
52
|
command.execute
|
52
53
|
end
|
53
54
|
|
55
|
+
desc 'delete topic_name', 'Delete topic'
|
56
|
+
def delete(topic_name)
|
57
|
+
command = GitTopic::Commands::Delete.new topic_name
|
58
|
+
command.execute
|
59
|
+
end
|
60
|
+
|
54
61
|
desc 'start topic_name', 'Transfer topic_name to branch to implement code'
|
55
62
|
def start(topic_name)
|
56
63
|
puts "start #{topic_name}"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GitTopic
|
4
|
+
module Commands
|
5
|
+
# delete command deletes topic
|
6
|
+
class Delete
|
7
|
+
def initialize(topic_name)
|
8
|
+
@topic_name = topic_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
system("git config --unset topic.#{@topic_name}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -18,17 +18,31 @@ module GitTopic
|
|
18
18
|
def print
|
19
19
|
puts "#{bold}[Branches]#{clear}" if @all
|
20
20
|
branches, current_branch = parse_branches
|
21
|
-
|
21
|
+
parse_length(branches)
|
22
|
+
print_header
|
22
23
|
print_contents(branches, current_branch)
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
private
|
27
|
+
|
28
|
+
def print_header
|
29
|
+
header_format = " %-#{@name_length}s %-#{@rev_length}s %s"
|
28
30
|
puts format(header_format, :Branch, :Rev, :Summary)
|
29
31
|
puts '-' * 80
|
30
32
|
end
|
31
33
|
|
34
|
+
def parse_length(branches)
|
35
|
+
@name_length = name_length branches
|
36
|
+
@rev_length = branches.first.rev.length
|
37
|
+
end
|
38
|
+
|
39
|
+
NAME_LENGTH = 10
|
40
|
+
|
41
|
+
def name_length(branches)
|
42
|
+
longest_name_length = branches.map(&:name).map(&:length).max
|
43
|
+
longest_name_length > NAME_LENGTH ? longest_name_length : NAME_LENGTH
|
44
|
+
end
|
45
|
+
|
32
46
|
def print_contents(branches, current_branch)
|
33
47
|
branches.each do |branch|
|
34
48
|
print_line(current_branch, branch)
|
@@ -68,8 +82,8 @@ module GitTopic
|
|
68
82
|
description = get_description_of branch
|
69
83
|
return if description.nil?
|
70
84
|
branch_format = branch_format(branch_name, current_branch)
|
71
|
-
|
72
|
-
puts format("#{branch_format} %s %s",
|
85
|
+
truncated_desc = truncate(description, truncate_at: 80)
|
86
|
+
puts format("#{branch_format} %s %s", branch_name, rev, truncated_desc)
|
73
87
|
end
|
74
88
|
|
75
89
|
def get_description_of(branch)
|
@@ -82,9 +96,9 @@ module GitTopic
|
|
82
96
|
|
83
97
|
def branch_format(branch_name, current_branch)
|
84
98
|
if branch_name == current_branch
|
85
|
-
"* #{green}#{bold}
|
99
|
+
"* #{green}#{bold}%-#{@name_length}s#{clear}"
|
86
100
|
else
|
87
|
-
" #{bold}
|
101
|
+
" #{bold}%-#{@name_length}s#{clear}"
|
88
102
|
end
|
89
103
|
end
|
90
104
|
end
|
data/lib/git_topic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_topic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroki Kondo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- ".overcommit.yml"
|
137
137
|
- ".rspec"
|
138
138
|
- ".rubocop.yml"
|
139
|
+
- ".ruby-version"
|
139
140
|
- ".travis.yml"
|
140
141
|
- CODE_OF_CONDUCT.md
|
141
142
|
- Gemfile
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- lib/git_topic.rb
|
153
154
|
- lib/git_topic/cli.rb
|
154
155
|
- lib/git_topic/commands/add.rb
|
156
|
+
- lib/git_topic/commands/delete.rb
|
155
157
|
- lib/git_topic/commands/edit.rb
|
156
158
|
- lib/git_topic/commands/list.rb
|
157
159
|
- lib/git_topic/commands/show.rb
|