geet 0.3.17 → 0.4.2

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -9
  3. data/bin/geet +4 -0
  4. data/geet.gemspec +1 -1
  5. data/lib/geet/commandline/commands.rb +2 -0
  6. data/lib/geet/commandline/configuration.rb +16 -1
  7. data/lib/geet/git/repository.rb +8 -2
  8. data/lib/geet/github/abstract_issue.rb +3 -0
  9. data/lib/geet/github/api_interface.rb +2 -0
  10. data/lib/geet/github/issue.rb +1 -1
  11. data/lib/geet/github/pr.rb +28 -9
  12. data/lib/geet/github/remote_repository.rb +37 -0
  13. data/lib/geet/gitlab/api_interface.rb +2 -0
  14. data/lib/geet/helpers/os_helper.rb +4 -3
  15. data/lib/geet/helpers/services_workflow_helper.rb +9 -7
  16. data/lib/geet/services/add_upstream_repo.rb +37 -0
  17. data/lib/geet/services/comment_pr.rb +1 -2
  18. data/lib/geet/services/create_pr.rb +13 -11
  19. data/lib/geet/services/merge_pr.rb +7 -8
  20. data/lib/geet/services/open_pr.rb +2 -3
  21. data/lib/geet/services/open_repo.rb +50 -0
  22. data/lib/geet/utils/attributes_selection_manager.rb +7 -0
  23. data/lib/geet/utils/git_client.rb +74 -33
  24. data/lib/geet/version.rb +1 -1
  25. data/spec/integration/comment_pr_spec.rb +1 -1
  26. data/spec/integration/create_issue_spec.rb +3 -3
  27. data/spec/integration/create_label_spec.rb +5 -5
  28. data/spec/integration/create_milestone_spec.rb +1 -1
  29. data/spec/integration/create_pr_spec.rb +20 -15
  30. data/spec/integration/list_issues_spec.rb +6 -6
  31. data/spec/integration/list_labels_spec.rb +4 -4
  32. data/spec/integration/list_milestones_spec.rb +4 -4
  33. data/spec/integration/list_prs_spec.rb +3 -3
  34. data/spec/integration/merge_pr_spec.rb +13 -9
  35. data/spec/integration/open_pr_spec.rb +1 -1
  36. data/spec/integration/open_repo_spec.rb +46 -0
  37. data/spec/vcr_cassettes/create_issue.yml +1 -1
  38. data/spec/vcr_cassettes/create_issue_upstream.yml +1 -1
  39. data/spec/vcr_cassettes/github_com/create_pr.yml +1 -1
  40. data/spec/vcr_cassettes/github_com/create_pr_in_auto_mode_create_upstream.yml +1 -1
  41. data/spec/vcr_cassettes/github_com/create_pr_in_auto_mode_with_push.yml +1 -1
  42. data/spec/vcr_cassettes/github_com/create_pr_upstream.yml +1 -1
  43. data/spec/vcr_cassettes/github_com/create_pr_upstream_without_write_permissions.yml +1 -1
  44. metadata +7 -4
  45. data/lib/geet/shared/branches.rb +0 -9
@@ -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('origin').and_return('git@github.com:donaldduck/testrepo')
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('origin').and_return('git@github.com:donaldduck/testrepo_gh')
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('origin').and_return('git@github.com:donaldduck/testrepo_2f')
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('origin').and_return('git@gitlab.com:donaldduck/testproject')
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('origin').and_return('git@gitlab.com:donaldduck/testproject')
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('origin').and_return('git@github.com:donaldduck/geet')
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('origin').and_return('git@github.com:donaldduck/geet')
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('origin').and_return('git@gitlab.com:donaldduck/testproject')
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('origin').and_return('git@github.com:donaldduck/geet')
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('origin').and_return('git@github.com:donald-fr/testrepo_downstream')
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('origin').and_return('git@gitlab.com:donaldduck/testproject')
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('origin').and_return('git@github.com:donald-fr/testrepo_downstream')
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('origin').and_return('git@github.com:donald-fr/testrepo_downstream')
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)
@@ -7,7 +7,7 @@ require_relative '../../lib/geet/services/merge_pr'
7
7
 
8
8
  # Currently disabled: it requires updates following the addition of the automatic removal of the local
9
9
  # branch.
