geet 0.18.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/bin/geet +3 -3
- data/geet.gemspec +1 -1
- data/lib/geet/commandline/configuration.rb +1 -0
- data/lib/geet/github/pr.rb +3 -2
- data/lib/geet/services/merge_pr.rb +22 -7
- data/lib/geet/utils/git_client.rb +14 -8
- data/lib/geet/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 553ba26732cdeab337b64fd735017cbb2e3746e2cfe9558fd6cbcac2ed1e56ae
|
4
|
+
data.tar.gz: 2c3d92f60356d1b5664990cdc15b3ea8782c33e5e48d5c22b6938ebee10a8d71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d20437f87b87cc0e3787383e3fdb1739a5447e9743dc11d790eb76b7241c5802333c37724a428882826c4446b7dc701dc3f4698ca968cf0f4836b994d22921
|
7
|
+
data.tar.gz: 6cee56626453e242679c187a61087322f904427529262fcaf66b2b679a2391430a962809e5809b7a46c4e29075221e1a9a388edc46bf2ba8bd9334d4aeb7b475
|
data/Gemfile
CHANGED
data/bin/geet
CHANGED
@@ -65,7 +65,7 @@ class GeetLauncher
|
|
65
65
|
|
66
66
|
Services::CommentPr.new(repository).execute(comment, **options)
|
67
67
|
when PR_CREATE_COMMAND
|
68
|
-
summary = options[:summary] || edit_pr_summary(
|
68
|
+
summary = options[:summary] || edit_pr_summary(**options.slice(:base))
|
69
69
|
title, description = split_summary(summary)
|
70
70
|
|
71
71
|
options = default_to_manual_selection(options, :labels, :milestone, :reviewers)
|
@@ -90,11 +90,11 @@ class GeetLauncher
|
|
90
90
|
|
91
91
|
private
|
92
92
|
|
93
|
-
def edit_pr_summary(base:
|
93
|
+
def edit_pr_summary(base: :main_branch)
|
94
94
|
# Tricky. It would be best to have Git logic exlusively inside the services,
|
95
95
|
# but at the same time, the summary editing should be out.
|
96
96
|
git = Utils::GitClient.new
|
97
|
-
pr_commits = git.cherry(base
|
97
|
+
pr_commits = git.cherry(base)
|
98
98
|
|
99
99
|
cancel_pr_help = "In order to cancel the PR creation, delete the description above.\n"
|
100
100
|
|
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.7.0'
|
12
12
|
s.authors = ['Saverio Miroddi']
|
13
|
-
s.date = '
|
13
|
+
s.date = '2024-08-23'
|
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'
|
@@ -93,6 +93,7 @@ module Geet
|
|
93
93
|
# rubocop:disable Style/MutableConstant
|
94
94
|
PR_MERGE_OPTIONS = [
|
95
95
|
['-d', '--delete-branch', 'Delete the branch after merging'],
|
96
|
+
['-s', '--squash', 'Squash merge'],
|
96
97
|
['-u', '--upstream', 'List on the upstream repository'],
|
97
98
|
long_help: 'Merge the PR for the current branch'
|
98
99
|
]
|
data/lib/geet/github/pr.rb
CHANGED
@@ -72,10 +72,11 @@ module Geet
|
|
72
72
|
|
73
73
|
# See https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
|
74
74
|
#
|
75
|
-
def merge
|
75
|
+
def merge(merge_method: nil)
|
76
76
|
api_path = "pulls/#{number}/merge"
|
77
|
+
request_data = { merge_method: } if merge_method
|
77
78
|
|
78
|
-
@api_interface.send_request(api_path, http_method: :put)
|
79
|
+
@api_interface.send_request(api_path, http_method: :put, data: request_data)
|
79
80
|
end
|
80
81
|
|
81
82
|
def request_review(reviewers)
|
@@ -22,12 +22,18 @@ module Geet
|
|
22
22
|
@git_client = git_client
|
23
23
|
end
|
24
24
|
|
25
|
-
def execute(delete_branch: false, **)
|
25
|
+
def execute(delete_branch: false, squash: false, **)
|
26
|
+
merge_method = 'squash' if squash
|
27
|
+
|
28
|
+
@git_client.fetch
|
29
|
+
|
26
30
|
@git_client.push
|
27
31
|
|
32
|
+
check_no_missing_upstream_commits
|
33
|
+
|
28
34
|
pr = checked_find_branch_pr
|
29
35
|
|
30
|
-
merge_pr(pr)
|
36
|
+
merge_pr(pr, merge_method:)
|
31
37
|
|
32
38
|
if delete_branch
|
33
39
|
branch = @git_client.current_branch
|
@@ -47,7 +53,10 @@ module Geet
|
|
47
53
|
checkout_branch(main_branch)
|
48
54
|
rebase
|
49
55
|
|
50
|
-
|
56
|
+
# When squashing, we need to force delete, since Git doesn't recognize that the branch has
|
57
|
+
# been merged.
|
58
|
+
#
|
59
|
+
delete_local_branch(pr_branch, force: squash)
|
51
60
|
end
|
52
61
|
|
53
62
|
pr
|
@@ -55,10 +64,16 @@ module Geet
|
|
55
64
|
|
56
65
|
private
|
57
66
|
|
58
|
-
def
|
67
|
+
def check_no_missing_upstream_commits
|
68
|
+
missing_upstream_commits = @git_client.cherry('HEAD', head: :main_branch)
|
69
|
+
|
70
|
+
raise "Found #{missing_upstream_commits.size} missing upstream commits!" if missing_upstream_commits.any?
|
71
|
+
end
|
72
|
+
|
73
|
+
def merge_pr(pr, merge_method: nil)
|
59
74
|
@out.puts "Merging PR ##{pr.number}..."
|
60
75
|
|
61
|
-
pr.merge
|
76
|
+
pr.merge(merge_method:)
|
62
77
|
end
|
63
78
|
|
64
79
|
def delete_remote_branch(branch)
|
@@ -85,10 +100,10 @@ module Geet
|
|
85
100
|
@git_client.rebase
|
86
101
|
end
|
87
102
|
|
88
|
-
def delete_local_branch(branch)
|
103
|
+
def delete_local_branch(branch, force:)
|
89
104
|
@out.puts "Deleting local branch #{branch}..."
|
90
105
|
|
91
|
-
@git_client.delete_branch(branch)
|
106
|
+
@git_client.delete_branch(branch, force:)
|
92
107
|
end
|
93
108
|
end
|
94
109
|
end
|
@@ -48,13 +48,19 @@ module Geet
|
|
48
48
|
# BRANCH/TREE APIS
|
49
49
|
##########################################################################
|
50
50
|
|
51
|
-
# Return the commit SHAs between
|
51
|
+
# Return the commit SHAs between :head and :upstream, excluding the already applied commits
|
52
52
|
# (which start with `-`)
|
53
53
|
#
|
54
|
-
|
55
|
-
|
54
|
+
# - upstream: String; pass :main_branch to use the main branch
|
55
|
+
# - head: String (optional); pass :main_branch to use the main branch
|
56
|
+
#
|
57
|
+
def cherry(upstream, head: nil)
|
58
|
+
upstream = main_branch if upstream == :main_branch
|
59
|
+
head = main_branch if head == :main_branch
|
60
|
+
|
61
|
+
git_params = [upstream, head].compact.map(&:shellescape)
|
56
62
|
|
57
|
-
raw_commits = execute_git_command("cherry #{
|
63
|
+
raw_commits = execute_git_command("cherry #{git_params.join(' ')}")
|
58
64
|
|
59
65
|
raw_commits.split("\n").grep(/^\+/).map { |line| line[3..-1] }
|
60
66
|
end
|
@@ -226,10 +232,10 @@ module Geet
|
|
226
232
|
execute_git_command("checkout #{branch.shellescape}")
|
227
233
|
end
|
228
234
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
execute_git_command("branch --delete #{branch.shellescape}")
|
235
|
+
def delete_branch(branch, force:)
|
236
|
+
force_option = "--force" if force
|
237
|
+
|
238
|
+
execute_git_command("branch --delete #{force_option} #{branch.shellescape}")
|
233
239
|
end
|
234
240
|
|
235
241
|
def rebase
|
data/lib/geet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saverio Miroddi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_scripting
|
@@ -175,7 +175,7 @@ homepage: https://github.com/saveriomiroddi/geet
|
|
175
175
|
licenses:
|
176
176
|
- GPL-3.0
|
177
177
|
metadata: {}
|
178
|
-
post_install_message:
|
178
|
+
post_install_message:
|
179
179
|
rdoc_options: []
|
180
180
|
require_paths:
|
181
181
|
- lib
|
@@ -190,8 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
194
|
-
signing_key:
|
193
|
+
rubygems_version: 3.5.9
|
194
|
+
signing_key:
|
195
195
|
specification_version: 4
|
196
196
|
summary: Commandline interface for performing SCM host operations, eg. create a PR
|
197
197
|
on GitHub
|