geet 0.3.17 → 0.4.2
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/README.md +4 -9
- data/bin/geet +4 -0
- data/geet.gemspec +1 -1
- data/lib/geet/commandline/commands.rb +2 -0
- data/lib/geet/commandline/configuration.rb +16 -1
- data/lib/geet/git/repository.rb +8 -2
- data/lib/geet/github/abstract_issue.rb +3 -0
- data/lib/geet/github/api_interface.rb +2 -0
- data/lib/geet/github/issue.rb +1 -1
- data/lib/geet/github/pr.rb +28 -9
- data/lib/geet/github/remote_repository.rb +37 -0
- data/lib/geet/gitlab/api_interface.rb +2 -0
- data/lib/geet/helpers/os_helper.rb +4 -3
- data/lib/geet/helpers/services_workflow_helper.rb +9 -7
- data/lib/geet/services/add_upstream_repo.rb +37 -0
- data/lib/geet/services/comment_pr.rb +1 -2
- data/lib/geet/services/create_pr.rb +13 -11
- data/lib/geet/services/merge_pr.rb +7 -8
- data/lib/geet/services/open_pr.rb +2 -3
- data/lib/geet/services/open_repo.rb +50 -0
- data/lib/geet/utils/attributes_selection_manager.rb +7 -0
- data/lib/geet/utils/git_client.rb +74 -33
- data/lib/geet/version.rb +1 -1
- data/spec/integration/comment_pr_spec.rb +1 -1
- data/spec/integration/create_issue_spec.rb +3 -3
- data/spec/integration/create_label_spec.rb +5 -5
- data/spec/integration/create_milestone_spec.rb +1 -1
- data/spec/integration/create_pr_spec.rb +20 -15
- data/spec/integration/list_issues_spec.rb +6 -6
- data/spec/integration/list_labels_spec.rb +4 -4
- data/spec/integration/list_milestones_spec.rb +4 -4
- data/spec/integration/list_prs_spec.rb +3 -3
- data/spec/integration/merge_pr_spec.rb +13 -9
- data/spec/integration/open_pr_spec.rb +1 -1
- data/spec/integration/open_repo_spec.rb +46 -0
- data/spec/vcr_cassettes/create_issue.yml +1 -1
- data/spec/vcr_cassettes/create_issue_upstream.yml +1 -1
- data/spec/vcr_cassettes/github_com/create_pr.yml +1 -1
- data/spec/vcr_cassettes/github_com/create_pr_in_auto_mode_create_upstream.yml +1 -1
- data/spec/vcr_cassettes/github_com/create_pr_in_auto_mode_with_push.yml +1 -1
- data/spec/vcr_cassettes/github_com/create_pr_upstream.yml +1 -1
- data/spec/vcr_cassettes/github_com/create_pr_upstream_without_write_permissions.yml +1 -1
- metadata +7 -4
- data/lib/geet/shared/branches.rb +0 -9
@@ -19,9 +19,8 @@ module Geet
|
|
19
19
|
@git_client = git_client
|
20
20
|
end
|
21
21
|
|
22
|
-
def execute(delete_branch: false)
|
23
|
-
|
24
|
-
pr = checked_find_branch_pr(merge_owner, merge_head)
|
22
|
+
def execute(delete_branch: false, **)
|
23
|
+
pr = checked_find_branch_pr
|
25
24
|
open_file_with_default_application(pr.link)
|
26
25
|
pr
|
27
26
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../helpers/os_helper'
|
4
|
+
|
5
|
+
module Geet
|
6
|
+
module Services
|
7
|
+
# Open in the browser the current repository.
|
8
|
+
#
|
9
|
+
class OpenRepo
|
10
|
+
include Helpers::OsHelper
|
11
|
+
|
12
|
+
DEFAULT_GIT_CLIENT = Utils::GitClient.new
|
13
|
+
|
14
|
+
def initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT)
|
15
|
+
@repository = repository
|
16
|
+
@out = out
|
17
|
+
@git_client = git_client
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute(upstream: false)
|
21
|
+
remote_options = upstream ? {name: Utils::GitClient::UPSTREAM_NAME} : {}
|
22
|
+
|
23
|
+
repo_url = @git_client.remote(**remote_options)
|
24
|
+
repo_url = convert_repo_url_to_http_protocol(repo_url)
|
25
|
+
|
26
|
+
open_file_with_default_application(repo_url)
|
27
|
+
|
28
|
+
repo_url
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# The repository URL may be in any of the git/http protocols.
|
34
|
+
#
|
35
|
+
def convert_repo_url_to_http_protocol(repo_url)
|
36
|
+
case repo_url
|
37
|
+
when /https:/
|
38
|
+
when /git@/
|
39
|
+
else
|
40
|
+
# Minimal error, due to match guaranteed by GitClient#remote.
|
41
|
+
raise
|
42
|
+
end
|
43
|
+
|
44
|
+
domain, _, path = repo_url.match(Utils::GitClient::REMOTE_URL_REGEX)[2..4]
|
45
|
+
|
46
|
+
"https://#{domain}/#{path}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -88,6 +88,13 @@ module Geet
|
|
88
88
|
# select_entries('reviewer', all_collaborators, 'donaldduck', nil)
|
89
89
|
#
|
90
90
|
def select_entries(entry_type, entries, pattern, name_method)
|
91
|
+
# Support both formats Array and String.
|
92
|
+
# It seems that at some point, SimpleScripting started splitting arrays automatically, so until
|
93
|
+
# the code is adjusted accordingly, this accommodates both the CLI and the test suite.
|
94
|
+
# Tracked here: https://github.com/saveriomiroddi/geet/issues/171.
|
95
|
+
#
|
96
|
+
pattern = pattern.join(',') if pattern.is_a?(Array)
|
97
|
+
|
91
98
|
if pattern == MANUAL_LIST_SELECTION_FLAG
|
92
99
|
Geet::Utils::ManualListSelection.new.select_entries(entry_type, entries, name_method: name_method)
|
93
100
|
else
|
@@ -11,19 +11,32 @@ module Geet
|
|
11
11
|
class GitClient
|
12
12
|
include Geet::Helpers::OsHelper
|
13
13
|
|
14
|
-
ORIGIN_NAME
|
14
|
+
ORIGIN_NAME = 'origin'
|
15
15
|
UPSTREAM_NAME = 'upstream'
|
16
16
|
|
17
|
-
#
|
18
|
-
|
17
|
+
# Simplified, but good enough, pattern.
|
18
|
+
#
|
19
|
+
# Relevant matches:
|
20
|
+
#
|
21
|
+
# 1: protocol + suffix
|
22
|
+
# 2: domain
|
23
|
+
# 3: domain<>path separator
|
24
|
+
# 4: path (repo, project)
|
25
|
+
# 5: suffix
|
26
|
+
#
|
27
|
+
REMOTE_URL_REGEX = %r{
|
19
28
|
\A
|
20
|
-
(
|
21
|
-
(
|
22
|
-
(
|
29
|
+
(https://|git@)
|
30
|
+
(.+?)
|
31
|
+
([/:])
|
32
|
+
(.+/.+?)
|
33
|
+
(\.git)?
|
23
34
|
\Z
|
24
35
|
}x
|
25
36
|
|
26
|
-
|
37
|
+
REMOTE_BRANCH_REGEX = %r{\A[^/]+/(.+)\Z}
|
38
|
+
|
39
|
+
MAIN_BRANCH_CONFIG_ENTRY = 'custom.development-branch'
|
27
40
|
|
28
41
|
CLEAN_TREE_MESSAGE_REGEX = /^nothing to commit, working tree clean$/
|
29
42
|
|
@@ -52,25 +65,23 @@ module Geet
|
|
52
65
|
branch
|
53
66
|
end
|
54
67
|
|
55
|
-
# Not to be confused with `upstream` repository!
|
56
|
-
#
|
57
68
|
# This API doesn't reveal if the remote branch is gone.
|
58
69
|
#
|
59
|
-
# return: nil, if the
|
70
|
+
# return: nil, if the remote branch is not configured.
|
60
71
|
#
|
61
|
-
def
|
72
|
+
def remote_branch
|
62
73
|
head_symbolic_ref = execute_git_command("symbolic-ref -q HEAD")
|
63
74
|
|
64
|
-
|
75
|
+
raw_remote_branch = execute_git_command("for-each-ref --format='%(upstream:short)' #{head_symbolic_ref.shellescape}").strip
|
65
76
|
|
66
|
-
if
|
67
|
-
|
77
|
+
if raw_remote_branch != ''
|
78
|
+
raw_remote_branch[REMOTE_BRANCH_REGEX, 1] || raise("Unexpected remote branch format: #{raw_remote_branch}")
|
68
79
|
else
|
69
80
|
nil
|
70
81
|
end
|
71
82
|
end
|
72
83
|
|
73
|
-
# TODO: May be merged with :
|
84
|
+
# TODO: May be merged with :remote_branch, although it would require designing how a gone
|
74
85
|
# remote branch is expressed.
|
75
86
|
#
|
76
87
|
# Sample command output:
|
@@ -78,7 +89,7 @@ module Geet
|
|
78
89
|
# ## add_milestone_closing...origin/add_milestone_closing [gone]
|
79
90
|
# M spec/integration/merge_pr_spec.rb
|
80
91
|
#
|
81
|
-
def
|
92
|
+
def remote_branch_gone?
|
82
93
|
git_command = "status -b --porcelain"
|
83
94
|
status_output = execute_git_command(git_command)
|
84
95
|
|
@@ -92,6 +103,19 @@ module Geet
|
|
92
103
|
end
|
93
104
|
end
|
94
105
|
|
106
|
+
# See https://saveriomiroddi.github.io/Conveniently-Handling-non-master-development-default-branches-in-git-hub
|
107
|
+
#
|
108
|
+
def main_branch
|
109
|
+
branch_name = execute_git_command("config --get #{MAIN_BRANCH_CONFIG_ENTRY}", allow_error: true)
|
110
|
+
|
111
|
+
if branch_name.empty?
|
112
|
+
full_branch_name = execute_git_command("rev-parse --abbrev-ref #{ORIGIN_NAME}/HEAD")
|
113
|
+
full_branch_name.split('/').last
|
114
|
+
else
|
115
|
+
branch_name
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
95
119
|
def working_tree_clean?
|
96
120
|
git_message = execute_git_command("status")
|
97
121
|
|
@@ -109,15 +133,22 @@ module Geet
|
|
109
133
|
end
|
110
134
|
|
111
135
|
##########################################################################
|
112
|
-
# REPOSITORY/REMOTE APIS
|
136
|
+
# REPOSITORY/REMOTE QUERYING APIS
|
113
137
|
##########################################################################
|
114
138
|
|
139
|
+
# Return the components of the remote, according to REMOTE_URL_REGEX; doesn't include the full
|
140
|
+
# match.
|
141
|
+
#
|
142
|
+
def remote_components(name: nil)
|
143
|
+
remote.match(REMOTE_URL_REGEX)[1..]
|
144
|
+
end
|
145
|
+
|
115
146
|
# Example: `donaldduck/geet`
|
116
147
|
#
|
117
148
|
def path(upstream: false)
|
118
|
-
|
149
|
+
remote_name_option = upstream ? {name: UPSTREAM_NAME} : {}
|
119
150
|
|
120
|
-
remote(
|
151
|
+
remote(**remote_name_option)[REMOTE_URL_REGEX, 4]
|
121
152
|
end
|
122
153
|
|
123
154
|
def owner
|
@@ -126,12 +157,10 @@ module Geet
|
|
126
157
|
|
127
158
|
def provider_domain
|
128
159
|
# We assume that it's not possible to have origin and upstream on different providers.
|
129
|
-
#
|
130
|
-
remote_url = remote(ORIGIN_NAME)
|
131
160
|
|
132
|
-
domain =
|
161
|
+
domain = remote()[REMOTE_URL_REGEX, 2]
|
133
162
|
|
134
|
-
raise "Can't identify domain in the provider domain string: #{domain}" if domain !~
|
163
|
+
raise "Can't identify domain in the provider domain string: #{domain}" if domain !~ /\w+\.\w+/
|
135
164
|
|
136
165
|
domain
|
137
166
|
end
|
@@ -141,12 +170,15 @@ module Geet
|
|
141
170
|
#
|
142
171
|
# The result is in the format `git@github.com:donaldduck/geet.git`
|
143
172
|
#
|
144
|
-
|
173
|
+
# options
|
174
|
+
# :name: remote name; if unspecified, the default remote is used.
|
175
|
+
#
|
176
|
+
def remote(name: nil)
|
145
177
|
remote_url = execute_git_command("ls-remote --get-url #{name}")
|
146
178
|
|
147
|
-
if
|
179
|
+
if !remote_defined?(name)
|
148
180
|
raise "Remote #{name.inspect} not found!"
|
149
|
-
elsif remote_url !~
|
181
|
+
elsif remote_url !~ REMOTE_URL_REGEX
|
150
182
|
raise "Unexpected remote reference format: #{remote_url.inspect}"
|
151
183
|
end
|
152
184
|
|
@@ -159,7 +191,8 @@ module Geet
|
|
159
191
|
def remote_defined?(name)
|
160
192
|
remote_url = execute_git_command("ls-remote --get-url #{name}")
|
161
193
|
|
162
|
-
# If the remote is not
|
194
|
+
# If the remote is not defined, `git ls-remote` will return the passed value.
|
195
|
+
#
|
163
196
|
remote_url != name
|
164
197
|
end
|
165
198
|
|
@@ -181,12 +214,12 @@ module Geet
|
|
181
214
|
execute_git_command("rebase")
|
182
215
|
end
|
183
216
|
|
184
|
-
#
|
217
|
+
# remote_branch: create an upstream branch.
|
185
218
|
#
|
186
|
-
def push(
|
187
|
-
|
219
|
+
def push(remote_branch: nil)
|
220
|
+
remote_branch_option = "-u #{ORIGIN_NAME} #{remote_branch.shellescape}" if remote_branch
|
188
221
|
|
189
|
-
execute_git_command("push #{
|
222
|
+
execute_git_command("push #{remote_branch_option}")
|
190
223
|
end
|
191
224
|
|
192
225
|
# Performs pruning.
|
@@ -195,6 +228,10 @@ module Geet
|
|
195
228
|
execute_git_command("fetch --prune")
|
196
229
|
end
|
197
230
|
|
231
|
+
def add_remote(name, url)
|
232
|
+
execute_git_command("remote add #{name.shellescape} #{url}")
|
233
|
+
end
|
234
|
+
|
198
235
|
##########################################################################
|
199
236
|
# INTERNAL HELPERS
|
200
237
|
##########################################################################
|
@@ -204,10 +241,14 @@ module Geet
|
|
204
241
|
# If executing a git command without calling this API, don't forget to split `gitdir_option`
|
205
242
|
# and use it!
|
206
243
|
#
|
207
|
-
|
244
|
+
# options (passed to :execute_command):
|
245
|
+
# - allow_error
|
246
|
+
# - (others)
|
247
|
+
#
|
248
|
+
def execute_git_command(command, **options)
|
208
249
|
gitdir_option = "-C #{@location.shellescape}" if @location
|
209
250
|
|
210
|
-
execute_command("git #{gitdir_option} #{command}")
|
251
|
+
execute_command("git #{gitdir_option} #{command}", **options)
|
211
252
|
end
|
212
253
|
end
|
213
254
|
end
|
data/lib/geet/version.rb
CHANGED
@@ -17,7 +17,7 @@ describe Geet::Services::CommentPr do
|
|
17
17
|
|
18
18
|
it 'should add a comment to the PR for the current branch' do
|
19
19
|
allow(git_client).to receive(:current_branch).and_return(branch)
|
20
|
-
allow(git_client).to receive(:remote).with(
|
20
|
+
allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
|
21
21
|
|
22
22
|
expected_pr_number = 3
|
23
23
|
expected_output = <<~STR
|
@@ -12,7 +12,7 @@ describe Geet::Services::CreateIssue do
|
|
12
12
|
|
13
13
|
context 'with labels, assignees and milestones' do
|
14
14
|
it 'should create an issue' do
|
15
|
-
allow(git_client).to receive(:remote).with(
|
15
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
16
16
|
|
17
17
|
expected_output = <<~STR
|
18
18
|
Finding labels...
|
@@ -47,8 +47,8 @@ describe Geet::Services::CreateIssue do
|
|
47
47
|
context 'without labels, assignees and milestones' do
|
48
48
|
it 'should create an upstream issue' do
|
49
49
|
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
50
|
-
allow(git_client).to receive(:remote).with(
|
51
|
-
allow(git_client).to receive(:remote).with('upstream').and_return('git@github.com:momcorp/therepo')
|
50
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo')
|
51
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:momcorp/therepo')
|
52
52
|
|
53
53
|
expected_output = <<~STR
|
54
54
|
Creating the issue...
|
@@ -13,7 +13,7 @@ describe Geet::Services::CreateLabel do
|
|
13
13
|
context 'with github.com' do
|
14
14
|
context 'with user-specified color' do
|
15
15
|
it 'should create a label' do
|
16
|
-
allow(git_client).to receive(:remote).with(
|
16
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo')
|
17
17
|
|
18
18
|
expected_output = <<~STR
|
19
19
|
Creating label...
|
@@ -34,8 +34,8 @@ describe Geet::Services::CreateLabel do
|
|
34
34
|
|
35
35
|
context 'upstream' do
|
36
36
|
it 'should create a label' do
|
37
|
-
allow(git_client).to receive(:remote).with(
|
38
|
-
allow(git_client).to receive(:remote).with('upstream').and_return('git@github.com:donaldduck-fr/testrepo_gh')
|
37
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo')
|
38
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donaldduck-fr/testrepo_gh')
|
39
39
|
|
40
40
|
expected_output = <<~STR
|
41
41
|
Creating label...
|
@@ -58,7 +58,7 @@ describe Geet::Services::CreateLabel do
|
|
58
58
|
|
59
59
|
context 'with auto-generated color' do
|
60
60
|
it 'should create a label' do
|
61
|
-
allow(git_client).to receive(:remote).with(
|
61
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo')
|
62
62
|
|
63
63
|
actual_output = StringIO.new
|
64
64
|
|
@@ -87,7 +87,7 @@ describe Geet::Services::CreateLabel do
|
|
87
87
|
|
88
88
|
context 'with gitlab.com' do
|
89
89
|
it 'should create a label' do
|
90
|
-
allow(git_client).to receive(:remote).with(
|
90
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
|
91
91
|
|
92
92
|
expected_output = <<~STR
|
93
93
|
Creating label...
|
@@ -12,7 +12,7 @@ describe Geet::Services::CreateMilestone do
|
|
12
12
|
|
13
13
|
context 'with github.com' do
|
14
14
|
it 'should create a milestone' do
|
15
|
-
allow(git_client).to receive(:remote).with(
|
15
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_upstream')
|
16
16
|
|
17
17
|
expected_output = <<~STR
|
18
18
|
Creating milestone...
|
@@ -14,7 +14,8 @@ describe Geet::Services::CreatePr do
|
|
14
14
|
context 'with labels, reviewers and milestones' do
|
15
15
|
it 'should create a PR' do
|
16
16
|
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
17
|
-
allow(git_client).to receive(:
|
17
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
18
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
18
19
|
|
19
20
|
expected_output = <<~STR
|
20
21
|
Finding labels...
|
@@ -50,8 +51,9 @@ describe Geet::Services::CreatePr do
|
|
50
51
|
context 'on an upstream repository' do
|
51
52
|
it 'should create an upstream PR' do
|
52
53
|
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
53
|
-
allow(git_client).to receive(:
|
54
|
-
allow(git_client).to receive(:remote).with(
|
54
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
55
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
56
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
55
57
|
|
56
58
|
expected_output = <<~STR
|
57
59
|
Creating PR...
|
@@ -80,8 +82,9 @@ describe Geet::Services::CreatePr do
|
|
80
82
|
context 'without labels, reviewers and milestones' do
|
81
83
|
it 'should create a PR' do
|
82
84
|
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
83
|
-
allow(git_client).to receive(:
|
84
|
-
allow(git_client).to receive(:remote).with(
|
85
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
86
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
87
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
85
88
|
|
86
89
|
expected_output = <<~STR
|
87
90
|
Creating PR...
|
@@ -112,7 +115,7 @@ describe Geet::Services::CreatePr do
|
|
112
115
|
context 'in automated mode' do
|
113
116
|
it 'should raise an error when the working tree is dirty' do
|
114
117
|
allow(git_client).to receive(:working_tree_clean?).and_return(false)
|
115
|
-
allow(git_client).to receive(:remote).with(
|
118
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
116
119
|
|
117
120
|
expected_output = <<~STR
|
118
121
|
Error! Saved summary to /tmp/last_geet_edited_summary.md
|
@@ -130,16 +133,17 @@ describe Geet::Services::CreatePr do
|
|
130
133
|
expect(actual_output.string).to eql(expected_output)
|
131
134
|
end
|
132
135
|
|
133
|
-
it 'should push to the
|
136
|
+
it 'should push to the remote branch' do
|
134
137
|
allow(git_client).to receive(:working_tree_clean?).and_return(true)
|
135
138
|
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
136
|
-
|
139
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
140
|
+
expect(git_client).to receive(:remote_branch).and_return('mybranch')
|
137
141
|
expect(git_client).to receive(:push)
|
138
142
|
|
139
|
-
allow(git_client).to receive(:remote).with(
|
143
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
140
144
|
|
141
145
|
expected_output = <<~STR
|
142
|
-
Pushing to
|
146
|
+
Pushing to remote branch...
|
143
147
|
Creating PR...
|
144
148
|
Assigning authenticated user...
|
145
149
|
PR address: https://github.com/donaldduck/testrepo_f/pull/2
|
@@ -155,16 +159,17 @@ describe Geet::Services::CreatePr do
|
|
155
159
|
expect(actual_output.string).to eql(expected_output)
|
156
160
|
end
|
157
161
|
|
158
|
-
it "should create
|
162
|
+
it "should create a remote branch, when there isn't one (is not tracked)" do
|
159
163
|
allow(git_client).to receive(:working_tree_clean?).and_return(true)
|
160
164
|
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
161
|
-
|
162
|
-
expect(git_client).to receive(:
|
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')
|
163
168
|
|
164
|
-
allow(git_client).to receive(:remote).with(
|
169
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
165
170
|
|
166
171
|
expected_output = <<~STR
|
167
|
-
Creating
|
172
|
+
Creating remote branch "mybranch"...
|
168
173
|
Creating PR...
|
169
174
|
Assigning authenticated user...
|
170
175
|
PR address: https://github.com/donaldduck/testrepo_f/pull/4
|