10
- # Specifically, `GitClient#upstream_branch_gone?` needs to be handled, since it returns the current
10
+ # Specifically, `GitClient#remote_branch_gone?` needs to be handled, since it returns the current
11
11
  # branch, while it's supposed to return
12
12
  #
13
13
  describe Geet::Services::MergePr do
@@ -15,11 +15,12 @@ describe Geet::Services::MergePr do
15
15
  let(:repository) { Geet::Git::Repository.new(git_client: git_client) }
16
16
  let(:owner) { 'donaldduck' }
17
17
  let(:branch) { 'mybranch' }
18
+ let(:main_branch) { 'main' }
18
19
 
19
20
  before :each do
20
21
  expect(git_client).to receive(:fetch)
21
- expect(git_client).to receive(:upstream_branch_gone?).and_return(true)
22
- expect(git_client).to receive(:checkout).with('master')
22
+ expect(git_client).to receive(:remote_branch_gone?).and_return(true)
23
+ expect(git_client).to receive(:checkout).with(main_branch)
23
24
  expect(git_client).to receive(:rebase)
24
25
  expect(git_client).to receive(:delete_branch).with('mybranch')
25
26
  end
@@ -29,14 +30,15 @@ describe Geet::Services::MergePr do
29
30
 
30
31
  it 'should merge the PR for the current branch' do
31
32
  allow(git_client).to receive(:current_branch).and_return(branch)
32
- allow(git_client).to receive(:remote).with('origin').and_return("git@github.com:#{owner}/#{repository_name}")
33
+ allow(git_client).to receive(:main_branch).and_return(main_branch)
34
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
33
35
 
34
36
  expected_pr_number = 1
35
37
  expected_output = <<~STR
