geet 0.3.17 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
- 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 +13 -0
- data/lib/geet/git/repository.rb +6 -0
- data/lib/geet/github/api_interface.rb +2 -0
- data/lib/geet/github/remote_repository.rb +37 -0
- data/lib/geet/gitlab/api_interface.rb +2 -0
- data/lib/geet/services/add_upstream_repo.rb +37 -0
- 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 +40 -17
- 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 +8 -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 +3 -3
- data/spec/integration/open_pr_spec.rb +1 -1
- data/spec/integration/open_repo_spec.rb +46 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b37d7ac48684dcd431b13c0e00cb9f999764ae714dec3c8d046102469f7f62f
|
4
|
+
data.tar.gz: 43a045941aff66c212314ae0de2c5c439434c75e89240ce2c59750f5759dcc5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe4aa67774fef6b5943ae4f6eb2950ec4d4c2b7f004aa963438e00904d80d01c3a73db8671567c718b6fc9b235a2e9d2002744ec891bce3ff4af1144ffa01d28
|
7
|
+
data.tar.gz: 14c3efa61fa206f3f3f70432c3683d394f9e4e4e09f6cefad757d96d11b88110559f393d22d296acef963d72d7117c668125724da79d8f1f6cbda9e35dfc367a
|
data/README.md
CHANGED
@@ -18,17 +18,12 @@ The functionalities currently supported are:
|
|
18
18
|
|
19
19
|
- Github/Gitlab:
|
20
20
|
- create label
|
21
|
-
- list issues
|
22
|
-
-
|
23
|
-
-
|
24
|
-
- list PRs
|
25
|
-
- merge PR
|
21
|
+
- list issues, labels, milestones, MR/PRs
|
22
|
+
- merge MR/PR
|
23
|
+
- open repository
|
26
24
|
- Github:
|
27
25
|
- comment PR
|
28
|
-
- create gist
|
29
|
-
- create issue
|
30
|
-
- create milestone
|
31
|
-
- create PR
|
26
|
+
- create gist, issue, milestone, PR
|
32
27
|
|
33
28
|
## Samples
|
34
29
|
|
data/bin/geet
CHANGED
@@ -76,6 +76,10 @@ class GeetLauncher
|
|
76
76
|
Services::MergePr.new(repository).execute(**options)
|
77
77
|
when PR_OPEN_COMMAND
|
78
78
|
Services::OpenPr.new(repository).execute(**options)
|
79
|
+
when REPO_ADD_UPSTREAM_COMMAND
|
80
|
+
Services::AddUpstreamRepo.new(repository).execute
|
81
|
+
when REPO_OPEN_COMMAND
|
82
|
+
Services::OpenRepo.new(repository).execute(**options)
|
79
83
|
else
|
80
84
|
raise "Internal error - Unrecognized command #{command.inspect}"
|
81
85
|
end
|
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 = '2021-
|
13
|
+
s.date = '2021-05-28'
|
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'
|
@@ -98,6 +98,15 @@ module Geet
|
|
98
98
|
long_help: 'Open in the browser the PR for the current branch'
|
99
99
|
]
|
100
100
|
|
101
|
+
REPO_ADD_UPSTREAM_OPTIONS = [
|
102
|
+
long_help: 'Add the upstream repository to the current repository (configuration).'
|
103
|
+
]
|
104
|
+
|
105
|
+
REPO_OPEN_OPTIONS = [
|
106
|
+
['-u', '--upstream', 'Open the upstream repository'],
|
107
|
+
long_help: 'Open the current repository in the browser'
|
108
|
+
]
|
109
|
+
|
101
110
|
# Commands decoding table
|
102
111
|
|
103
112
|
COMMANDS_DECODING_TABLE = {
|
@@ -124,6 +133,10 @@ module Geet
|
|
124
133
|
'merge' => PR_MERGE_OPTIONS,
|
125
134
|
'open' => PR_OPEN_OPTIONS,
|
126
135
|
},
|
136
|
+
'repo' => {
|
137
|
+
'add_upstream' => REPO_ADD_UPSTREAM_OPTIONS,
|
138
|
+
'open' => REPO_OPEN_OPTIONS,
|
139
|
+
},
|
127
140
|
}
|
128
141
|
|
129
142
|
# Public interface
|
data/lib/geet/git/repository.rb
CHANGED
@@ -85,6 +85,12 @@ module Geet
|
|
85
85
|
attempt_provider_call(:PR, :list, api_interface, owner: owner, head: head, milestone: milestone)
|
86
86
|
end
|
87
87
|
|
88
|
+
# Returns the RemoteRepository instance.
|
89
|
+
#
|
90
|
+
def remote
|
91
|
+
attempt_provider_call(:RemoteRepository, :find, api_interface)
|
92
|
+
end
|
93
|
+
|
88
94
|
# REMOTE FUNCTIONALITIES (ACCOUNT)
|
89
95
|
|
90
96
|
def authenticated_user
|
@@ -11,6 +11,8 @@ module Geet
|
|
11
11
|
API_AUTH_USER = '' # We don't need the login, as the API key uniquely identifies the user
|
12
12
|
API_BASE_URL = 'https://api.github.com'
|
13
13
|
|
14
|
+
attr_reader :repository_path
|
15
|
+
|
14
16
|
# repo_path: optional for operations that don't require a repository, eg. gist creation.
|
15
17
|
# upstream: boolean; makes sense only when :repo_path is set.
|
16
18
|
#
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Geet
|
4
|
+
module Github
|
5
|
+
# A remote repository. Currently only provides the parent path.
|
6
|
+
#
|
7
|
+
# It's a difficult choice whether to independently use the repository path, or relying on the one
|
8
|
+
# stored in the ApiInterface.
|
9
|
+
# The former design is conceptually cleaner, but it practically (as of the current design) introduces
|
10
|
+
# duplication. All in all, for simplicity, the latter design is chosen, but is subject to redesign.
|
11
|
+
#
|
12
|
+
class RemoteRepository
|
13
|
+
# Nil if the repository is not a fork.
|
14
|
+
#
|
15
|
+
attr_reader :parent_path
|
16
|
+
|
17
|
+
def initialize(api_interface, parent_path: nil)
|
18
|
+
@api_interface = api_interface
|
19
|
+
@parent_path = parent_path
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get the repository parent path.
|
23
|
+
#
|
24
|
+
# https://docs.github.com/en/rest/reference/repos#get-a-repository
|
25
|
+
#
|
26
|
+
def self.find(api_interface)
|
27
|
+
api_path = "/repos/#{api_interface.repository_path}"
|
28
|
+
|
29
|
+
response = api_interface.send_request(api_path)
|
30
|
+
|
31
|
+
parent_path = response['parent']&.fetch("full_name")
|
32
|
+
|
33
|
+
self.new(api_interface, parent_path: parent_path)
|
34
|
+
end
|
35
|
+
end # module RemoteRepository
|
36
|
+
end # module GitHub
|
37
|
+
end # module Geet
|
@@ -10,6 +10,8 @@ module Geet
|
|
10
10
|
class ApiInterface
|
11
11
|
API_BASE_URL = 'https://gitlab.com/api/v4'
|
12
12
|
|
13
|
+
attr_reader :repository_path
|
14
|
+
|
13
15
|
# repo_path: "path/namespace"; required for the current GitLab operations.
|
14
16
|
# upstream: boolean; required for the current GitLab operations.
|
15
17
|
#
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Geet
|
4
|
+
module Services
|
5
|
+
# Add the upstream repository to the current repository (configuration).
|
6
|
+
#
|
7
|
+
class AddUpstreamRepo
|
8
|
+
DEFAULT_GIT_CLIENT = Utils::GitClient.new
|
9
|
+
|
10
|
+
def initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT)
|
11
|
+
@repository = repository
|
12
|
+
@out = out
|
13
|
+
@git_client = git_client
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
raise "Upstream remote already existing!" if @git_client.remote_defined?(Utils::GitClient::UPSTREAM_NAME)
|
18
|
+
|
19
|
+
parent_path = @repository.remote.parent_path
|
20
|
+
|
21
|
+
parent_url = compose_parent_url(parent_path)
|
22
|
+
|
23
|
+
@git_client.add_remote(Utils::GitClient::UPSTREAM_NAME, parent_url)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
# Use the same protocol as the main repository.
|
29
|
+
#
|
30
|
+
def compose_parent_url(parent_path)
|
31
|
+
protocol, domain, separator, _, suffix = @git_client.remote_components
|
32
|
+
|
33
|
+
"#{protocol}#{domain}#{separator}#{parent_path}#{suffix}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
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,15 +11,25 @@ module Geet
|
|
11
11
|
class GitClient
|
12
12
|
include Geet::Helpers::OsHelper
|
13
13
|
|
14
|
-
ORIGIN_NAME = 'origin'
|
15
14
|
UPSTREAM_NAME = 'upstream'
|
16
15
|
|
17
|
-
#
|
18
|
-
|
16
|
+
# Simplified, but good enough, pattern.
|
17
|
+
#
|
18
|
+
# Relevant matches:
|
19
|
+
#
|
20
|
+
# 1: protocol + suffix
|
21
|
+
# 2: domain
|
22
|
+
# 3: domain<>path separator
|
23
|
+
# 4: path (repo, project)
|
24
|
+
# 5: suffix
|
25
|
+
#
|
26
|
+
REMOTE_URL_REGEX = %r{
|
19
27
|
\A
|
20
|
-
(
|
21
|
-
(
|
22
|
-
(
|
28
|
+
(https://|git@)
|
29
|
+
(.+?)
|
30
|
+
([/:])
|
31
|
+
(.+/.+?)
|
32
|
+
(\.git)?
|
23
33
|
\Z
|
24
34
|
}x
|
25
35
|
|
@@ -109,15 +119,22 @@ module Geet
|
|
109
119
|
end
|
110
120
|
|
111
121
|
##########################################################################
|
112
|
-
# REPOSITORY/REMOTE APIS
|
122
|
+
# REPOSITORY/REMOTE QUERYING APIS
|
113
123
|
##########################################################################
|
114
124
|
|
125
|
+
# Return the components of the remote, according to REMOTE_URL_REGEX; doesn't include the full
|
126
|
+
# match.
|
127
|
+
#
|
128
|
+
def remote_components(name: nil)
|
129
|
+
remote.match(REMOTE_URL_REGEX)[1..]
|
130
|
+
end
|
131
|
+
|
115
132
|
# Example: `donaldduck/geet`
|
116
133
|
#
|
117
134
|
def path(upstream: false)
|
118
|
-
|
135
|
+
remote_name_option = upstream ? {name: UPSTREAM_NAME} : {}
|
119
136
|
|
120
|
-
remote(
|
137
|
+
remote(**remote_name_option)[REMOTE_URL_REGEX, 4]
|
121
138
|
end
|
122
139
|
|
123
140
|
def owner
|
@@ -126,12 +143,10 @@ module Geet
|
|
126
143
|
|
127
144
|
def provider_domain
|
128
145
|
# We assume that it's not possible to have origin and upstream on different providers.
|
129
|
-
#
|
130
|
-
remote_url = remote(ORIGIN_NAME)
|
131
146
|
|
132
|
-
domain =
|
147
|
+
domain = remote()[REMOTE_URL_REGEX, 2]
|
133
148
|
|
134
|
-
raise "Can't identify domain in the provider domain string: #{domain}" if domain !~
|
149
|
+
raise "Can't identify domain in the provider domain string: #{domain}" if domain !~ /\w+\.\w+/
|
135
150
|
|
136
151
|
domain
|
137
152
|
end
|
@@ -141,12 +156,15 @@ module Geet
|
|
141
156
|
#
|
142
157
|
# The result is in the format `git@github.com:donaldduck/geet.git`
|
143
158
|
#
|
144
|
-
|
159
|
+
# options
|
160
|
+
# :name: remote name; if unspecified, the default remote is used.
|
161
|
+
#
|
162
|
+
def remote(name: nil)
|
145
163
|
remote_url = execute_git_command("ls-remote --get-url #{name}")
|
146
164
|
|
147
|
-
if
|
165
|
+
if !remote_defined?(name)
|
148
166
|
raise "Remote #{name.inspect} not found!"
|
149
|
-
elsif remote_url !~
|
167
|
+
elsif remote_url !~ REMOTE_URL_REGEX
|
150
168
|
raise "Unexpected remote reference format: #{remote_url.inspect}"
|
151
169
|
end
|
152
170
|
|
@@ -159,7 +177,8 @@ module Geet
|
|
159
177
|
def remote_defined?(name)
|
160
178
|
remote_url = execute_git_command("ls-remote --get-url #{name}")
|
161
179
|
|
162
|
-
# If the remote is not
|
180
|
+
# If the remote is not defined, `git ls-remote` will return the passed value.
|
181
|
+
#
|
163
182
|
remote_url != name
|
164
183
|
end
|
165
184
|
|
@@ -195,6 +214,10 @@ module Geet
|
|
195
214
|
execute_git_command("fetch --prune")
|
196
215
|
end
|
197
216
|
|
217
|
+
def add_remote(name, url)
|
218
|
+
execute_git_command("remote add #{name.shellescape} #{url}")
|
219
|
+
end
|
220
|
+
|
198
221
|
##########################################################################
|
199
222
|
# INTERNAL HELPERS
|
200
223
|
##########################################################################
|
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,7 @@ 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(:remote).with(
|
17
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
18
18
|
|
19
19
|
expected_output = <<~STR
|
20
20
|
Finding labels...
|
@@ -50,8 +50,8 @@ describe Geet::Services::CreatePr do
|
|
50
50
|
context 'on an upstream repository' do
|
51
51
|
it 'should create an upstream PR' do
|
52
52
|
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
53
|
-
allow(git_client).to receive(:remote).with(
|
54
|
-
allow(git_client).to receive(:remote).with('upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
53
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
54
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
55
55
|
|
56
56
|
expected_output = <<~STR
|
57
57
|
Creating PR...
|
@@ -80,8 +80,8 @@ describe Geet::Services::CreatePr do
|
|
80
80
|
context 'without labels, reviewers and milestones' do
|
81
81
|
it 'should create a PR' do
|
82
82
|
allow(git_client).to receive(:current_branch).and_return('mybranch')
|
83
|
-
allow(git_client).to receive(:remote).with(
|
84
|
-
allow(git_client).to receive(:remote).with('upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
83
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
84
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
85
85
|
|
86
86
|
expected_output = <<~STR
|
87
87
|
Creating PR...
|
@@ -112,7 +112,7 @@ describe Geet::Services::CreatePr do
|
|
112
112
|
context 'in automated mode' do
|
113
113
|
it 'should raise an error when the working tree is dirty' do
|
114
114
|
allow(git_client).to receive(:working_tree_clean?).and_return(false)
|
115
|
-
allow(git_client).to receive(:remote).with(
|
115
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
116
116
|
|
117
117
|
expected_output = <<~STR
|
118
118
|
Error! Saved summary to /tmp/last_geet_edited_summary.md
|
@@ -136,7 +136,7 @@ describe Geet::Services::CreatePr do
|
|
136
136
|
expect(git_client).to receive(:upstream_branch).and_return('mybranch')
|
137
137
|
expect(git_client).to receive(:push)
|
138
138
|
|
139
|
-
allow(git_client).to receive(:remote).with(
|
139
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
140
140
|
|
141
141
|
expected_output = <<~STR
|
142
142
|
Pushing to upstream branch...
|
@@ -161,7 +161,7 @@ describe Geet::Services::CreatePr do
|
|
161
161
|
expect(git_client).to receive(:upstream_branch).and_return(nil)
|
162
162
|
expect(git_client).to receive(:push).with(upstream_branch: 'mybranch')
|
163
163
|
|
164
|
-
allow(git_client).to receive(:remote).with(
|
164
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
165
165
|
|
166
166
|
expected_output = <<~STR
|
167
167
|
Creating upstream branch "mybranch"...
|
@@ -12,7 +12,7 @@ describe Geet::Services::ListIssues do
|
|
12
12
|
|
13
13
|
context 'with github.com' do
|
14
14
|
it 'should list the default issues' 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')
|
16
16
|
|
17
17
|
expected_output = <<~STR
|
18
18
|
5. Title 2 (https://github.com/donaldduck/testrepo/issues/5)
|
@@ -34,7 +34,7 @@ describe Geet::Services::ListIssues do
|
|
34
34
|
|
35
35
|
context 'with assignee filtering' do
|
36
36
|
it 'should list the issues' do
|
37
|
-
allow(git_client).to receive(:remote).with(
|
37
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_gh')
|
38
38
|
|
39
39
|
expected_output = <<~STR
|
40
40
|
Finding collaborators...
|
@@ -57,8 +57,8 @@ describe Geet::Services::ListIssues do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'should list the upstream issues' do
|
60
|
-
allow(git_client).to receive(:remote).with(
|
61
|
-
allow(git_client).to receive(:remote).with('upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
60
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_2f')
|
61
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
62
62
|
|
63
63
|
expected_output = <<~STR
|
64
64
|
2. Title 2 U (https://github.com/donald-fr/testrepo_u/issues/2)
|
@@ -81,7 +81,7 @@ describe Geet::Services::ListIssues do
|
|
81
81
|
|
82
82
|
context 'with gitlab.com' do
|
83
83
|
it 'should list the issues' do
|
84
|
-
allow(git_client).to receive(:remote).with(
|
84
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
|
85
85
|
|
86
86
|
expected_output = <<~STR
|
87
87
|
2. I like more pizza (https://gitlab.com/donaldduck/testproject/issues/2)
|
@@ -103,7 +103,7 @@ describe Geet::Services::ListIssues do
|
|
103
103
|
|
104
104
|
context 'with assignee filtering' do
|
105
105
|
it 'should list the issues' do
|
106
|
-
allow(git_client).to receive(:remote).with(
|
106
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
|
107
107
|
|
108
108
|
expected_output = <<~STR
|
109
109
|
Finding collaborators...
|
@@ -12,7 +12,7 @@ describe Geet::Services::ListLabels do
|
|
12
12
|
|
13
13
|
context 'with github.com' do
|
14
14
|
it 'should list the labels' 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/geet')
|
16
16
|
|
17
17
|
expected_output = <<~STR
|
18
18
|
- bug (#ee0701)
|
@@ -34,8 +34,8 @@ describe Geet::Services::ListLabels do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should list the upstream labels' 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_u')
|
37
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/geet')
|
38
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donaldduck-fr/testrepo_u')
|
39
39
|
|
40
40
|
expected_output = <<~STR
|
41
41
|
- bug (#ee0701)
|
@@ -57,7 +57,7 @@ describe Geet::Services::ListLabels do
|
|
57
57
|
|
58
58
|
context 'with gitlab.com' do
|
59
59
|
it 'should list the labels' do
|
60
|
-
allow(git_client).to receive(:remote).with(
|
60
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
|
61
61
|
|
62
62
|
expected_output = <<~STR
|
63
63
|
- bug (#d9534f)
|
@@ -12,7 +12,7 @@ describe Geet::Services::ListMilestones do
|
|
12
12
|
|
13
13
|
context 'with github.com' do
|
14
14
|
it 'should list the milestones' 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/geet')
|
16
16
|
|
17
17
|
expected_output = <<~STR
|
18
18
|
Finding milestones...
|
@@ -50,8 +50,8 @@ describe Geet::Services::ListMilestones do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'should list the upstream milestones' do
|
53
|
-
allow(git_client).to receive(:remote).with(
|
54
|
-
allow(git_client).to receive(:remote).with('upstream').and_return('git@github.com:donaldduck/testrepo_upstream')
|
53
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donald-fr/testrepo_downstream')
|
54
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donaldduck/testrepo_upstream')
|
55
55
|
|
56
56
|
expected_output = <<~STR
|
57
57
|
Finding milestones...
|
@@ -80,7 +80,7 @@ describe Geet::Services::ListMilestones do
|
|
80
80
|
|
81
81
|
context 'with gitlab.com' do
|
82
82
|
it 'should list the milestones' do
|
83
|
-
allow(git_client).to receive(:remote).with(
|
83
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@gitlab.com:donaldduck/testproject')
|
84
84
|
|
85
85
|
expected_output = <<~STR
|
86
86
|
Finding milestones...
|
@@ -11,7 +11,7 @@ describe Geet::Services::ListPrs do
|
|
11
11
|
let(:upstream_repository) { Geet::Git::Repository.new(upstream: true, git_client: git_client) }
|
12
12
|
|
13
13
|
it 'should list the PRs' do
|
14
|
-
allow(git_client).to receive(:remote).with(
|
14
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donald-fr/testrepo_downstream')
|
15
15
|
|
16
16
|
expected_output = <<~STR
|
17
17
|
2. Add testfile3 (downstream) (https://github.com/donald-fr/testrepo_downstream/pull/2)
|
@@ -32,8 +32,8 @@ describe Geet::Services::ListPrs do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should list the upstream PRs' do
|
35
|
-
allow(git_client).to receive(:remote).with(
|
36
|
-
allow(git_client).to receive(:remote).with('upstream').and_return('git@github.com:donaldduck/testrepo_upstream')
|
35
|
+
allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donald-fr/testrepo_downstream')
|
36
|
+
allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donaldduck/testrepo_upstream')
|
37
37
|
|
38
38
|
expected_output = <<~STR
|
39
39
|
2. Add testfile3 (upstream) (https://github.com/donaldduck/testrepo_upstream/pull/2)
|
@@ -29,7 +29,7 @@ describe Geet::Services::MergePr do
|
|
29
29
|
|
30
30
|
it 'should merge the PR for the current branch' do
|
31
31
|
allow(git_client).to receive(:current_branch).and_return(branch)
|
32
|
-
allow(git_client).to receive(:remote).with(
|
32
|
+
allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
|
33
33
|
|
34
34
|
expected_pr_number = 1
|
35
35
|
expected_output = <<~STR
|
@@ -55,7 +55,7 @@ describe Geet::Services::MergePr do
|
|
55
55
|
|
56
56
|
it 'should merge the PR for the current branch, with branch deletion' do
|
57
57
|
allow(git_client).to receive(:current_branch).and_return(branch)
|
58
|
-
allow(git_client).to receive(:remote).with(
|
58
|
+
allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
|
59
59
|
|
60
60
|
expected_pr_number = 2
|
61
61
|
expected_output = <<~STR
|
@@ -86,7 +86,7 @@ describe Geet::Services::MergePr do
|
|
86
86
|
|
87
87
|
it 'should merge the PR for the current branch' do
|
88
88
|
allow(git_client).to receive(:current_branch).and_return(branch)
|
89
|
-
allow(git_client).to receive(:remote).with(
|
89
|
+
allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:#{owner}/#{repository_name}")
|
90
90
|
|
91
91
|
expected_pr_number = 4
|
92
92
|
expected_output = <<~STR
|
@@ -16,7 +16,7 @@ describe Geet::Services::OpenPr do
|
|
16
16
|
|
17
17
|
it 'should open the PR for the current branch' do
|
18
18
|
allow(git_client).to receive(:current_branch).and_return(branch)
|
19
|
-
allow(git_client).to receive(:remote).with(
|
19
|
+
allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
|
20
20
|
|
21
21
|
expected_pr_number = 3
|
22
22
|
expected_output = <<~STR
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require_relative '../../lib/geet/git/repository'
|
6
|
+
require_relative '../../lib/geet/services/open_repo'
|
7
|
+
|
8
|
+
module Geet
|
9
|
+
describe Services::OpenRepo do
|
10
|
+
let(:git_client) { Utils::GitClient.new }
|
11
|
+
let(:repository) { Git::Repository.new(git_client: git_client) }
|
12
|
+
|
13
|
+
OWNER = 'donaldduck'
|
14
|
+
REPOSITORY_NAME = 'testrepo'
|
15
|
+
|
16
|
+
REMOTE_URLS = {
|
17
|
+
'git' => "git@github.com:#{OWNER}/#{REPOSITORY_NAME}",
|
18
|
+
'https' => "https://github.com/#{OWNER}/#{REPOSITORY_NAME}",
|
19
|
+
}
|
20
|
+
|
21
|
+
context 'should open the PR for the current branch' do
|
22
|
+
REMOTE_URLS.each do |protocol, remote_url|
|
23
|
+
it "with #{protocol} protocol" do
|
24
|
+
allow(git_client).to receive(:remote).with(no_args).and_return(remote_url)
|
25
|
+
|
26
|
+
expected_url = "https://github.com/#{OWNER}/#{REPOSITORY_NAME}"
|
27
|
+
expected_output = ""
|
28
|
+
|
29
|
+
actual_output = StringIO.new
|
30
|
+
service_instance = described_class.new(repository, out: actual_output, git_client: git_client)
|
31
|
+
|
32
|
+
expect(service_instance).to receive(:open_file_with_default_application).with(expected_url) do
|
33
|
+
# do nothing; just don't open the browser
|
34
|
+
end
|
35
|
+
|
36
|
+
execution_result = VCR.use_cassette('github_com/open_repo') do
|
37
|
+
service_instance.execute
|
38
|
+
end
|
39
|
+
|
40
|
+
expect(actual_output.string).to eql(expected_output)
|
41
|
+
expect(execution_result).to eql(expected_url)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end # context 'should open the PR for the current branch'
|
45
|
+
end # describe Services::OpenRepo
|
46
|
+
end # module Geet
|
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.3.
|
4
|
+
version: 0.3.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saverio Miroddi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_scripting
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/geet/github/label.rb
|
89
89
|
- lib/geet/github/milestone.rb
|
90
90
|
- lib/geet/github/pr.rb
|
91
|
+
- lib/geet/github/remote_repository.rb
|
91
92
|
- lib/geet/github/user.rb
|
92
93
|
- lib/geet/gitlab/api_interface.rb
|
93
94
|
- lib/geet/gitlab/issue.rb
|
@@ -101,6 +102,7 @@ files:
|
|
101
102
|
- lib/geet/helpers/summary_helper.rb
|
102
103
|
- lib/geet/resources/templates/edit_summary.md
|
103
104
|
- lib/geet/services/abstract_create_issue.rb
|
105
|
+
- lib/geet/services/add_upstream_repo.rb
|
104
106
|
- lib/geet/services/close_milestones.rb
|
105
107
|
- lib/geet/services/comment_pr.rb
|
106
108
|
- lib/geet/services/create_gist.rb
|
@@ -114,6 +116,7 @@ files:
|
|
114
116
|
- lib/geet/services/list_prs.rb
|
115
117
|
- lib/geet/services/merge_pr.rb
|
116
118
|
- lib/geet/services/open_pr.rb
|
119
|
+
- lib/geet/services/open_repo.rb
|
117
120
|
- lib/geet/shared/branches.rb
|
118
121
|
- lib/geet/shared/http_error.rb
|
119
122
|
- lib/geet/shared/repo_permissions.rb
|
@@ -135,6 +138,7 @@ files:
|
|
135
138
|
- spec/integration/list_prs_spec.rb
|
136
139
|
- spec/integration/merge_pr_spec.rb
|
137
140
|
- spec/integration/open_pr_spec.rb
|
141
|
+
- spec/integration/open_repo_spec.rb
|
138
142
|
- spec/spec_helper.rb
|
139
143
|
- spec/vcr_cassettes/create_gist_private.yml
|
140
144
|
- spec/vcr_cassettes/create_gist_public.yml
|
@@ -187,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
191
|
- !ruby/object:Gem::Version
|
188
192
|
version: '0'
|
189
193
|
requirements: []
|
190
|
-
rubygems_version: 3.
|
194
|
+
rubygems_version: 3.2.3
|
191
195
|
signing_key:
|
192
196
|
specification_version: 4
|
193
197
|
summary: Commandline interface for performing SCM host operations, eg. create a PR
|