geet 0.3.14 → 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/.gitignore +1 -0
- data/.travis.yml +8 -0
- data/README.md +4 -8
- data/bin/geet +23 -8
- data/geet.gemspec +1 -1
- data/lib/geet/commandline/commands.rb +4 -0
- data/lib/geet/commandline/configuration.rb +26 -1
- data/lib/geet/git/repository.rb +21 -3
- data/lib/geet/github/api_interface.rb +2 -0
- data/lib/geet/github/branch.rb +1 -1
- data/lib/geet/github/issue.rb +2 -2
- data/lib/geet/github/label.rb +2 -2
- data/lib/geet/github/milestone.rb +29 -2
- data/lib/geet/github/pr.rb +1 -2
- data/lib/geet/github/remote_repository.rb +37 -0
- data/lib/geet/github/user.rb +2 -2
- data/lib/geet/gitlab/api_interface.rb +2 -0
- data/lib/geet/gitlab/label.rb +2 -2
- data/lib/geet/gitlab/milestone.rb +1 -1
- data/lib/geet/gitlab/user.rb +1 -1
- data/lib/geet/helpers/os_helper.rb +4 -3
- data/lib/geet/services/add_upstream_repo.rb +37 -0
- data/lib/geet/services/close_milestones.rb +46 -0
- data/lib/geet/services/comment_pr.rb +2 -2
- data/lib/geet/services/create_issue.rb +5 -3
- data/lib/geet/services/create_milestone.rb +24 -0
- data/lib/geet/services/create_pr.rb +10 -6
- data/lib/geet/services/list_issues.rb +4 -1
- data/lib/geet/services/merge_pr.rb +55 -4
- data/lib/geet/services/open_repo.rb +50 -0
- data/lib/geet/shared/selection.rb +3 -0
- data/lib/geet/utils/attributes_selection_manager.rb +12 -3
- data/lib/geet/utils/git_client.rb +122 -29
- data/lib/geet/version.rb +1 -1
- data/spec/integration/comment_pr_spec.rb +1 -1
- data/spec/integration/create_issue_spec.rb +4 -4
- data/spec/integration/create_label_spec.rb +5 -5
- data/spec/integration/create_milestone_spec.rb +34 -0
- data/spec/integration/create_pr_spec.rb +13 -8
- 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 +33 -4
- 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_milestone.yml +82 -0
- metadata +11 -4
@@ -30,8 +30,10 @@ module Geet
|
|
30
30
|
@selections_data = []
|
31
31
|
end
|
32
32
|
|
33
|
+
# selection_type: SELECTION_SINGLE or SELECTION_MULTIPLE
|
34
|
+
#
|
33
35
|
def add_attribute(repository_call, description, pattern, selection_type, name_method: nil, &pre_selection_hook)
|
34
|
-
raise "Unrecognized selection type #{selection_type.inspect}" if ![
|
36
|
+
raise "Unrecognized selection type #{selection_type.inspect}" if ![SELECTION_SINGLE, SELECTION_MULTIPLE].include?(selection_type)
|
35
37
|
|
36
38
|
finder_thread = find_attribute_entries(repository_call)
|
37
39
|
|
@@ -47,9 +49,9 @@ module Geet
|
|
47
49
|
entries = pre_selection_hook.(entries) if pre_selection_hook
|
48
50
|
|
49
51
|
case selection_type
|
50
|
-
when
|
52
|
+
when SELECTION_SINGLE
|
51
53
|
select_entry(description, entries, pattern, name_method)
|
52
|
-
when
|
54
|
+
when SELECTION_MULTIPLE
|
53
55
|
select_entries(description, entries, pattern, name_method)
|
54
56
|
end
|
55
57
|
end
|
@@ -86,6 +88,13 @@ module Geet
|
|
86
88
|
# select_entries('reviewer', all_collaborators, 'donaldduck', nil)
|
87
89
|
#
|
88
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
|
+
|
89
98
|
if pattern == MANUAL_LIST_SELECTION_FLAG
|
90
99
|
Geet::Utils::ManualListSelection.new.select_entries(entry_type, entries, name_method: name_method)
|
91
100
|
else
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'English'
|
3
4
|
require 'shellwords'
|
4
5
|
require_relative '../helpers/os_helper'
|
5
6
|
|
@@ -10,20 +11,33 @@ module Geet
|
|
10
11
|
class GitClient
|
11
12
|
include Geet::Helpers::OsHelper
|
12
13
|
|
13
|
-
ORIGIN_NAME
|
14
|
+
ORIGIN_NAME = 'origin'
|
14
15
|
UPSTREAM_NAME = 'upstream'
|
15
16
|
|
16
|
-
#
|
17
|
-
|
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{
|
18
28
|
\A
|
19
|
-
(
|
20
|
-
(
|
21
|
-
(
|
29
|
+
(https://|git@)
|
30
|
+
(.+?)
|
31
|
+
([/:])
|
32
|
+
(.+/.+?)
|
33
|
+
(\.git)?
|
22
34
|
\Z
|
23
35
|
}x
|
24
36
|
|
25
37
|
UPSTREAM_BRANCH_REGEX = %r{\A[^/]+/([^/]+)\Z}
|
26
38
|
|
39
|
+
MAIN_BRANCH_CONFIG_ENTRY = 'custom.development-branch'
|
40
|
+
|
27
41
|
CLEAN_TREE_MESSAGE_REGEX = /^nothing to commit, working tree clean$/
|
28
42
|
|
29
43
|
def initialize(location: nil)
|
@@ -38,13 +52,13 @@ module Geet
|
|
38
52
|
# (which start with `-`)
|
39
53
|
#
|
40
54
|
def cherry(limit)
|
41
|
-
raw_commits =
|
55
|
+
raw_commits = execute_git_command("cherry #{limit.shellescape}")
|
42
56
|
|
43
57
|
raw_commits.split("\n").grep(/^\+/).map { |line| line[3..-1] }
|
44
58
|
end
|
45
59
|
|
46
60
|
def current_branch
|
47
|
-
branch =
|
61
|
+
branch = execute_git_command("rev-parse --abbrev-ref HEAD")
|
48
62
|
|
49
63
|
raise "Couldn't find current branch" if branch == 'HEAD'
|
50
64
|
|
@@ -53,12 +67,14 @@ module Geet
|
|
53
67
|
|
54
68
|
# Not to be confused with `upstream` repository!
|
55
69
|
#
|
70
|
+
# This API doesn't reveal if the remote branch is gone.
|
71
|
+
#
|
56
72
|
# return: nil, if the upstream branch is not configured.
|
57
73
|
#
|
58
74
|
def upstream_branch
|
59
|
-
head_symbolic_ref =
|
75
|
+
head_symbolic_ref = execute_git_command("symbolic-ref -q HEAD")
|
60
76
|
|
61
|
-
raw_upstream_branch =
|
77
|
+
raw_upstream_branch = execute_git_command("for-each-ref --format='%(upstream:short)' #{head_symbolic_ref.shellescape}").strip
|
62
78
|
|
63
79
|
if raw_upstream_branch != ''
|
64
80
|
raw_upstream_branch[UPSTREAM_BRANCH_REGEX, 1] || raise("Unexpected upstream format: #{raw_upstream_branch}")
|
@@ -67,8 +83,43 @@ module Geet
|
|
67
83
|
end
|
68
84
|
end
|
69
85
|
|
86
|
+
# TODO: May be merged with :upstream_branch, although it would require designing how a gone
|
87
|
+
# remote branch is expressed.
|
88
|
+
#
|
89
|
+
# Sample command output:
|
90
|
+
#
|
91
|
+
# ## add_milestone_closing...origin/add_milestone_closing [gone]
|
92
|
+
# M spec/integration/merge_pr_spec.rb
|
93
|
+
#
|
94
|
+
def upstream_branch_gone?
|
95
|
+
git_command = "status -b --porcelain"
|
96
|
+
status_output = execute_git_command(git_command)
|
97
|
+
|
98
|
+
# Simplified branch naming pattern. The exact one (see https://stackoverflow.com/a/3651867)
|
99
|
+
# is not worth implementing.
|
100
|
+
#
|
101
|
+
if status_output =~ %r(^## .+\.\.\..+?( \[gone\])?$)
|
102
|
+
!!$LAST_MATCH_INFO[1]
|
103
|
+
else
|
104
|
+
raise "Unexpected git command #{git_command.inspect} output: #{status_output}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# See https://saveriomiroddi.github.io/Conveniently-Handling-non-master-development-default-branches-in-git-hub
|
109
|
+
#
|
110
|
+
def main_branch
|
111
|
+
branch_name = execute_git_command("config --get #{MAIN_BRANCH_CONFIG_ENTRY}", allow_error: true)
|
112
|
+
|
113
|
+
if branch_name.empty?
|
114
|
+
full_branch_name = execute_git_command("rev-parse --abbrev-ref #{ORIGIN_NAME}/HEAD")
|
115
|
+
full_branch_name.split('/').last
|
116
|
+
else
|
117
|
+
branch_name
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
70
121
|
def working_tree_clean?
|
71
|
-
git_message =
|
122
|
+
git_message = execute_git_command("status")
|
72
123
|
|
73
124
|
!!(git_message =~ CLEAN_TREE_MESSAGE_REGEX)
|
74
125
|
end
|
@@ -80,19 +131,26 @@ module Geet
|
|
80
131
|
# Show the description ("<subject>\n\n<body>") for the given git object.
|
81
132
|
#
|
82
133
|
def show_description(object)
|
83
|
-
|
134
|
+
execute_git_command("show --quiet --format='%s\n\n%b' #{object.shellescape}")
|
84
135
|
end
|
85
136
|
|
86
137
|
##########################################################################
|
87
|
-
# REPOSITORY/REMOTE APIS
|
138
|
+
# REPOSITORY/REMOTE QUERYING APIS
|
88
139
|
##########################################################################
|
89
140
|
|
141
|
+
# Return the components of the remote, according to REMOTE_URL_REGEX; doesn't include the full
|
142
|
+
# match.
|
143
|
+
#
|
144
|
+
def remote_components(name: nil)
|
145
|
+
remote.match(REMOTE_URL_REGEX)[1..]
|
146
|
+
end
|
147
|
+
|
90
148
|
# Example: `donaldduck/geet`
|
91
149
|
#
|
92
150
|
def path(upstream: false)
|
93
|
-
|
151
|
+
remote_name_option = upstream ? {name: UPSTREAM_NAME} : {}
|
94
152
|
|
95
|
-
remote(
|
153
|
+
remote(**remote_name_option)[REMOTE_URL_REGEX, 4]
|
96
154
|
end
|
97
155
|
|
98
156
|
def owner
|
@@ -101,12 +159,10 @@ module Geet
|
|
101
159
|
|
102
160
|
def provider_domain
|
103
161
|
# We assume that it's not possible to have origin and upstream on different providers.
|
104
|
-
#
|
105
|
-
remote_url = remote(ORIGIN_NAME)
|
106
162
|
|
107
|
-
domain =
|
163
|
+
domain = remote()[REMOTE_URL_REGEX, 2]
|
108
164
|
|
109
|
-
raise "Can't identify domain in the provider domain string: #{domain}" if domain !~
|
165
|
+
raise "Can't identify domain in the provider domain string: #{domain}" if domain !~ /\w+\.\w+/
|
110
166
|
|
111
167
|
domain
|
112
168
|
end
|
@@ -116,12 +172,15 @@ module Geet
|
|
116
172
|
#
|
117
173
|
# The result is in the format `git@github.com:donaldduck/geet.git`
|
118
174
|
#
|
119
|
-
|
120
|
-
|
175
|
+
# options
|
176
|
+
# :name: remote name; if unspecified, the default remote is used.
|
177
|
+
#
|
178
|
+
def remote(name: nil)
|
179
|
+
remote_url = execute_git_command("ls-remote --get-url #{name}")
|
121
180
|
|
122
|
-
if
|
181
|
+
if !remote_defined?(name)
|
123
182
|
raise "Remote #{name.inspect} not found!"
|
124
|
-
elsif remote_url !~
|
183
|
+
elsif remote_url !~ REMOTE_URL_REGEX
|
125
184
|
raise "Unexpected remote reference format: #{remote_url.inspect}"
|
126
185
|
end
|
127
186
|
|
@@ -132,9 +191,10 @@ module Geet
|
|
132
191
|
# purposes, any any action that needs to work with the remote, uses #remote.
|
133
192
|
#
|
134
193
|
def remote_defined?(name)
|
135
|
-
remote_url =
|
194
|
+
remote_url = execute_git_command("ls-remote --get-url #{name}")
|
136
195
|
|
137
|
-
# If the remote is not
|
196
|
+
# If the remote is not defined, `git ls-remote` will return the passed value.
|
197
|
+
#
|
138
198
|
remote_url != name
|
139
199
|
end
|
140
200
|
|
@@ -142,12 +202,36 @@ module Geet
|
|
142
202
|
# OPERATION APIS
|
143
203
|
##########################################################################
|
144
204
|
|
205
|
+
def checkout(branch)
|
206
|
+
execute_git_command("checkout #{branch.shellescape}")
|
207
|
+
end
|
208
|
+
|
209
|
+
# Unforced deletion.
|
210
|
+
#
|
211
|
+
def delete_branch(branch)
|
212
|
+
execute_git_command("branch --delete #{branch.shellescape}")
|
213
|
+
end
|
214
|
+
|
215
|
+
def rebase
|
216
|
+
execute_git_command("rebase")
|
217
|
+
end
|
218
|
+
|
145
219
|
# upstream_branch: create an upstream branch.
|
146
220
|
#
|
147
221
|
def push(upstream_branch: nil)
|
148
|
-
upstream_branch_option = "-u
|
222
|
+
upstream_branch_option = "-u #{ORIGIN_NAME} #{upstream_branch.shellescape}" if upstream_branch
|
223
|
+
|
224
|
+
execute_git_command("push #{upstream_branch_option}")
|
225
|
+
end
|
226
|
+
|
227
|
+
# Performs pruning.
|
228
|
+
#
|
229
|
+
def fetch
|
230
|
+
execute_git_command("fetch --prune")
|
231
|
+
end
|
149
232
|
|
150
|
-
|
233
|
+
def add_remote(name, url)
|
234
|
+
execute_git_command("remote add #{name.shellescape} #{url}")
|
151
235
|
end
|
152
236
|
|
153
237
|
##########################################################################
|
@@ -156,8 +240,17 @@ module Geet
|
|
156
240
|
|
157
241
|
private
|
158
242
|
|
159
|
-
|
160
|
-
|
243
|
+
# If executing a git command without calling this API, don't forget to split `gitdir_option`
|
244
|
+
# and use it!
|
245
|
+
#
|
246
|
+
# options (passed to :execute_command):
|
247
|
+
# - allow_error
|
248
|
+
# - (others)
|
249
|
+
#
|
250
|
+
def execute_git_command(command, **options)
|
251
|
+
gitdir_option = "-C #{@location.shellescape}" if @location
|
252
|
+
|
253
|
+
execute_command("git #{gitdir_option} #{command}", **options)
|
161
254
|
end
|
162
255
|
end
|
163
256
|
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...
|
@@ -59,7 +59,7 @@ describe Geet::Services::CreateIssue do
|
|
59
59
|
|
60
60
|
actual_created_issue = VCR.use_cassette('create_issue_upstream') do
|
61
61
|
create_options = { no_open_issue: true, out: actual_output }
|
62
|
-
described_class.new(upstream_repository, out: actual_output).execute('Title', 'Description', create_options)
|
62
|
+
described_class.new(upstream_repository, out: actual_output).execute('Title', 'Description', **create_options)
|
63
63
|
end
|
64
64
|
|
65
65
|
expect(actual_output.string).to eql(expected_output)
|
@@ -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...
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require_relative '../../lib/geet/git/repository'
|
6
|
+
require_relative '../../lib/geet/services/create_milestone'
|
7
|
+
|
8
|
+
describe Geet::Services::CreateMilestone do
|
9
|
+
let(:git_client) { Geet::Utils::GitClient.new }
|
10
|
+
let(:repository) { Geet::Git::Repository.new(git_client: git_client) }
|
11
|
+
let(:upstream_repository) { Geet::Git::Repository.new(upstream: true, git_client: git_client) }
|
12
|
+
|
13
|
+
context 'with github.com' do
|
14
|
+
it 'should create a milestone' do
|
15
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_upstream')
|
16
|
+
|
17
|
+
expected_output = <<~STR
|
18
|
+
Creating milestone...
|
19
|
+
STR
|
20
|
+
|
21
|
+
actual_output = StringIO.new
|
22
|
+
|
23
|
+
actual_created_label = VCR.use_cassette('github_com/create_milestone') do
|
24
|
+
described_class.new(repository, out: actual_output).execute('my_milestone')
|
25
|
+
end
|
26
|
+
|
27
|
+
expect(actual_output.string).to eql(expected_output)
|
28
|
+
|
29
|
+
expect(actual_created_label.number).to eql(6)
|
30
|
+
expect(actual_created_label.title).to eql('my_milestone')
|
31
|
+
expect(actual_created_label.due_on).to be(nil)
|
32
|
+
end
|
33
|
+
end # context 'with github.com'
|
34
|
+
end # describe Geet::Services::CreateLabel
|
@@ -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
|
@@ -133,10 +136,11 @@ describe Geet::Services::CreatePr do
|
|
133
136
|
it 'should push to the upstream 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')
|
139
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
136
140
|
expect(git_client).to receive(:upstream_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
146
|
Pushing to upstream branch...
|
@@ -158,10 +162,11 @@ describe Geet::Services::CreatePr do
|
|
158
162
|
it "should create an upstream 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')
|
165
|
+
allow(git_client).to receive(:main_branch).and_return('master')
|
161
166
|
expect(git_client).to receive(:upstream_branch).and_return(nil)
|
162
167
|
expect(git_client).to receive(:push).with(upstream_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
172
|
Creating upstream branch "mybranch"...
|