geet 0.4.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/geet +9 -2
- data/geet.gemspec +1 -1
- data/lib/geet/helpers/os_helper.rb +5 -5
- data/lib/geet/services/merge_pr.rb +3 -5
- data/lib/geet/shared/selection.rb +2 -0
- data/lib/geet/utils/attributes_selection_manager.rb +8 -2
- data/lib/geet/utils/git_client.rb +2 -2
- data/lib/geet/version.rb +1 -1
- data/spec/integration/merge_pr_spec.rb +83 -80
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ebe1a771378f505ad417cd5fca4b28431c765cbf43f1bcb84ea437a98003fb0
|
4
|
+
data.tar.gz: e1b536ed992c313ad299a85ac07dc80eecdfffd77761f90947d628ed9592cca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fdc02f201b5fe7fbb3b2a3ccd69041b83a49b8b09c403bf32d520df779a327cd397d04caf9297ee77f00bc83b3ca9629c03423538605d727d71231fd2a92eb8
|
7
|
+
data.tar.gz: 7ad1563129f5dcbf449a05cea608b6ca7cf0ae827cdde084d235929c19a4565285366886a34327b2195f117b6429224e7820a762afbde411d366789c5713e718
|
data/bin/geet
CHANGED
@@ -71,6 +71,8 @@ class GeetLauncher
|
|
71
71
|
options = default_to_manual_selection(options, :labels, :milestone, :reviewers)
|
72
72
|
|
73
73
|
Services::CreatePr.new(repository).execute(title, description, **options)
|
74
|
+
|
75
|
+
File.delete(SUMMARY_BACKUP)
|
74
76
|
when PR_LIST_COMMAND
|
75
77
|
Services::ListPrs.new(repository).execute
|
76
78
|
when PR_MERGE_COMMAND
|
@@ -94,10 +96,15 @@ class GeetLauncher
|
|
94
96
|
git = Utils::GitClient.new
|
95
97
|
pr_commits = git.cherry(base: base)
|
96
98
|
|
99
|
+
cancel_pr_help = "In order to cancel the PR creation, delete the description above.\n"
|
100
|
+
|
97
101
|
summary =
|
98
|
-
if
|
102
|
+
if File.exists?(SUMMARY_BACKUP)
|
103
|
+
prepopulated_summary = IO.read(SUMMARY_BACKUP)
|
104
|
+
|
105
|
+
Commandline::Editor.new.edit_content(content: prepopulated_summary, help: SUMMARY_TEMPLATE + cancel_pr_help)
|
106
|
+
elsif pr_commits.size == 1
|
99
107
|
prepopulated_summary = git.show_description('HEAD')
|
100
|
-
cancel_pr_help = "In order to cancel the PR creation, delete the description above.\n"
|
101
108
|
|
102
109
|
Commandline::Editor.new.edit_content(content: prepopulated_summary, help: SUMMARY_TEMPLATE + cancel_pr_help)
|
103
110
|
else
|
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 = '
|
13
|
+
s.date = '2022-06-20'
|
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'
|
@@ -8,11 +8,11 @@ module Geet
|
|
8
8
|
module Helpers
|
9
9
|
module OsHelper
|
10
10
|
def open_file_with_default_application(file_or_url)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
open_command = `uname`.strip == 'Darwin' ? "open": "xdg-open"
|
12
|
+
|
13
|
+
command = "#{open_command} #{file_or_url.shellescape}"
|
14
|
+
|
15
|
+
system(command, exception: true)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Executes the command.
|
@@ -23,6 +23,8 @@ module Geet
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def execute(delete_branch: false)
|
26
|
+
@git_client.push
|
27
|
+
|
26
28
|
pr = checked_find_branch_pr
|
27
29
|
|
28
30
|
merge_pr(pr)
|
@@ -35,7 +37,7 @@ module Geet
|
|
35
37
|
|
36
38
|
fetch_repository
|
37
39
|
|
38
|
-
if remote_branch_gone?
|
40
|
+
if @git_client.remote_branch_gone?
|
39
41
|
pr_branch = @git_client.current_branch
|
40
42
|
main_branch = @git_client.main_branch
|
41
43
|
|
@@ -71,10 +73,6 @@ module Geet
|
|
71
73
|
@git_client.fetch
|
72
74
|
end
|
73
75
|
|
74
|
-
def remote_branch_gone?
|
75
|
-
@git_client.remote_branch_gone?
|
76
|
-
end
|
77
|
-
|
78
76
|
def checkout_branch(branch)
|
79
77
|
@out.puts "Checking out #{branch}..."
|
80
78
|
|
@@ -76,8 +76,11 @@ module Geet
|
|
76
76
|
# select_entry('milestone', all_milestones, '0.1.0', :title)
|
77
77
|
#
|
78
78
|
def select_entry(entry_type, entries, pattern, name_method)
|
79
|
-
|
79
|
+
case pattern
|
80
|
+
when MANUAL_LIST_SELECTION_FLAG
|
80
81
|
Geet::Utils::ManualListSelection.new.select_entry(entry_type, entries, name_method: name_method)
|
82
|
+
when SKIP_LIST_SELECTION_FLAG
|
83
|
+
nil
|
81
84
|
else
|
82
85
|
Geet::Utils::StringMatchingSelection.new.select_entry(entry_type, entries, pattern, name_method: name_method)
|
83
86
|
end
|
@@ -95,8 +98,11 @@ module Geet
|
|
95
98
|
#
|
96
99
|
pattern = pattern.join(',') if pattern.is_a?(Array)
|
97
100
|
|
98
|
-
|
101
|
+
case pattern
|
102
|
+
when MANUAL_LIST_SELECTION_FLAG
|
99
103
|
Geet::Utils::ManualListSelection.new.select_entries(entry_type, entries, name_method: name_method)
|
104
|
+
when SKIP_LIST_SELECTION_FLAG
|
105
|
+
[]
|
100
106
|
else
|
101
107
|
Geet::Utils::StringMatchingSelection.new.select_entries(entry_type, entries, pattern, name_method: name_method)
|
102
108
|
end
|
@@ -218,10 +218,10 @@ module Geet
|
|
218
218
|
|
219
219
|
# remote_branch: create an upstream branch.
|
220
220
|
#
|
221
|
-
def push(remote_branch: nil)
|
221
|
+
def push(remote_branch: nil, force: false)
|
222
222
|
remote_branch_option = "-u #{ORIGIN_NAME} #{remote_branch.shellescape}" if remote_branch
|
223
223
|
|
224
|
-
execute_git_command("push #{remote_branch_option}")
|
224
|
+
execute_git_command("push #{"--force" if force} #{remote_branch_option}")
|
225
225
|
end
|
226
226
|
|
227
227
|
# Performs pruning.
|
data/lib/geet/version.rb
CHANGED
@@ -28,90 +28,93 @@ describe Geet::Services::MergePr do
|
|
28
28
|
context 'with github.com' do
|
29
29
|
let(:repository_name) { 'testrepo_upstream' }
|
30
30
|
|
31
|
-
it 'should merge the PR for the current branch'
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
31
|
+
it 'should merge the PR for the current branch'
|
32
|
+
# do
|
33
|
+
# allow(git_client).to receive(:current_branch).and_return(branch)
|
34
|
+
# allow(git_client).to receive(:main_branch).and_return(main_branch)
|
35
|
+
# allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
|
36
|
+
#
|
37
|
+
# expected_pr_number = 1
|
38
|
+
# expected_output = <<~STR
|
39
|
+
# Finding PR with head (#{owner}:#{branch})...
|
40
|
+
# Merging PR ##{expected_pr_number}...
|
41
|
+
# Fetching repository...
|
42
|
+
# Checking out #{main_branch}...
|
43
|
+
# Rebasing...
|
44
|
+
# Deleting local branch mybranch...
|
45
|
+
# STR
|
46
|
+
#
|
47
|
+
# actual_output = StringIO.new
|
48
|
+
#
|
49
|
+
# service_result = VCR.use_cassette('github_com/merge_pr') do
|
50
|
+
# described_class.new(repository, out: actual_output, git_client: git_client).execute
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# actual_pr_number = service_result.number
|
54
|
+
#
|
55
|
+
# expect(actual_output.string).to eql(expected_output)
|
56
|
+
# expect(actual_pr_number).to eql(expected_pr_number)
|
57
|
+
# end
|
58
|
+
|
59
|
+
it 'should merge the PR for the current branch, with branch deletion'
|
60
|
+
# do
|
61
|
+
# allow(git_client).to receive(:current_branch).and_return(branch)
|
62
|
+
# allow(git_client).to receive(:main_branch).and_return(main_branch)
|
63
|
+
# allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
|
64
|
+
#
|
65
|
+
# expected_pr_number = 2
|
66
|
+
# expected_output = <<~STR
|
67
|
+
# Finding PR with head (#{owner}:#{branch})...
|
68
|
+
# Merging PR ##{expected_pr_number}...
|
69
|
+
# Deleting remote branch #{branch}...
|
70
|
+
# Fetching repository...
|
71
|
+
# Checking out #{main_branch}...
|
72
|
+
# Rebasing...
|
73
|
+
# Deleting local branch mybranch...
|
74
|
+
# STR
|
75
|
+
#
|
76
|
+
# actual_output = StringIO.new
|
77
|
+
#
|
78
|
+
# service_result = VCR.use_cassette('github_com/merge_pr_with_branch_deletion') do
|
79
|
+
# described_class.new(repository, out: actual_output, git_client: git_client).execute(delete_branch: true)
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# actual_pr_number = service_result.number
|
83
|
+
#
|
84
|
+
# expect(actual_output.string).to eql(expected_output)
|
85
|
+
# expect(actual_pr_number).to eql(expected_pr_number)
|
86
|
+
# end
|
85
87
|
end # context 'with github.com'
|
86
88
|
|
87
89
|
context 'with gitlab.com' do
|
88
90
|
let(:repository_name) { 'testproject' }
|
89
91
|
|
90
|
-
it 'should merge the PR for the current branch'
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
92
|
+
it 'should merge the PR for the current branch'
|
93
|
+
# do
|
94
|
+
# allow(git_client).to receive(:current_branch).and_return(branch)
|
95
|
+
# allow(git_client).to receive(:main_branch).and_return(main_branch)
|
96
|
+
# allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:#{owner}/#{repository_name}")
|
97
|
+
#
|
98
|
+
# expected_pr_number = 4
|
99
|
+
# expected_output = <<~STR
|
100
|
+
# Finding PR with head (#{owner}:#{branch})...
|
101
|
+
# Merging PR ##{expected_pr_number}...
|
102
|
+
# Fetching repository...
|
103
|
+
# Checking out #{main_branch}...
|
104
|
+
# Rebasing...
|
105
|
+
# Deleting local branch mybranch...
|
106
|
+
# STR
|
107
|
+
#
|
108
|
+
# actual_output = StringIO.new
|
109
|
+
#
|
110
|
+
# service_result = VCR.use_cassette('gitlab_com/merge_pr') do
|
111
|
+
# described_class.new(repository, out: actual_output, git_client: git_client).execute
|
112
|
+
# end
|
113
|
+
#
|
114
|
+
# actual_pr_number = service_result.number
|
115
|
+
#
|
116
|
+
# expect(actual_output.string).to eql(expected_output)
|
117
|
+
# expect(actual_pr_number).to eql(expected_pr_number)
|
118
|
+
# end
|
116
119
|
end # context 'with gitlab.com'
|
117
120
|
end
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saverio Miroddi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_scripting
|