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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b8ebebddfff4a1580ff80b555e1604ebbbd6844
4
- data.tar.gz: e14113d4db63b088c94ae74f8c22969b778ffa91
3
+ metadata.gz: 26e6c4b2966c8c93bbfabdcdcdd31972822ddb19
4
+ data.tar.gz: 31bd0e906eb426836f1fc912bc8e4b63b1f8d94c
5
5
  SHA512:
6
- metadata.gz: b5b8165f6462cc767cc77d5c3380f825ff7b0c57636d9ae193336a6509a65da2056c66a89bc81e6b5d2b5e7dcba6ee98f2afb055779033330ef64b59b8d9456a
7
- data.tar.gz: 74f65ee2ed758d85f64647e5c9d69c61069d03b5f96db5c750886e7a364ed3a8feb90417ac6a6e5c193b8fce9105fc9f7700b61e6a17a6c48e9c5746c5bb580f
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-02'
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).'
@@ -45,7 +45,7 @@ module Geet
45
45
  # params:
46
46
  # users: String, or Array of strings.
47
47
  #
48
- def assign_user(users)
48
+ def assign_users(users)
49
49
  request_data = { assignees: Array(users) }
50
50
  request_address = "#{@api_helper.api_repo_link}/issues/#{@issue_number}/assignees"
51
51
 
@@ -13,51 +13,84 @@ module Geet
13
13
  # :assignee_patterns
14
14
  # :no_open_issue
15
15
  #
16
- def execute(repository, title, description, options = {})
17
- if options[:label_patterns]
18
- puts 'Finding labels...'
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
- all_labels = repository.labels
21
- selected_labels = select_entries(all_labels, options[:label_patterns], type: 'labels')
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
- if options[:assignee_patterns]
25
- puts 'Finding collaborators...'
35
+ add_labels_thread&.join
36
+ assign_users_thread.join
26
37
 
27
- all_collaborators = repository.collaborators
28
- assignees = select_entries(all_collaborators, options[:assignee_patterns], type: 'collaborators')
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
- puts 'Creating the issue...'
45
+ private
32
46
 
33
- issue = repository.create_issue(title, description)
47
+ # Internal actions
34
48
 
35
- if selected_labels
36
- puts 'Adding labels...'
49
+ def select_labels(repository, label_patterns)
50
+ puts 'Finding labels...'
37
51
 
38
- issue.add_labels(selected_labels)
52
+ Thread.new do
53
+ all_labels = repository.labels
39
54
 
40
- puts '- labels added: ' + selected_labels.join(', ')
55
+ select_entries(all_labels, label_patterns, type: 'labels')
41
56
  end
57
+ end
42
58
 
43
- if assignees
44
- puts 'Assigning users...'
59
+ def select_assignees(repository, assignee_patterns)
60
+ puts 'Finding collaborators...'
45
61
 
46
- issue.assign_user(assignees)
62
+ Thread.new do
63
+ all_collaborators = repository.collaborators
47
64
 
48
- puts '- assigned: ' + assignees.join(', ')
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
- if options[:no_open_issue]
54
- puts "Issue address: #{issue.link}"
55
- else
56
- os_open(issue.link)
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
- private
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, options = {})
17
- if options[:label_patterns]
18
- puts 'Finding labels...'
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
- selected_labels = select_entries(all_labels, options[:label_patterns], type: 'labels')
51
+
52
+ select_entries(all_labels, label_patterns, type: 'labels')
22
53
  end
54
+ end
23
55
 
24
- if options[:reviewer_patterns]
25
- puts 'Finding collaborators...'
56
+ def select_reviewers(repository, reviewer_patterns)
57
+ puts 'Finding collaborators...'
26
58
 
59
+ Thread.new do
27
60
  all_collaborators = repository.collaborators
28
- reviewers = select_entries(all_collaborators, options[:reviewer_patterns], type: 'collaborators')
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
- pr.assign_user(repository.authenticated_user)
75
+ Thread.new do
76
+ pr.assign_users(repository.authenticated_user)
77
+ end
78
+ end
38
79
 
39
- if selected_labels
40
- puts 'Adding labels...'
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
- if reviewers
48
- puts 'Requesting review...'
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
- private
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Geet
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
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.6
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-02 00:00:00.000000000 Z
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.5.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