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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1f5292c4e5a178415318180ff45bf3d5c5b55d0
4
- data.tar.gz: fd4e79d7c444a6f054e72da5c4b60ed3d2083a07
3
+ metadata.gz: 1baf0a34af6aca737041298f5329a0c0b3d4e345
4
+ data.tar.gz: 87b679a9b0b08b827353a9288e69c5984a36da84
5
5
  SHA512:
6
- metadata.gz: 147d88352b5b46ce3a801b81babc5415a52667d61d6fb3874ee612eb2e6d3ab85ae20be764222fe2487259559e2848585231b4d349a3ef6495d3eba7ccea1d6a
7
- data.tar.gz: 0a70933433daad90df9a75edc9abb7e75007724f7ab8aeacd147b8148d20fe06873af3e00f5fb3f137219cdcd617ed36f0ac0240635c1e4d5c098fa0f8a2745e
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
  ![Travis CI](https://travis-ci.org/kompiro/git_topic.svg?branch=master)
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] # Edit topic description
18
- git-topic show [branch_name] # Show topic description
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
- print_header(branches.first)
21
+ parse_length(branches)
22
+ print_header
22
23
  print_contents(branches, current_branch)
23
24
  end
24
25
 
25
- def print_header(branch)
26
- rev_length = branch.rev.length
27
- header_format = " %-20s %-#{rev_length}s %s"
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
- truncated_name = truncate(branch_name)
72
- puts format("#{branch_format} %s %s", truncated_name, rev, description)
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}%-20s#{clear}"
99
+ "* #{green}#{bold}%-#{@name_length}s#{clear}"
86
100
  else
87
- " #{bold}%-20s#{clear}"
101
+ " #{bold}%-#{@name_length}s#{clear}"
88
102
  end
89
103
  end
90
104
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitTopic
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.3'
5
5
  end
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.0
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-03 00:00:00.000000000 Z
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