36
38
  Finding PR with head (#{owner}:#{branch})...
37
39
  Merging PR ##{expected_pr_number}...
38
40
  Fetching repository...
39
- Checking out master...
41
+ Checking out #{main_branch}...
40
42
  Rebasing...
41
43
  Deleting local branch mybranch...
42
44
  STR
@@ -55,7 +57,8 @@ describe Geet::Services::MergePr do
55
57
 
56
58
  it 'should merge the PR for the current branch, with branch deletion' do
57
59
  allow(git_client).to receive(:current_branch).and_return(branch)
58
- allow(git_client).to receive(:remote).with('origin').and_return("git@github.com:#{owner}/#{repository_name}")
60
+ allow(git_client).to receive(:main_branch).and_return(main_branch)
61
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@github.com:#{owner}/#{repository_name}")
59
62
 
60
63
  expected_pr_number = 2
61
64
  expected_output = <<~STR
@@ -63,7 +66,7 @@ describe Geet::Services::MergePr do
63
66
  Merging PR ##{expected_pr_number}...
64
67
  Deleting remote branch #{branch}...
65
68
  Fetching repository...
66
- Checking out master...
69
+ Checking out #{main_branch}...
67
70
  Rebasing...
68
71
  Deleting local branch mybranch...
69
72
  STR
@@ -86,14 +89,15 @@ describe Geet::Services::MergePr do
86
89
 
87
90
  it 'should merge the PR for the current branch' do
88
91
  allow(git_client).to receive(:current_branch).and_return(branch)
89
- allow(git_client).to receive(:remote).with('origin').and_return("git@gitlab.com:#{owner}/#{repository_name}")
92
+ allow(git_client).to receive(:main_branch).and_return(main_branch)
93
+ allow(git_client).to receive(:remote).with(no_args).and_return("git@gitlab.com:#{owner}/#{repository_name}")
90
94
 
91
95
  expected_pr_number = 4
92
96
  expected_output = <<~STR
93
97
  Finding PR with head (#{owner}:#{branch})...
94
98
  Merging PR ##{expected_pr_number}...
95
99
  Fetching repository...
96
- Checking out master...
100
+ Checking out #{main_branch}...
97
101
  Rebasing...
98
102
  Deleting local branch mybranch...
99
103
  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('origin').and_return("git@github.com:#{owner}/#{repository_name}")
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
@@ -608,7 +608,7 @@ http_interactions:
608
608
  uri: https://api.github.com/repos/donaldduck/testrepo_f/issues
609
609
  body:
610
610
  encoding: UTF-8
611
- string: '{"title":"Title","body":"Description","base":"master"}'
611
+ string: '{"title":"Title","body":"Description"}'
612
612
  headers:
613
613
  Accept-Encoding:
614
614
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -152,7 +152,7 @@ http_interactions:
152
152
  uri: https://api.github.com/repos/momcorp/therepo/issues
153
153
  body:
154
154
  encoding: UTF-8
155
- string: '{"title":"Title","body":"Description","base":"master"}'
155
+ string: '{"title":"Title","body":"Description"}'
156
156
  headers:
157
157
  Accept-Encoding:
158
158
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -686,7 +686,7 @@ http_interactions:
686
686
  uri: https://api.github.com/repos/donaldduck/testrepo_f/pulls
687
687
  body:
688
688
  encoding: UTF-8
689
- string: '{"title":"Title","body":"Description","head":"mybranch","base":"master"}'
689
+ string: '{"title":"Title","body":"Description","head":"mybranch","base":"master","draft":false}'
690
690
  headers:
691
691
  Accept-Encoding:
692
692
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -381,7 +381,7 @@ http_interactions:
381
381
  uri: https://api.github.com/repos/donaldduck/testrepo_f/pulls
382
382
  body:
383
383
  encoding: UTF-8
384
- string: '{"title":"Title","body":"Description","head":"mybranch","base":"master"}'
384
+ string: '{"title":"Title","body":"Description","head":"mybranch","base":"master","draft":false}'
385
385
  headers:
386
386
  Accept-Encoding:
387
387
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -381,7 +381,7 @@ http_interactions:
381
381
  uri: https://api.github.com/repos/donaldduck/testrepo_f/pulls
382
382
  body:
383
383
  encoding: UTF-8
384
- string: '{"title":"Title","body":"Description","head":"mybranch","base":"master"}'
384
+ string: '{"title":"Title","body":"Description","head":"mybranch","base":"master","draft":false}'
385
385
  headers:
386
386
  Accept-Encoding:
387
387
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -459,7 +459,7 @@ http_interactions:
459
459
  uri: https://api.github.com/repos/donald-fr/testrepo_u/pulls
460
460
  body:
461
461
  encoding: UTF-8
462
- string: '{"title":"Title","body":"Description","head":"donaldduck:mybranch","base":"master"}'
462
+ string: '{"title":"Title","body":"Description","head":"donaldduck:mybranch","base":"master","draft":false}'
463
463
  headers:
464
464
  Accept-Encoding:
465
465
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -230,7 +230,7 @@ http_interactions:
230
230
  uri: https://api.github.com/repos/donald-fr/testrepo_u/pulls
231
231
  body:
232
232
  encoding: UTF-8
233
- string: '{"title":"Title","body":"Description","head":"donaldduck:mybranch","base":"master"}'
233
+ string: '{"title":"Title","body":"Description","head":"donaldduck:mybranch","base":"master","draft":false}'
234
234
  headers:
235
235
  Accept-Encoding:
236
236
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
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.17
4
+ version: 0.4.2
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-01-18 00:00:00.000000000 Z
11
+ date: 2021-07-26 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,7 +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
117
- - lib/geet/shared/branches.rb
119
+ - lib/geet/services/open_repo.rb
118
120
  - lib/geet/shared/http_error.rb
119
121
  - lib/geet/shared/repo_permissions.rb
120
122
  - lib/geet/shared/selection.rb
@@ -135,6 +137,7 @@ files:
135
137
  - spec/integration/list_prs_spec.rb
136
138
  - spec/integration/merge_pr_spec.rb
137
139
  - spec/integration/open_pr_spec.rb
140
+ - spec/integration/open_repo_spec.rb
138
141
  - spec/spec_helper.rb
139
142
  - spec/vcr_cassettes/create_gist_private.yml
140
143
  - spec/vcr_cassettes/create_gist_public.yml
@@ -187,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
190
  - !ruby/object:Gem::Version
188
191
  version: '0'
189
192
  requirements: []
190
- rubygems_version: 3.1.2
193
+ rubygems_version: 3.2.22
191
194
  signing_key:
192
195
  specification_version: 4
193
196
  summary: Commandline interface for performing SCM host operations, eg. create a PR
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Geet
4
- module Shared
5
- module Branches
6
- MAIN_BRANCH = 'master'
7
- end
8
- end
9
- end