geet 0.27.8 → 0.28.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/.github/workflows/ci.yml +0 -1
- data/README.md +8 -17
- data/geet.gemspec +1 -1
- data/lib/geet/git/repository.rb +36 -70
- data/lib/geet/helpers/services_workflow_helper.rb +1 -1
- data/lib/geet/services/add_upstream_repo.rb +1 -1
- data/lib/geet/services/close_milestones.rb +1 -1
- data/lib/geet/services/comment_pr.rb +1 -1
- data/lib/geet/services/create_issue.rb +27 -28
- data/lib/geet/services/create_label.rb +2 -2
- data/lib/geet/services/create_milestone.rb +2 -2
- data/lib/geet/services/create_pr.rb +20 -27
- data/lib/geet/services/list_issues.rb +3 -3
- data/lib/geet/services/list_labels.rb +1 -1
- data/lib/geet/services/list_milestones.rb +7 -7
- data/lib/geet/services/list_prs.rb +1 -1
- data/lib/geet/services/merge_pr.rb +2 -2
- data/lib/geet/services/open_pr.rb +1 -1
- data/lib/geet/utils/git_client.rb +0 -11
- data/lib/geet/version.rb +1 -1
- data/spec/integration/create_label_spec.rb +0 -21
- data/spec/integration/create_pr_spec.rb +0 -1
- data/spec/integration/list_issues_spec.rb +0 -46
- data/spec/integration/list_labels_spec.rb +0 -27
- data/spec/integration/list_milestones_spec.rb +0 -27
- data/spec/integration/merge_pr_spec.rb +0 -30
- data/spec/spec_helper.rb +0 -3
- metadata +2 -16
- data/lib/geet/github/remote_repository.rb +0 -53
- data/lib/geet/gitlab/api_interface.rb +0 -212
- data/lib/geet/gitlab/issue.rb +0 -62
- data/lib/geet/gitlab/label.rb +0 -66
- data/lib/geet/gitlab/milestone.rb +0 -78
- data/lib/geet/gitlab/pr.rb +0 -114
- data/lib/geet/gitlab/user.rb +0 -52
- data/lib/geet/services/abstract_create_issue.rb +0 -21
- data/spec/vcr_cassettes/gitlab_com/create_label.yml +0 -64
- data/spec/vcr_cassettes/gitlab_com/list_issues.yml +0 -84
- data/spec/vcr_cassettes/gitlab_com/list_issues_with_assignee.yml +0 -162
- data/spec/vcr_cassettes/gitlab_com/list_labels.yml +0 -80
- data/spec/vcr_cassettes/gitlab_com/list_milestones.yml +0 -397
- data/spec/vcr_cassettes/gitlab_com/merge_pr.yml +0 -144
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5af59384cc84e82fee578187c950ad9577ef3a8347427aad991e7e3edca96d3
|
|
4
|
+
data.tar.gz: 965ffc1c1104b4fe68f35c5cb8790bb511d7d0185567c3f0f2385a57526c4a85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 702523e7d54a5201164cc033d867c84d3828b231a580bbb7209e6cf262b6dbf55e94c39e98451d9ff90338915e2becce512208ac758a78ffca90485cb2883faa
|
|
7
|
+
data.tar.gz: 89bf9a2642425d9f33de1cad5b0a28c05aa7fd4de3409c2d1dcc09d84adbe597d72718f2a91d2d5d9f1613ac657bc53fd0d8f63c0435635eddab564342703bf6
|
data/.github/workflows/ci.yml
CHANGED
data/README.md
CHANGED
|
@@ -2,28 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
# Geet
|
|
4
4
|
|
|
5
|
-
Command line interface for performing
|
|
5
|
+
Command line interface for performing GitHub operations.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
In the past, Geet supported multiple providers, including GitLab; it was originally conceived as a provider-independent version of [Hub](https://github.com/github/hub) and [Lab](https://github.com/zaquestion/lab).
|
|
8
8
|
|
|
9
9
|
## Development status/plan
|
|
10
10
|
|
|
11
|
-
The current focus is implementing Gitlab functionalities (0.3.x series).
|
|
12
|
-
|
|
13
11
|
Everything is tracked in detail via [issues](https://github.com/saveriomiroddi/geet/issues) and [milestones](https://github.com/saveriomiroddi/geet/milestones).
|
|
14
12
|
|
|
15
|
-
##
|
|
16
|
-
|
|
17
|
-
The functionalities currently supported are:
|
|
13
|
+
## Supported operations
|
|
18
14
|
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- open repository
|
|
24
|
-
- Github:
|
|
25
|
-
- comment PR
|
|
26
|
-
- create gist, issue, milestone, PR
|
|
15
|
+
- create label, gist, issue, milestone, PR
|
|
16
|
+
- list issues, labels, milestones, PRs
|
|
17
|
+
- merge PR, comment PR
|
|
18
|
+
- open repository
|
|
27
19
|
|
|
28
20
|
## Samples
|
|
29
21
|
|
|
@@ -31,8 +23,7 @@ The functionalities currently supported are:
|
|
|
31
23
|
|
|
32
24
|
Geet requires the API token environment variable to be set, eg:
|
|
33
25
|
|
|
34
|
-
export GITHUB_API_TOKEN=0123456789abcdef0123456789abcdef
|
|
35
|
-
export GITLAB_API_TOKEN=0123456789abcd-ef0-1 # for GitLab
|
|
26
|
+
export GITHUB_API_TOKEN=0123456789abcdef0123456789abcdef
|
|
36
27
|
|
|
37
28
|
All the commands need to be run from the git repository.
|
|
38
29
|
|
data/geet.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
|
9
9
|
s.required_ruby_version = ">= 3.2.0"
|
|
10
10
|
s.authors = ["Saverio Miroddi"]
|
|
11
|
-
s.date = "2026-02-
|
|
11
|
+
s.date = "2026-02-21"
|
|
12
12
|
s.email = ["saverio.pub2@gmail.com"]
|
|
13
13
|
s.homepage = "https://github.com/saveriomiroddi/geet"
|
|
14
14
|
s.summary = "Commandline interface for performing SCM host operations, eg. create a PR on GitHub"
|
data/lib/geet/git/repository.rb
CHANGED
|
@@ -37,14 +37,14 @@ module Geet
|
|
|
37
37
|
|
|
38
38
|
# REMOTE FUNCTIONALITIES (REPOSITORY)
|
|
39
39
|
|
|
40
|
-
sig { returns(T
|
|
40
|
+
sig { returns(T::Array[Github::User]) }
|
|
41
41
|
def collaborators
|
|
42
|
-
|
|
42
|
+
Github::User.list_collaborators(api_interface)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
sig { returns(T
|
|
45
|
+
sig { returns(T::Array[Github::Label]) }
|
|
46
46
|
def labels
|
|
47
|
-
|
|
47
|
+
Github::Label.list(api_interface)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
sig {
|
|
@@ -52,13 +52,13 @@ module Geet
|
|
|
52
52
|
title: String,
|
|
53
53
|
description: String
|
|
54
54
|
)
|
|
55
|
-
.returns(
|
|
55
|
+
.returns(Github::Issue)
|
|
56
56
|
}
|
|
57
57
|
def create_issue(title, description)
|
|
58
58
|
confirm(LOCAL_ACTION_ON_UPSTREAM_REPOSITORY_MESSAGE) if local_action_on_upstream_repository? && @warnings
|
|
59
59
|
confirm(ACTION_ON_PROTECTED_REPOSITORY_MESSAGE) if action_on_protected_repository? && @warnings
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
Github::Issue.create(title, description, api_interface)
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
sig {
|
|
@@ -66,46 +66,46 @@ module Geet
|
|
|
66
66
|
name: String,
|
|
67
67
|
color: String
|
|
68
68
|
)
|
|
69
|
-
.returns(
|
|
69
|
+
.returns(Github::Label)
|
|
70
70
|
}
|
|
71
71
|
def create_label(name, color)
|
|
72
|
-
|
|
72
|
+
Github::Label.create(name, color, api_interface)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
sig { params(name: String).void }
|
|
76
76
|
def delete_branch(name)
|
|
77
|
-
|
|
77
|
+
Github::Branch.delete(name, api_interface)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
sig {
|
|
81
81
|
params(
|
|
82
|
-
assignee: T.nilable(
|
|
83
|
-
milestone: T.nilable(
|
|
82
|
+
assignee: T.nilable(Github::User),
|
|
83
|
+
milestone: T.nilable(Github::Milestone)
|
|
84
84
|
)
|
|
85
|
-
.returns(T
|
|
85
|
+
.returns(T::Array[Github::AbstractIssue])
|
|
86
86
|
}
|
|
87
87
|
def issues(assignee: nil, milestone: nil)
|
|
88
|
-
|
|
88
|
+
Github::Issue.list(api_interface, assignee:, milestone:)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
sig {
|
|
92
92
|
params(
|
|
93
93
|
title: String
|
|
94
94
|
)
|
|
95
|
-
.returns(
|
|
95
|
+
.returns(Github::Milestone)
|
|
96
96
|
}
|
|
97
97
|
def create_milestone(title)
|
|
98
|
-
|
|
98
|
+
Github::Milestone.create(title, api_interface)
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
sig { returns(T
|
|
101
|
+
sig { returns(T::Array[Github::Milestone]) }
|
|
102
102
|
def milestones
|
|
103
|
-
|
|
103
|
+
Github::Milestone.list(api_interface)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
sig { params(number: Integer).void }
|
|
107
107
|
def close_milestone(number)
|
|
108
|
-
|
|
108
|
+
Github::Milestone.close(number, api_interface)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
sig {
|
|
@@ -116,39 +116,42 @@ module Geet
|
|
|
116
116
|
base: String, # target branch
|
|
117
117
|
draft: T::Boolean
|
|
118
118
|
)
|
|
119
|
-
.returns(
|
|
119
|
+
.returns(Github::PR)
|
|
120
120
|
}
|
|
121
121
|
def create_pr(title, description, head, base, draft)
|
|
122
122
|
confirm(LOCAL_ACTION_ON_UPSTREAM_REPOSITORY_MESSAGE) if local_action_on_upstream_repository? && @warnings
|
|
123
123
|
confirm(ACTION_ON_PROTECTED_REPOSITORY_MESSAGE) if action_on_protected_repository? && @warnings
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
Github::PR.create(title, description, head, api_interface, base, draft: draft)
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
sig {
|
|
129
129
|
params(
|
|
130
130
|
owner: T.nilable(String), # filter by repository owner
|
|
131
131
|
head: T.nilable(String), # filter by source branch
|
|
132
|
-
milestone: T.nilable(
|
|
132
|
+
milestone: T.nilable(Github::Milestone)
|
|
133
133
|
)
|
|
134
|
-
.returns(T
|
|
134
|
+
.returns(T::Array[Github::PR])
|
|
135
135
|
}
|
|
136
136
|
def prs(owner: nil, head: nil, milestone: nil)
|
|
137
|
-
|
|
137
|
+
Github::PR.list(api_interface, owner:, head:, milestone:)
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
# Returns the
|
|
140
|
+
# Returns the parent repository path, or nil if this is not a fork.
|
|
141
141
|
#
|
|
142
|
-
sig { returns(
|
|
143
|
-
def
|
|
144
|
-
|
|
142
|
+
sig { returns(T.nilable(String)) }
|
|
143
|
+
def parent_path
|
|
144
|
+
api_path = "/repos/#{api_interface.repository_path}"
|
|
145
|
+
response = T.cast(api_interface.send_request(api_path), T::Hash[String, T.untyped])
|
|
146
|
+
parent_hash = T.cast(response["parent"], T.nilable(T::Hash[String, T.untyped]))
|
|
147
|
+
T.cast(parent_hash&.fetch("full_name"), T.nilable(String))
|
|
145
148
|
end
|
|
146
149
|
|
|
147
150
|
# REMOTE FUNCTIONALITIES (ACCOUNT)
|
|
148
151
|
|
|
149
152
|
sig { returns(Github::User) }
|
|
150
153
|
def authenticated_user
|
|
151
|
-
|
|
154
|
+
Github::User.authenticated(api_interface)
|
|
152
155
|
end
|
|
153
156
|
|
|
154
157
|
# OTHER/CONVENIENCE FUNCTIONALITIES
|
|
@@ -169,41 +172,6 @@ module Geet
|
|
|
169
172
|
|
|
170
173
|
private
|
|
171
174
|
|
|
172
|
-
# PROVIDER
|
|
173
|
-
|
|
174
|
-
sig { returns(String) }
|
|
175
|
-
def extract_env_api_token
|
|
176
|
-
env_variable_name = "#{provider_name.upcase}_API_TOKEN"
|
|
177
|
-
|
|
178
|
-
ENV[env_variable_name] || raise("#{env_variable_name} not set!")
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
# Attempt to find the provider class and send the specified method, returning a friendly
|
|
182
|
-
# error (functionality X [Y] is missing) when a class/method is missing.
|
|
183
|
-
sig { params(class_name: Symbol, meth: Symbol, args: T.untyped).returns(T.untyped) }
|
|
184
|
-
def attempt_provider_call(class_name, meth, *args)
|
|
185
|
-
module_name = provider_name.capitalize
|
|
186
|
-
|
|
187
|
-
full_class_name = "Geet::#{module_name}::#{class_name}"
|
|
188
|
-
|
|
189
|
-
# Use const_get directly to trigger Zeitwerk autoloading
|
|
190
|
-
begin
|
|
191
|
-
klass = Object.const_get(full_class_name)
|
|
192
|
-
rescue NameError
|
|
193
|
-
raise "The class referenced (#{full_class_name}) is not currently supported!"
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
if !klass.respond_to?(meth)
|
|
197
|
-
raise "The functionality invoked (#{class_name}.#{meth}) is not currently supported!"
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
# Can't use ruby2_keywords, because the method definitions use named keyword arguments.
|
|
201
|
-
#
|
|
202
|
-
kwargs = args.last.is_a?(Hash) ? args.pop : {}
|
|
203
|
-
|
|
204
|
-
klass.send(meth, *args, **kwargs)
|
|
205
|
-
end
|
|
206
|
-
|
|
207
175
|
# WARNINGS
|
|
208
176
|
|
|
209
177
|
sig { params(message: String).void }
|
|
@@ -226,17 +194,15 @@ module Geet
|
|
|
226
194
|
|
|
227
195
|
# OTHER HELPERS
|
|
228
196
|
|
|
229
|
-
sig { returns(
|
|
197
|
+
sig { returns(Github::ApiInterface) }
|
|
230
198
|
def api_interface
|
|
231
|
-
|
|
232
|
-
|
|
199
|
+
@api_interface = T.let(@api_interface, T.nilable(Github::ApiInterface))
|
|
200
|
+
@api_interface ||= Github::ApiInterface.new(@api_token, repo_path: @git_client.path(upstream: @upstream), upstream: @upstream)
|
|
233
201
|
end
|
|
234
202
|
|
|
235
|
-
# Bare downcase provider name, eg. `github`
|
|
236
|
-
#
|
|
237
203
|
sig { returns(String) }
|
|
238
|
-
def
|
|
239
|
-
|
|
204
|
+
def extract_env_api_token
|
|
205
|
+
ENV["GITHUB_API_TOKEN"] || raise("GITHUB_API_TOKEN not set!")
|
|
240
206
|
end
|
|
241
207
|
end
|
|
242
208
|
end
|
|
@@ -21,7 +21,7 @@ module Geet
|
|
|
21
21
|
def execute
|
|
22
22
|
raise "Upstream remote already existing!" if @git_client.remote_defined?(Utils::GitClient::UPSTREAM_NAME)
|
|
23
23
|
|
|
24
|
-
parent_path = @repository.
|
|
24
|
+
parent_path = @repository.parent_path
|
|
25
25
|
|
|
26
26
|
if parent_path
|
|
27
27
|
parent_url = compose_parent_url(parent_path)
|
|
@@ -31,7 +31,7 @@ module Geet
|
|
|
31
31
|
|
|
32
32
|
selection_manager.add_attribute(:milestones, "milestone", numbers, SELECTION_MULTIPLE, name_method: :title)
|
|
33
33
|
|
|
34
|
-
milestones = T.cast(selection_manager.select_attributes[0], T::Array[
|
|
34
|
+
milestones = T.cast(selection_manager.select_attributes[0], T::Array[Github::Milestone])
|
|
35
35
|
|
|
36
36
|
milestones.map(&:number)
|
|
37
37
|
end
|
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
|
|
4
4
|
module Geet
|
|
5
5
|
module Services
|
|
6
|
-
class CreateIssue
|
|
6
|
+
class CreateIssue
|
|
7
7
|
extend T::Sig
|
|
8
8
|
|
|
9
|
+
include Geet::Helpers::OsHelper
|
|
9
10
|
include Geet::Shared::RepoPermissions
|
|
10
11
|
include Geet::Shared::Selection
|
|
11
12
|
|
|
13
|
+
sig { params(repository: Git::Repository, out: T.any(IO, StringIO)).void }
|
|
14
|
+
def initialize(repository, out: $stdout)
|
|
15
|
+
@repository = repository
|
|
16
|
+
@out = out
|
|
17
|
+
end
|
|
18
|
+
|
|
12
19
|
sig {
|
|
13
20
|
params(
|
|
14
21
|
title: String,
|
|
@@ -17,7 +24,7 @@ module Geet
|
|
|
17
24
|
milestone: T.nilable(String), # Number or description pattern
|
|
18
25
|
assignees: T.nilable(String),
|
|
19
26
|
open_browser: T::Boolean
|
|
20
|
-
).returns(
|
|
27
|
+
).returns(Github::Issue)
|
|
21
28
|
}
|
|
22
29
|
def execute(
|
|
23
30
|
title, description,
|
|
@@ -60,9 +67,9 @@ module Geet
|
|
|
60
67
|
milestone: T.nilable(String),
|
|
61
68
|
assignees: T.nilable(String)
|
|
62
69
|
).returns([
|
|
63
|
-
T.nilable(T::Array[
|
|
64
|
-
T.nilable(
|
|
65
|
-
T.nilable(T::Array[
|
|
70
|
+
T.nilable(T::Array[Github::Label]),
|
|
71
|
+
T.nilable(Github::Milestone),
|
|
72
|
+
T.nilable(T::Array[Github::User]),
|
|
66
73
|
])
|
|
67
74
|
}
|
|
68
75
|
def find_and_select_attributes(labels, milestone, assignees)
|
|
@@ -74,9 +81,9 @@ module Geet
|
|
|
74
81
|
|
|
75
82
|
selected_attributes = selection_manager.select_attributes
|
|
76
83
|
|
|
77
|
-
selected_labels = T.cast(selected_attributes.shift, T.nilable(T::Array[
|
|
78
|
-
selected_milestone = T.cast(selected_attributes.shift, T.nilable(
|
|
79
|
-
selected_assignees = T.cast(selected_attributes.shift, T.nilable(T::Array[
|
|
84
|
+
selected_labels = T.cast(selected_attributes.shift, T.nilable(T::Array[Github::Label])) if labels
|
|
85
|
+
selected_milestone = T.cast(selected_attributes.shift, T.nilable(Github::Milestone)) if milestone
|
|
86
|
+
selected_assignees = T.cast(selected_attributes.shift, T.nilable(T::Array[Github::User])) if assignees
|
|
80
87
|
|
|
81
88
|
[selected_labels, selected_milestone, selected_assignees]
|
|
82
89
|
end
|
|
@@ -85,7 +92,7 @@ module Geet
|
|
|
85
92
|
params(
|
|
86
93
|
title: String,
|
|
87
94
|
description: String
|
|
88
|
-
).returns(
|
|
95
|
+
).returns(Github::Issue)
|
|
89
96
|
}
|
|
90
97
|
def create_issue(title, description)
|
|
91
98
|
@out.puts "Creating the issue..."
|
|
@@ -95,10 +102,10 @@ module Geet
|
|
|
95
102
|
|
|
96
103
|
sig {
|
|
97
104
|
params(
|
|
98
|
-
issue:
|
|
99
|
-
labels: T.nilable(T::Array[
|
|
100
|
-
milestone: T.nilable(
|
|
101
|
-
assignees: T.nilable(T::Array[
|
|
105
|
+
issue: Github::Issue,
|
|
106
|
+
labels: T.nilable(T::Array[Github::Label]),
|
|
107
|
+
milestone: T.nilable(Github::Milestone),
|
|
108
|
+
assignees: T.nilable(T::Array[Github::User])
|
|
102
109
|
).void
|
|
103
110
|
}
|
|
104
111
|
def edit_issue(issue, labels, milestone, assignees)
|
|
@@ -121,13 +128,11 @@ module Geet
|
|
|
121
128
|
|
|
122
129
|
sig {
|
|
123
130
|
params(
|
|
124
|
-
issue:
|
|
125
|
-
selected_labels: T::Array[
|
|
131
|
+
issue: Github::Issue,
|
|
132
|
+
selected_labels: T::Array[Github::Label]
|
|
126
133
|
).returns(Thread)
|
|
127
134
|
}
|
|
128
135
|
def add_labels(issue, selected_labels)
|
|
129
|
-
raise "Functionality unsupported on GitLab!" if issue.is_a?(Gitlab::Issue)
|
|
130
|
-
|
|
131
136
|
labels_list = selected_labels.map(&:name).join(", ")
|
|
132
137
|
|
|
133
138
|
@out.puts "Adding labels #{labels_list}..."
|
|
@@ -139,13 +144,11 @@ module Geet
|
|
|
139
144
|
|
|
140
145
|
sig {
|
|
141
146
|
params(
|
|
142
|
-
issue:
|
|
143
|
-
milestone:
|
|
147
|
+
issue: Github::Issue,
|
|
148
|
+
milestone: Github::Milestone
|
|
144
149
|
).returns(Thread)
|
|
145
150
|
}
|
|
146
151
|
def set_milestone(issue, milestone)
|
|
147
|
-
raise "Functionality unsupported on GitLab!" if issue.is_a?(Gitlab::Issue)
|
|
148
|
-
|
|
149
152
|
@out.puts "Setting milestone #{milestone.title}..."
|
|
150
153
|
|
|
151
154
|
Thread.new do
|
|
@@ -155,13 +158,11 @@ module Geet
|
|
|
155
158
|
|
|
156
159
|
sig {
|
|
157
160
|
params(
|
|
158
|
-
issue:
|
|
159
|
-
users: T::Array[
|
|
161
|
+
issue: Github::Issue,
|
|
162
|
+
users: T::Array[Github::User]
|
|
160
163
|
).returns(Thread)
|
|
161
164
|
}
|
|
162
165
|
def assign_users(issue, users)
|
|
163
|
-
raise "Functionality unsupported on GitLab!" if issue.is_a?(Gitlab::Issue)
|
|
164
|
-
|
|
165
166
|
usernames = users.map(&:username)
|
|
166
167
|
|
|
167
168
|
@out.puts "Assigning users #{usernames.join(', ')}..."
|
|
@@ -173,12 +174,10 @@ module Geet
|
|
|
173
174
|
|
|
174
175
|
sig {
|
|
175
176
|
params(
|
|
176
|
-
issue:
|
|
177
|
+
issue: Github::Issue
|
|
177
178
|
).returns(Thread)
|
|
178
179
|
}
|
|
179
180
|
def assign_authenticated_user(issue)
|
|
180
|
-
raise "Functionality unsupported on GitLab!" if issue.is_a?(Gitlab::Issue)
|
|
181
|
-
|
|
182
181
|
@out.puts "Assigning authenticated user..."
|
|
183
182
|
|
|
184
183
|
Thread.new do
|
|
@@ -17,7 +17,7 @@ module Geet
|
|
|
17
17
|
name: String,
|
|
18
18
|
color: String
|
|
19
19
|
)
|
|
20
|
-
.returns(
|
|
20
|
+
.returns(Github::Label)
|
|
21
21
|
}
|
|
22
22
|
def execute(name, color: generate_random_color)
|
|
23
23
|
label = create_label(name, color)
|
|
@@ -34,7 +34,7 @@ module Geet
|
|
|
34
34
|
name: String,
|
|
35
35
|
color: String
|
|
36
36
|
)
|
|
37
|
-
.returns(
|
|
37
|
+
.returns(Github::Label)
|
|
38
38
|
}
|
|
39
39
|
def create_label(name, color)
|
|
40
40
|
@out.puts "Creating label..."
|
|
@@ -12,14 +12,14 @@ module Geet
|
|
|
12
12
|
@out = out
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
sig { params(title: String).returns(
|
|
15
|
+
sig { params(title: String).returns(Github::Milestone) }
|
|
16
16
|
def execute(title)
|
|
17
17
|
create_milestone(title)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
private
|
|
21
21
|
|
|
22
|
-
sig { params(title: String).returns(
|
|
22
|
+
sig { params(title: String).returns(Github::Milestone) }
|
|
23
23
|
def create_milestone(title)
|
|
24
24
|
@out.puts "Creating milestone..."
|
|
25
25
|
|
|
@@ -5,9 +5,10 @@ require "io/console" # stdlib
|
|
|
5
5
|
|
|
6
6
|
module Geet
|
|
7
7
|
module Services
|
|
8
|
-
class CreatePr
|
|
8
|
+
class CreatePr
|
|
9
9
|
extend T::Sig
|
|
10
10
|
|
|
11
|
+
include Geet::Helpers::OsHelper
|
|
11
12
|
include Geet::Shared::RepoPermissions
|
|
12
13
|
include Geet::Shared::Selection
|
|
13
14
|
|
|
@@ -16,12 +17,12 @@ module Geet
|
|
|
16
17
|
sig {
|
|
17
18
|
params(
|
|
18
19
|
repository: Git::Repository,
|
|
19
|
-
out: IO,
|
|
20
|
+
out: T.any(IO, StringIO),
|
|
20
21
|
git_client: Utils::GitClient
|
|
21
22
|
).void
|
|
22
23
|
}
|
|
23
24
|
def initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT)
|
|
24
|
-
|
|
25
|
+
@repository = repository
|
|
25
26
|
@git_client = git_client
|
|
26
27
|
@out = out
|
|
27
28
|
end
|
|
@@ -38,7 +39,7 @@ module Geet
|
|
|
38
39
|
open_browser: T::Boolean,
|
|
39
40
|
automerge: T::Boolean,
|
|
40
41
|
_: T.untyped,
|
|
41
|
-
).returns(
|
|
42
|
+
).returns(Github::PR)
|
|
42
43
|
}
|
|
43
44
|
def execute(
|
|
44
45
|
title, description, labels: nil, milestone: nil, reviewers: nil,
|
|
@@ -95,9 +96,9 @@ module Geet
|
|
|
95
96
|
milestone: T.nilable(String),
|
|
96
97
|
reviewers: T.nilable(String)
|
|
97
98
|
).returns([
|
|
98
|
-
T.nilable(T::Array[
|
|
99
|
-
T.nilable(
|
|
100
|
-
T.nilable(T::Array[
|
|
99
|
+
T.nilable(T::Array[Github::Label]),
|
|
100
|
+
T.nilable(Github::Milestone),
|
|
101
|
+
T.nilable(T::Array[Github::User]),
|
|
101
102
|
])
|
|
102
103
|
}
|
|
103
104
|
def find_and_select_attributes(labels, milestone, reviewers)
|
|
@@ -187,7 +188,7 @@ module Geet
|
|
|
187
188
|
description: String,
|
|
188
189
|
base: T.nilable(String),
|
|
189
190
|
draft: T::Boolean
|
|
190
|
-
).returns(
|
|
191
|
+
).returns(Github::PR)
|
|
191
192
|
}
|
|
192
193
|
def create_pr(title, description, base:, draft:)
|
|
193
194
|
@out.puts "Creating PR..."
|
|
@@ -199,10 +200,10 @@ module Geet
|
|
|
199
200
|
|
|
200
201
|
sig {
|
|
201
202
|
params(
|
|
202
|
-
pr:
|
|
203
|
-
labels: T.nilable(T::Array[
|
|
204
|
-
milestone: T.nilable(
|
|
205
|
-
reviewers: T.nilable(T::Array[
|
|
203
|
+
pr: Github::PR,
|
|
204
|
+
labels: T.nilable(T::Array[Github::Label]),
|
|
205
|
+
milestone: T.nilable(Github::Milestone),
|
|
206
|
+
reviewers: T.nilable(T::Array[Github::User])
|
|
206
207
|
).void
|
|
207
208
|
}
|
|
208
209
|
def edit_pr(pr, labels, milestone, reviewers)
|
|
@@ -219,13 +220,11 @@ module Geet
|
|
|
219
220
|
|
|
220
221
|
sig {
|
|
221
222
|
params(
|
|
222
|
-
pr:
|
|
223
|
-
selected_labels: T::Array[
|
|
223
|
+
pr: Github::PR,
|
|
224
|
+
selected_labels: T::Array[Github::Label]
|
|
224
225
|
).returns(Thread)
|
|
225
226
|
}
|
|
226
227
|
def add_labels(pr, selected_labels)
|
|
227
|
-
raise "Functionality unsupported on GitLab!" if pr.is_a?(Gitlab::PR)
|
|
228
|
-
|
|
229
228
|
labels_list = selected_labels.map(&:name).join(", ")
|
|
230
229
|
|
|
231
230
|
@out.puts "Adding labels #{labels_list}..."
|
|
@@ -237,13 +236,11 @@ module Geet
|
|
|
237
236
|
|
|
238
237
|
sig {
|
|
239
238
|
params(
|
|
240
|
-
pr:
|
|
241
|
-
milestone:
|
|
239
|
+
pr: Github::PR,
|
|
240
|
+
milestone: Github::Milestone
|
|
242
241
|
).returns(Thread)
|
|
243
242
|
}
|
|
244
243
|
def set_milestone(pr, milestone)
|
|
245
|
-
raise "Functionality unsupported on GitLab!" if pr.is_a?(Gitlab::PR)
|
|
246
|
-
|
|
247
244
|
@out.puts "Setting milestone #{milestone.title}..."
|
|
248
245
|
|
|
249
246
|
Thread.new do
|
|
@@ -253,13 +250,11 @@ module Geet
|
|
|
253
250
|
|
|
254
251
|
sig {
|
|
255
252
|
params(
|
|
256
|
-
pr:
|
|
257
|
-
reviewers: T::Array[
|
|
253
|
+
pr: Github::PR,
|
|
254
|
+
reviewers: T::Array[Github::User]
|
|
258
255
|
).returns(Thread)
|
|
259
256
|
}
|
|
260
257
|
def request_review(pr, reviewers)
|
|
261
|
-
raise "Functionality unsupported on GitLab!" if pr.is_a?(Gitlab::PR)
|
|
262
|
-
|
|
263
258
|
reviewer_usernames = reviewers.map(&:username)
|
|
264
259
|
|
|
265
260
|
@out.puts "Requesting review from #{reviewer_usernames.join(', ')}..."
|
|
@@ -271,12 +266,10 @@ module Geet
|
|
|
271
266
|
|
|
272
267
|
sig {
|
|
273
268
|
params(
|
|
274
|
-
pr:
|
|
269
|
+
pr: Github::PR
|
|
275
270
|
).void
|
|
276
271
|
}
|
|
277
272
|
def enable_automerge(pr)
|
|
278
|
-
raise "Functionality unsupported on GitLab!" if pr.is_a?(Gitlab::PR)
|
|
279
|
-
|
|
280
273
|
if !pr.respond_to?(:enable_automerge)
|
|
281
274
|
raise "Automerge is not supported for this repository provider"
|
|
282
275
|
elsif !pr.respond_to?(:node_id) || pr.node_id.nil?
|
|
@@ -23,7 +23,7 @@ module Geet
|
|
|
23
23
|
params(
|
|
24
24
|
assignee: T.nilable(String)
|
|
25
25
|
)
|
|
26
|
-
.returns(T
|
|
26
|
+
.returns(T::Array[Github::AbstractIssue])
|
|
27
27
|
}
|
|
28
28
|
def execute(assignee: nil)
|
|
29
29
|
selected_assignee = find_and_select_attributes(assignee) if assignee
|
|
@@ -40,14 +40,14 @@ module Geet
|
|
|
40
40
|
sig {
|
|
41
41
|
params(
|
|
42
42
|
assignee: String
|
|
43
|
-
).returns(
|
|
43
|
+
).returns(Github::User)
|
|
44
44
|
}
|
|
45
45
|
def find_and_select_attributes(assignee)
|
|
46
46
|
selection_manager = Geet::Utils::AttributesSelectionManager.new(@repository, out: @out)
|
|
47
47
|
|
|
48
48
|
selection_manager.add_attribute(:collaborators, "assignee", assignee, SELECTION_SINGLE, name_method: :username)
|
|
49
49
|
|
|
50
|
-
T.cast(selection_manager.select_attributes[0],
|
|
50
|
+
T.cast(selection_manager.select_attributes[0], Github::User)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|