geet 0.5.0 → 0.8.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/git/repository.rb +9 -1
- data/lib/geet/helpers/os_helper.rb +5 -5
- data/lib/geet/services/create_pr.rb +7 -0
- data/lib/geet/version.rb +1 -1
- data/spec/integration/create_pr_spec.rb +55 -53
- 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: c2b76f3d154b8fe98577116cd740f14c8f26c2bae85d30935f31ba1793f79170
|
4
|
+
data.tar.gz: 8579bbfe3b1ab2af8a67d57a357b32873cc2c1b91799bebdf9dfff80b3977c3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e848275122d9762b5aea1790b4d9408025e1adb8a348ae390903fd685c4be32f130e2cac928a17ac539b86e565d362934a8bf90ebcdd5805105db8f5c77c491
|
7
|
+
data.tar.gz: 4db97dcd0fd5336a34ed2321a7499ad24365968dfb667a6392d9de87c8d088f8ff74f1f8d9d8179861184c5e9bd1a18d57eb1a497f88f5d09286ee9b8a536975
|
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 = '2022-
|
13
|
+
s.date = '2022-06-26'
|
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'
|
data/lib/geet/git/repository.rb
CHANGED
@@ -103,6 +103,14 @@ module Geet
|
|
103
103
|
@upstream
|
104
104
|
end
|
105
105
|
|
106
|
+
# For cases where it's necessary to work on the downstream repo.
|
107
|
+
#
|
108
|
+
def downstream
|
109
|
+
raise "downstream() is not available on not-upstream repositories!" if !upstream?
|
110
|
+
|
111
|
+
Git::Repository.new(upstream: false, protected_repositories: @protected_repositories)
|
112
|
+
end
|
113
|
+
|
106
114
|
private
|
107
115
|
|
108
116
|
# PROVIDER
|
@@ -159,7 +167,7 @@ module Geet
|
|
159
167
|
end
|
160
168
|
|
161
169
|
def local_action_on_upstream_repository?
|
162
|
-
@git_client.remote_defined?(
|
170
|
+
@git_client.remote_defined?(Utils::GitClient::UPSTREAM_NAME) && !@upstream
|
163
171
|
end
|
164
172
|
|
165
173
|
# OTHER HELPERS
|
@@ -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.
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'abstract_create_issue'
|
4
4
|
require_relative '../shared/repo_permissions'
|
5
5
|
require_relative '../shared/selection'
|
6
|
+
require_relative 'add_upstream_repo'
|
6
7
|
|
7
8
|
module Geet
|
8
9
|
module Services
|
@@ -29,6 +30,12 @@ module Geet
|
|
29
30
|
)
|
30
31
|
ensure_clean_tree if automated_mode
|
31
32
|
|
33
|
+
if @repository.upstream? && !@git_client.remote_defined?(Utils::GitClient::UPSTREAM_NAME)
|
34
|
+
@out.puts "Upstream not found; adding it to the repository remotes..."
|
35
|
+
|
36
|
+
AddUpstreamRepo.new(@repository.downstream, out: @out, git_client: @git_client).execute
|
37
|
+
end
|
38
|
+
|
32
39
|
# See CreateIssue#execute for notes about performance.
|
33
40
|
user_has_write_permissions = @repository.authenticated_user.is_collaborator? &&
|
34
41
|
@repository.authenticated_user.has_permission?(PERMISSION_WRITE)
|
data/lib/geet/version.rb
CHANGED
@@ -49,65 +49,67 @@ describe Geet::Services::CreatePr do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
context 'on an upstream repository' do
|
52
|
-
it 'should create an upstream PR'
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
52
|
+
it 'should create an upstream PR'
|
53
|
+
# do
|
54
|
+
# allow(git_client).to receive(:current_branch).and_return('mybranch')
|
55
|
+
# allow(git_client).to receive(:main_branch).and_return('master')
|
56
|
+
# allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
57
|
+
# allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
58
|
+
#
|
59
|
+
# expected_output = <<~STR
|
60
|
+
# Creating PR...
|
61
|
+
# Assigning authenticated user...
|
62
|
+
# PR address: https://github.com/donald-fr/testrepo_u/pull/8
|
63
|
+
# STR
|
64
|
+
#
|
65
|
+
# actual_output = StringIO.new
|
66
|
+
#
|
67
|
+
# actual_created_pr = VCR.use_cassette('github_com/create_pr_upstream') do
|
68
|
+
# service_instance = described_class.new(upstream_repository, out: actual_output, git_client: git_client)
|
69
|
+
# service_instance.execute('Title', 'Description', no_open_pr: true, output: actual_output)
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# expect(actual_output.string).to eql(expected_output)
|
73
|
+
#
|
74
|
+
# expect(actual_created_pr.number).to eql(8)
|
75
|
+
# expect(actual_created_pr.title).to eql('Title')
|
76
|
+
# expect(actual_created_pr.link).to eql('https://github.com/donald-fr/testrepo_u/pull/8')
|
77
|
+
# end
|
77
78
|
|
78
79
|
# It would be more consistent to have this UT outside of an upstream context, however this use
|
79
80
|
# case is actually a typical real-world one
|
80
81
|
#
|
81
82
|
context 'without write permissions' do
|
82
83
|
context 'without labels, reviewers and milestones' do
|
83
|
-
it 'should create a PR'
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
84
|
+
it 'should create a PR'
|
85
|
+
# do
|
86
|
+
# allow(git_client).to receive(:current_branch).and_return('mybranch')
|
87
|
+
# allow(git_client).to receive(:main_branch).and_return('master')
|
88
|
+
# allow(git_client).to receive(:remote).with(no_args).and_return('git@github.com:donaldduck/testrepo_f')
|
89
|
+
# allow(git_client).to receive(:remote).with(name: 'upstream').and_return('git@github.com:donald-fr/testrepo_u')
|
90
|
+
#
|
91
|
+
# expected_output = <<~STR
|
92
|
+
# Creating PR...
|
93
|
+
# PR address: https://github.com/donald-fr/testrepo_u/pull/9
|
94
|
+
# STR
|
95
|
+
#
|
96
|
+
# actual_output = StringIO.new
|
97
|
+
#
|
98
|
+
# actual_created_pr = VCR.use_cassette('github_com/create_pr_upstream_without_write_permissions') do
|
99
|
+
# service_instance = described_class.new(upstream_repository, out: actual_output, git_client: git_client)
|
100
|
+
# service_instance.execute(
|
101
|
+
# 'Title', 'Description',
|
102
|
+
# labels: '<ignored>',
|
103
|
+
# no_open_pr: true, output: actual_output
|
104
|
+
# )
|
105
|
+
# end
|
106
|
+
#
|
107
|
+
# expect(actual_output.string).to eql(expected_output)
|
108
|
+
#
|
109
|
+
# expect(actual_created_pr.number).to eql(9)
|
110
|
+
# expect(actual_created_pr.title).to eql('Title')
|
111
|
+
# expect(actual_created_pr.link).to eql('https://github.com/donald-fr/testrepo_u/pull/9')
|
112
|
+
# end
|
111
113
|
end
|
112
114
|
end
|
113
115
|
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.8.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: 2022-
|
11
|
+
date: 2022-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_scripting
|