geet 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/geet.gemspec +1 -1
- data/lib/geet/git_hub/abstract_issue.rb +1 -1
- data/lib/geet/services/create_issue.rb +59 -26
- data/lib/geet/services/create_pr.rb +57 -23
- data/lib/geet/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26e6c4b2966c8c93bbfabdcdcdd31972822ddb19
|
4
|
+
data.tar.gz: 31bd0e906eb426836f1fc912bc8e4b63b1f8d94c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 763f77f17b6cdd5b97fe0547f645943c3d0f360598435a96b2de2e01ed4c576d1c2a1110195b1de04e43496d89fd986105cbbac53f56c393ee60533efafb1fab
|
7
|
+
data.tar.gz: 198ba0c2c055ab1269bc3d14d2d4d2f63c26970359cca5b18e80cc790e000cfa2b973285dd5484e0cecb9ac4e1ddf8d139ea07c31cee231c2bda3000fa736623
|
data/geet.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.platform = Gem::Platform::RUBY
|
12
12
|
s.required_ruby_version = '>= 2.2.0'
|
13
13
|
s.authors = ['Saverio Miroddi']
|
14
|
-
s.date = '2017-11-
|
14
|
+
s.date = '2017-11-06'
|
15
15
|
s.email = ['saverio.pub2@gmail.com']
|
16
16
|
s.homepage = 'https://github.com/saveriomiroddi/geet'
|
17
17
|
s.summary = 'Commandline interface for performing SCM (eg. GitHub) operations (eg. PR creation).'
|
@@ -13,51 +13,84 @@ module Geet
|
|
13
13
|
# :assignee_patterns
|
14
14
|
# :no_open_issue
|
15
15
|
#
|
16
|
-
def execute(repository, title, description,
|
17
|
-
if
|
18
|
-
|
16
|
+
def execute(repository, title, description, label_patterns: nil, assignee_patterns: nil, no_open_issue: nil, **)
|
17
|
+
labels_thread = select_labels(repository, label_patterns) if label_patterns
|
18
|
+
assignees_thread = select_assignees(repository, assignee_patterns) if assignee_patterns
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
selected_labels = labels_thread&.join&.value
|
21
|
+
assignees = assignees_thread&.join&.value
|
22
|
+
|
23
|
+
puts 'Creating the issue...'
|
24
|
+
|
25
|
+
issue = repository.create_issue(title, description)
|
26
|
+
|
27
|
+
add_labels_thread = add_labels(issue, selected_labels) if selected_labels
|
28
|
+
|
29
|
+
if assignees
|
30
|
+
assign_users_thread = assign_users(issue, assignees)
|
31
|
+
else
|
32
|
+
assign_users_thread = assign_authenticated_user(repository, issue)
|
22
33
|
end
|
23
34
|
|
24
|
-
|
25
|
-
|
35
|
+
add_labels_thread&.join
|
36
|
+
assign_users_thread.join
|
26
37
|
|
27
|
-
|
28
|
-
|
38
|
+
if no_open_issue
|
39
|
+
puts "Issue address: #{issue.link}"
|
40
|
+
else
|
41
|
+
os_open(issue.link)
|
29
42
|
end
|
43
|
+
end
|
30
44
|
|
31
|
-
|
45
|
+
private
|
32
46
|
|
33
|
-
|
47
|
+
# Internal actions
|
34
48
|
|
35
|
-
|
36
|
-
|
49
|
+
def select_labels(repository, label_patterns)
|
50
|
+
puts 'Finding labels...'
|
37
51
|
|
38
|
-
|
52
|
+
Thread.new do
|
53
|
+
all_labels = repository.labels
|
39
54
|
|
40
|
-
|
55
|
+
select_entries(all_labels, label_patterns, type: 'labels')
|
41
56
|
end
|
57
|
+
end
|
42
58
|
|
43
|
-
|
44
|
-
|
59
|
+
def select_assignees(repository, assignee_patterns)
|
60
|
+
puts 'Finding collaborators...'
|
45
61
|
|
46
|
-
|
62
|
+
Thread.new do
|
63
|
+
all_collaborators = repository.collaborators
|
47
64
|
|
48
|
-
|
49
|
-
else
|
50
|
-
issue.assign_user(repository.authenticated_user)
|
65
|
+
select_entries(all_collaborators, assignee_patterns, type: 'collaborators')
|
51
66
|
end
|
67
|
+
end
|
52
68
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
69
|
+
def add_labels(issue, selected_labels)
|
70
|
+
puts "Adding labels #{selected_labels.join(', ')}..."
|
71
|
+
|
72
|
+
Thread.new do
|
73
|
+
issue.add_labels(selected_labels)
|
57
74
|
end
|
58
75
|
end
|
59
76
|
|
60
|
-
|
77
|
+
def assign_users(issue, users)
|
78
|
+
puts "Assigning users #{users.join(', ')}..."
|
79
|
+
|
80
|
+
Thread.new do
|
81
|
+
issue.assign_users(users)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def assign_authenticated_user(repository, issue)
|
86
|
+
puts 'Assigning authenticated user...'
|
87
|
+
|
88
|
+
Thread.new do
|
89
|
+
issue.assign_users(repository.authenticated_user)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Generic helpers
|
61
94
|
|
62
95
|
def select_entries(entries, raw_patterns, type: 'entries')
|
63
96
|
patterns = raw_patterns.split(',')
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require_relative '../helpers/os_helper.rb'
|
4
4
|
require_relative '../git/repository.rb'
|
5
5
|
|
6
|
+
require 'thread'
|
7
|
+
|
6
8
|
module Geet
|
7
9
|
module Services
|
8
10
|
class CreatePr
|
@@ -13,53 +15,85 @@ module Geet
|
|
13
15
|
# :reviewer_patterns
|
14
16
|
# :no_open_pr
|
15
17
|
#
|
16
|
-
def execute(repository, title, description,
|
17
|
-
if
|
18
|
-
|
18
|
+
def execute(repository, title, description, label_patterns: nil, reviewer_patterns: nil, no_open_pr: nil, **)
|
19
|
+
labels_thread = select_labels(repository, label_patterns) if label_patterns
|
20
|
+
reviewers_thread = select_reviewers(repository, reviewer_patterns) if reviewer_patterns
|
21
|
+
|
22
|
+
selected_labels = selected_labels&.join&.value
|
23
|
+
reviewers = reviewers_thread&.join&.value
|
24
|
+
|
25
|
+
pr = create_pr(repository, title, description)
|
26
|
+
|
27
|
+
assign_user_thread = assign_authenticated_user(pr, repository)
|
28
|
+
add_labels_thread = add_labels(pr, selected_labels) if selected_labels
|
29
|
+
request_review_thread = request_review(pr, reviewers) if reviewers
|
30
|
+
|
31
|
+
assign_user_thread.join
|
32
|
+
add_labels_thread&.join
|
33
|
+
request_review_thread&.join
|
34
|
+
|
35
|
+
if no_open_pr
|
36
|
+
puts "PR address: #{pr.link}"
|
37
|
+
else
|
38
|
+
os_open(pr.link)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
# Internal actions
|
19
45
|
|
46
|
+
def select_labels(repository, label_patterns)
|
47
|
+
puts 'Finding labels...'
|
48
|
+
|
49
|
+
Thread.new do
|
20
50
|
all_labels = repository.labels
|
21
|
-
|
51
|
+
|
52
|
+
select_entries(all_labels, label_patterns, type: 'labels')
|
22
53
|
end
|
54
|
+
end
|
23
55
|
|
24
|
-
|
25
|
-
|
56
|
+
def select_reviewers(repository, reviewer_patterns)
|
57
|
+
puts 'Finding collaborators...'
|
26
58
|
|
59
|
+
Thread.new do
|
27
60
|
all_collaborators = repository.collaborators
|
28
|
-
|
61
|
+
|
62
|
+
select_entries(all_collaborators, reviewer_patterns, type: 'collaborators')
|
29
63
|
end
|
64
|
+
end
|
30
65
|
|
66
|
+
def create_pr(repository, title, description)
|
31
67
|
puts 'Creating PR...'
|
32
68
|
|
33
69
|
pr = repository.create_pr(title, description, repository.current_head)
|
70
|
+
end
|
34
71
|
|
72
|
+
def assign_authenticated_user(pr, repository)
|
35
73
|
puts 'Assigning authenticated user...'
|
36
74
|
|
37
|
-
|
75
|
+
Thread.new do
|
76
|
+
pr.assign_users(repository.authenticated_user)
|
77
|
+
end
|
78
|
+
end
|
38
79
|
|
39
|
-
|
40
|
-
|
80
|
+
def add_labels(pr, selected_labels)
|
81
|
+
puts "Adding labels #{selected_labels.join(', ')}..."
|
41
82
|
|
83
|
+
Thread.new do
|
42
84
|
pr.add_labels(selected_labels)
|
43
|
-
|
44
|
-
puts '- labels added: ' + selected_labels.join(', ')
|
45
85
|
end
|
86
|
+
end
|
46
87
|
|
47
|
-
|
48
|
-
|
88
|
+
def request_review(pr, reviewers)
|
89
|
+
puts "Requesting review from #{reviewers.join(', ')}..."
|
49
90
|
|
91
|
+
Thread.new do
|
50
92
|
pr.request_review(reviewers)
|
51
|
-
|
52
|
-
puts '- review requested to: ' + reviewers.join(', ')
|
53
|
-
end
|
54
|
-
|
55
|
-
if options[:no_open_pr]
|
56
|
-
puts "PR address: #{pr.link}"
|
57
|
-
else
|
58
|
-
os_open(pr.link)
|
59
93
|
end
|
60
94
|
end
|
61
95
|
|
62
|
-
|
96
|
+
# Generic helpers
|
63
97
|
|
64
98
|
def select_entries(entries, raw_patterns, type: 'entries')
|
65
99
|
patterns = raw_patterns.split(',')
|
data/lib/geet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saverio Miroddi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_scripting
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
81
|
+
rubygems_version: 2.6.13
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Commandline interface for performing SCM (eg. GitHub) operations (eg. PR
|