git_topic 0.3.3 → 0.4.0
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/.rubocop.yml +7 -0
- data/README.md +11 -9
- data/git_topic.gemspec +4 -0
- data/lib/git_topic/cli.rb +16 -10
- data/lib/git_topic/commands/edit.rb +4 -0
- data/lib/git_topic/commands/publish.rb +39 -0
- data/lib/git_topic/commands/start.rb +36 -0
- data/lib/git_topic/version.rb +1 -1
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85ccceb01e2ed1580b6873294edad47c16103d4
|
4
|
+
data.tar.gz: 31ceecaa343ac94ab05321d922fcce52f6375d76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cced3052b457682b50d13328492e6636d22c0ce7097846477f381d86816527d2642089165b7f1b5e41d6af91f2aa6c04736e66e18233ef259f66d28bfbb03acf
|
7
|
+
data.tar.gz: '07183227e39779cab39d55bed2d38e4bd8c130e00d4789c980939a7525c0d6b7673c8b4a57d52b7c10c90eb4df26ffcc8c9446c4fbee3b6b8613fe2c6e332cb6'
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -13,15 +13,17 @@ Install it yourself as:
|
|
13
13
|
## Usage
|
14
14
|
|
15
15
|
Commands:
|
16
|
-
git-topic [list] [-a]
|
17
|
-
git-topic edit [branch_name]
|
18
|
-
git-topic show [branch_name]
|
19
|
-
git-topic add topic_name
|
20
|
-
git-topic delete topic_name
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
+
git-topic start topic_name # Start the topic to branch to implement code
|
22
|
+
git-topic publish repo branch_name base # Create pull request using branch description
|
23
|
+
|
24
|
+
### Authentication (for publish command)
|
25
|
+
|
26
|
+
publish command uses netrc to authenticate github. Please refer [octokit Using a netrc section](https://github.com/octokit/octokit.rb#using-a-netrc-file).
|
25
27
|
|
26
28
|
## Development
|
27
29
|
|
data/git_topic.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('../lib', __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'git_topic/version'
|
@@ -25,6 +27,8 @@ DESC
|
|
25
27
|
|
26
28
|
spec.add_runtime_dependency 'thor', '~> 0.20.0'
|
27
29
|
spec.add_runtime_dependency 'term-ansicolor', '~> 1.6.0'
|
30
|
+
spec.add_runtime_dependency 'octokit', '~> 4.0'
|
31
|
+
spec.add_runtime_dependency 'netrc', '~> 0.11'
|
28
32
|
|
29
33
|
spec.add_development_dependency 'bundler', '~> 1.15'
|
30
34
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/lib/git_topic/cli.rb
CHANGED
@@ -9,6 +9,8 @@ require 'git_topic/commands/delete'
|
|
9
9
|
require 'git_topic/commands/edit'
|
10
10
|
require 'git_topic/commands/list'
|
11
11
|
require 'git_topic/commands/show'
|
12
|
+
require 'git_topic/commands/start'
|
13
|
+
require 'git_topic/commands/publish'
|
12
14
|
|
13
15
|
module GitTopic
|
14
16
|
# CLI command entry point
|
@@ -18,12 +20,12 @@ module GitTopic
|
|
18
20
|
desc 'list', 'Show managed topics'
|
19
21
|
option :version, aliases: 'v', desc: 'Show version'
|
20
22
|
option :all, aliases: 'a', desc: 'Show all information'
|
23
|
+
option :edit, aliases: 'e', desc: 'Edit current topic description'
|
21
24
|
def list
|
22
25
|
# Show version if -v specified
|
23
|
-
if options[:version]
|
24
|
-
|
25
|
-
|
26
|
-
end
|
26
|
+
version && return if options[:version]
|
27
|
+
# Edit topic if -e specified
|
28
|
+
edit && return if options[:edit]
|
27
29
|
|
28
30
|
command = GitTopic::Commands::List.new options
|
29
31
|
command.execute
|
@@ -44,6 +46,7 @@ module GitTopic
|
|
44
46
|
desc 'version', 'Show version'
|
45
47
|
def version
|
46
48
|
puts GitTopic::VERSION
|
49
|
+
true
|
47
50
|
end
|
48
51
|
|
49
52
|
desc 'add topic_name summary', 'Remember topic'
|
@@ -60,14 +63,17 @@ module GitTopic
|
|
60
63
|
|
61
64
|
desc 'start topic_name', 'Transfer topic_name to branch to implement code'
|
62
65
|
def start(topic_name)
|
63
|
-
|
64
|
-
|
66
|
+
command = GitTopic::Commands::Start.new topic_name
|
67
|
+
command.execute
|
65
68
|
end
|
66
69
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
# rubocop:disable Metrics/LineLength
|
71
|
+
desc 'publish repo base branch_name', 'Create pull request using branch description'
|
72
|
+
# rubocop:enable Metrics/LineLength
|
73
|
+
def publish(repo, base, branch_name)
|
74
|
+
client = Octokit::Client.new(netrc: true)
|
75
|
+
command = GitTopic::Commands::Publish.new client, repo, branch_name, base
|
76
|
+
command.execute
|
71
77
|
end
|
72
78
|
end
|
73
79
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'octokit'
|
4
|
+
|
5
|
+
module GitTopic
|
6
|
+
module Commands
|
7
|
+
# Publish command creates pull request from description.
|
8
|
+
class Publish
|
9
|
+
def initialize(client, repo, branch_name, base)
|
10
|
+
@client = client
|
11
|
+
@repo = repo
|
12
|
+
@branch_name = branch_name
|
13
|
+
@base = base
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
head = @branch_name
|
18
|
+
response = create_pull_request(@repo, @base, head)
|
19
|
+
puts response[:html_url]
|
20
|
+
rescue StandardError => ex
|
21
|
+
STDERR.puts ex.message
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def create_pull_request(repo, base, branch_name)
|
27
|
+
title = load_title(branch_name)
|
28
|
+
@client.create_pull_request(repo, base, branch_name, title)
|
29
|
+
end
|
30
|
+
|
31
|
+
def load_title(head)
|
32
|
+
config_key = "branch.#{head}.description"
|
33
|
+
command = "git config #{config_key}"
|
34
|
+
_stdin, stdout, _stderr, _wait_thr = *Open3.popen3(command)
|
35
|
+
stdout.readlines[0].chop
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GitTopic
|
4
|
+
module Commands
|
5
|
+
# this command starts topic to create branch
|
6
|
+
class Start
|
7
|
+
def initialize(topic_name)
|
8
|
+
@topic_name = topic_name
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
create_branch
|
13
|
+
summary = read_summary
|
14
|
+
summary_to_branch summary
|
15
|
+
puts "start `#{@topic_name}`"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def create_branch
|
21
|
+
command = "git checkout -b #{@topic_name}"
|
22
|
+
system(command)
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_summary
|
26
|
+
command = "git config --get topic.#{@topic_name}"
|
27
|
+
_stdin, stdout, _stderr, _wait_thr = *Open3.popen3(command)
|
28
|
+
stdout.readline
|
29
|
+
end
|
30
|
+
|
31
|
+
def summary_to_branch(summary)
|
32
|
+
system("git config --add branch.#{@topic_name}.description #{summary}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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.
|
4
|
+
version: 0.4.0
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.6.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: octokit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: netrc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.11'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.11'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bundler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,7 +184,9 @@ files:
|
|
156
184
|
- lib/git_topic/commands/delete.rb
|
157
185
|
- lib/git_topic/commands/edit.rb
|
158
186
|
- lib/git_topic/commands/list.rb
|
187
|
+
- lib/git_topic/commands/publish.rb
|
159
188
|
- lib/git_topic/commands/show.rb
|
189
|
+
- lib/git_topic/commands/start.rb
|
160
190
|
- lib/git_topic/formatter/branches.rb
|
161
191
|
- lib/git_topic/formatter/helper.rb
|
162
192
|
- lib/git_topic/formatter/topics.rb
|