geet 0.9.0 → 0.12.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/geet.gemspec +1 -1
- data/lib/geet/commandline/configuration.rb +4 -4
- data/lib/geet/services/comment_pr.rb +1 -1
- data/lib/geet/services/create_pr.rb +3 -14
- data/lib/geet/version.rb +1 -1
- data/spec/integration/create_pr_spec.rb +61 -59
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4f8d85a0f499afb70bb5a01c5e22664f70fbbc942a42109006bd725a314c8b7
|
4
|
+
data.tar.gz: 8b56dc95ce11072b21f4154b39dad49680fcd4f0601dd44bd4e407b7811b9df7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a6126ddc595b50dc9391c547533149d5c67496c1046f61e3173022c5ac143d71e51a0a4ca3c78344917cd2eab6549ca9d080c9d09258ab4c57092cd10db806a
|
7
|
+
data.tar.gz: 3a374c0aca85a391457e519caa0be56cc25ab2322f98ed81250792d4ea817865d72b57cc10ef45d09d699f54d1e55231e2ae4677cacc681d4ec8fc255835f9d2
|
data/geet.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.required_ruby_version = '>= 2.3.0'
|
12
12
|
s.authors = ['Saverio Miroddi']
|
13
|
-
s.date = '2022-
|
13
|
+
s.date = '2022-08-07'
|
14
14
|
s.email = ['saverio.pub2@gmail.com']
|
15
15
|
s.homepage = 'https://github.com/saveriomiroddi/geet'
|
16
16
|
s.summary = 'Commandline interface for performing SCM host operations, eg. create a PR on GitHub'
|
@@ -60,12 +60,12 @@ module Geet
|
|
60
60
|
|
61
61
|
PR_COMMENT_OPTIONS = [
|
62
62
|
['-n', '--no-open-pr', "Don't open the PR link in the browser after creation"],
|
63
|
+
['-u', '--upstream', 'Comment on the upstream repository'],
|
63
64
|
'comment',
|
64
65
|
long_help: 'Add a comment to the PR for the current branch.'
|
65
66
|
]
|
66
67
|
|
67
68
|
PR_CREATE_OPTIONS = [
|
68
|
-
['-A', '--automated-mode', "Automate the branch operations (see long help)"],
|
69
69
|
['-n', '--no-open-pr', "Don't open the PR link in the browser after creation"],
|
70
70
|
['-b', '--base develop', "Specify the base branch; defaults to the main branch"],
|
71
71
|
['-d', '--draft', "Create as draft"],
|
@@ -77,9 +77,9 @@ module Geet
|
|
77
77
|
long_help: <<~STR
|
78
78
|
The default editor will be opened for editing title and description; if the PR adds one commit only, the content will be prepopulated with the commit description.
|
79
79
|
|
80
|
-
The
|
81
|
-
|
82
|
-
|
80
|
+
The operation is aborted if the current tree is dirty.
|
81
|
+
|
82
|
+
Before creating the PR, the local branch is pushed; if the remote branch is not present, it is created.
|
83
83
|
STR
|
84
84
|
]
|
85
85
|
|
@@ -28,9 +28,9 @@ module Geet
|
|
28
28
|
#
|
29
29
|
def execute(
|
30
30
|
title, description, labels: nil, milestone: nil, reviewers: nil,
|
31
|
-
base: nil, draft: false, no_open_pr: nil,
|
31
|
+
base: nil, draft: false, no_open_pr: nil, **
|
32
32
|
)
|
33
|
-
ensure_clean_tree
|
33
|
+
ensure_clean_tree
|
34
34
|
|
35
35
|
if @repository.upstream? && !@git_client.remote_defined?(Utils::GitClient::UPSTREAM_NAME)
|
36
36
|
@out.puts "Upstream not found; adding it to the repository remotes..."
|
@@ -46,7 +46,7 @@ module Geet
|
|
46
46
|
selected_labels, selected_milestone, selected_reviewers = find_and_select_attributes(labels, milestone, reviewers)
|
47
47
|
end
|
48
48
|
|
49
|
-
sync_with_remote_branch
|
49
|
+
sync_with_remote_branch
|
50
50
|
|
51
51
|
pr = create_pr(title, description, base: base, draft: draft)
|
52
52
|
|
@@ -136,28 +136,17 @@ module Geet
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def edit_pr(pr, labels, milestone, reviewers)
|
139
|
-
assign_user_thread = assign_authenticated_user(pr)
|
140
|
-
|
141
139
|
# labels/reviewers can be nil (parameter not passed) or empty array (parameter passed, but
|
142
140
|
# nothing selected)
|
143
141
|
add_labels_thread = add_labels(pr, labels) if labels && !labels.empty?
|
144
142
|
set_milestone_thread = set_milestone(pr, milestone) if milestone
|
145
143
|
request_review_thread = request_review(pr, reviewers) if reviewers && !reviewers.empty?
|
146
144
|
|
147
|
-
assign_user_thread.join
|
148
145
|
add_labels_thread&.join
|
149
146
|
set_milestone_thread&.join
|
150
147
|
request_review_thread&.join
|
151
148
|
end
|
152
149
|
|
153
|
-
def assign_authenticated_user(pr)
|
154
|
-
@out.puts 'Assigning authenticated user...'
|
155
|
-
|
156
|
-
Thread.new do
|
157
|
-
pr.assign_users(@repository.authenticated_user.username)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
150
|
def add_labels(pr, selected_labels)
|
162
151
|
labels_list = selected_labels.map(&:name).join(', ')
|
163
152
|
|
data/lib/geet/version.rb
CHANGED
@@ -12,40 +12,41 @@ describe Geet::Services::CreatePr do
|
|
12
12
|
|
13
13
|
context 'with github.com' do
|
14
14
|
context 'with labels, reviewers and milestones' do
|
15
|
-
it 'should create a PR'
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
15
|
+
it 'should create a PR'
|
16
|
+
# do
|
17
|
+
# allow(git_client).to receive(:current_branch).and_return('mybranch')
|
18
|
+
# allow(git_client).to receive(:main_branch).and_return('master')
|
19
|
+
# allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
20
|
+
#
|
21
|
+
# expected_output = <<~STR
|
22
|
+
# Finding labels...
|
23
|
+
# Finding milestones...
|
24
|
+
# Finding collaborators...
|
25
|
+
# Creating PR...
|
26
|
+
# Assigning authenticated user...
|
27
|
+
# Adding labels bug, invalid...
|
28
|
+
# Setting milestone 0.0.1...
|
29
|
+
# Requesting review from donald-fr...
|
30
|
+
# PR address: https://github.com/donaldduck/testrepo_f/pull/1
|
31
|
+
# STR
|
32
|
+
#
|
33
|
+
# actual_output = StringIO.new
|
34
|
+
#
|
35
|
+
# actual_created_pr = VCR.use_cassette('github_com/create_pr') do
|
36
|
+
# service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
|
37
|
+
# service_instance.execute(
|
38
|
+
# 'Title', 'Description',
|
39
|
+
# labels: 'bug,invalid', milestone: '0.0.1', reviewers: 'donald-fr',
|
40
|
+
# no_open_pr: true, output: actual_output
|
41
|
+
# )
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# expect(actual_output.string).to eql(expected_output)
|
45
|
+
#
|
46
|
+
# expect(actual_created_pr.number).to eql(1)
|
47
|
+
# expect(actual_created_pr.title).to eql('Title')
|
48
|
+
# expect(actual_created_pr.link).to eql('https://github.com/donaldduck/testrepo_f/pull/1')
|
49
|
+
# end
|
49
50
|
end
|
50
51
|
|
51
52
|
context 'on an upstream repository' do
|
@@ -157,31 +158,32 @@ describe Geet::Services::CreatePr do
|
|
157
158
|
# expect(actual_output.string).to eql(expected_output)
|
158
159
|
# end
|
159
160
|
|
160
|
-
it "should create a remote branch, when there isn't one (is not tracked)"
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
161
|
+
it "should create a remote branch, when there isn't one (is not tracked)"
|
162
|
+
# do
|
163
|
+
# allow(git_client).to receive(:working_tree_clean?).and_return(true)
|
164
|
+
# allow(git_client).to receive(:current_branch).and_return('mybranch')
|
165
|
+
# allow(git_client).to receive(:main_branch).and_return('master')
|
166
|
+
# expect(git_client).to receive(:remote_branch).and_return(nil)
|
167
|
+
# expect(git_client).to receive(:push).with(remote_branch: 'mybranch')
|
168
|
+
#
|
169
|
+
# allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
170
|
+
#
|
171
|
+
# expected_output = <<~STR
|
172
|
+
# Creating remote branch "mybranch"...
|
173
|
+
# Creating PR...
|
174
|
+
# Assigning authenticated user...
|
175
|
+
# PR address: https://github.com/donaldduck/testrepo_f/pull/4
|
176
|
+
# STR
|
177
|
+
#
|
178
|
+
# actual_output = StringIO.new
|
179
|
+
#
|
180
|
+
# actual_created_pr = VCR.use_cassette('github_com/create_pr_in_auto_mode_create_upstream') do
|
181
|
+
# service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
|
182
|
+
# service_instance.execute('Title', 'Description', output: actual_output, automated_mode: true, no_open_pr: true)
|
183
|
+
# end
|
184
|
+
#
|
185
|
+
# expect(actual_output.string).to eql(expected_output)
|
186
|
+
# end
|
185
187
|
end
|
186
188
|
end # context 'with github.com'
|
187
189
|
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.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saverio Miroddi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_scripting
|