geet 0.1.10 → 0.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c59d2f426846e6efe8e86311fdaa40c2d492c551
4
- data.tar.gz: ad031d1e06cb881481c6cd8e72581e3069b365e2
3
+ metadata.gz: 1a2f49ae01e6ee8ffb49547325a0a863fcdbf5a3
4
+ data.tar.gz: 278afc31f3bde847a85888ae1a41d9f59f4bf971
5
5
  SHA512:
6
- metadata.gz: 44015551198b6a04525a17079b065b85a81f5086ae2a22febcc3466596700035201da645ed2b7cb5093ddc6e4585d4fff105cf7fd806227eeb64f089f3e4e853
7
- data.tar.gz: 64e7d77b762b34d4444e443ac447b9c0a9ad201724daee2eb4f5745f83598853e8dd4d5674e48bc68815756d7132530103b5e7ee1ec3756a0837d38398f056da
6
+ metadata.gz: a26048f5c129330b17d077172b2533d8a38f19ca8dcc588eb580cc58ebc381708581713bebc5605b6bf4d7aca45723478f49d1f93cd59377cd026921bd8e984f
7
+ data.tar.gz: 50de5cca0d6d813bfdb6a2ac32143a7fb4d710e090f4ee15e24f92da6499ac148abca94ae22ef6fb656c54e8ebf4a0c041aee633fe29ebe7413c9b2936199bd0
data/README.md CHANGED
@@ -4,13 +4,26 @@ Command line interface for performing Git hosting service operations.
4
4
 
5
5
  The current version supports only creating PRs/issues.
6
6
 
7
- This tool is very similar to [Hub](https://github.com/github/hub), but it supports more complex operations, fully specified via command line.
7
+ This tool is very similar to [Hub](https://github.com/github/hub), but it supports a different set of operations, fully specified via command line.
8
8
 
9
9
  Please see the [development status](#development-status) section for informations about the current development.
10
10
 
11
11
  ## Providers support
12
12
 
13
- Currently, there are many functionalities implemented for GitHub (see help), and only issues listing for GitLab.
13
+ The functionalities currently supported are:
14
+
15
+ - Github:
16
+ - create gist
17
+ - create issue
18
+ - create PR
19
+ - list issues
20
+ - list labels
21
+ - list milestones
22
+ - list PRs
23
+ - merge PR
24
+ - Gitlab:
25
+ - list issues
26
+ - list labels
14
27
 
15
28
  ## Samples
16
29
 
@@ -87,6 +100,6 @@ Examples:
87
100
 
88
101
  ## Development status
89
102
 
90
- Geet is in alpha status. Although I use it daily, lots of features are being implemented, and internal/external APIs are frequently changed.
103
+ Geet is in alpha status. Although I use it daily, new features are frequently added, and internal/external APIs/workflows may change.
91
104
 
92
- The public release will be 1.0, and is expected to be released in January 2018 or earlier.
105
+ The public release will be 1.0, and is expected to be released in February 2018 or earlier.
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.2.0'
12
12
  s.authors = ['Saverio Miroddi']
13
- s.date = '2017-11-26'
13
+ s.date = '2017-11-27'
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 (eg. GitHub) operations (eg. PR creation).'
@@ -10,7 +10,7 @@ module Geet
10
10
  api_path = 'labels'
11
11
  response = api_interface.send_request(api_path, multipage: true)
12
12
 
13
- response.map { |label_entry| label_entry['name'] }
13
+ response.map { |label_entry| label_entry.fetch('name') }
14
14
  end
15
15
  end
16
16
  end
@@ -102,7 +102,13 @@ module Geet
102
102
  end
103
103
 
104
104
  def decode_and_format_error(parsed_response)
105
- parsed_response.fetch('error')
105
+ if parsed_response.key?('error')
106
+ parsed_response.fetch('error')
107
+ elsif parsed_response.key?('message')
108
+ parsed_response.fetch('message')
109
+ else
110
+ "Unrecognized response: #{parsed_response}"
111
+ end
106
112
  end
107
113
 
108
114
  def link_next_page(response_headers)
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'date'
4
+
5
+ module Geet
6
+ module Gitlab
7
+ class Label
8
+ # Returns a flat list of names in string form.
9
+ def self.list(api_interface)
10
+ api_path = "projects/#{api_interface.path_with_namespace(encoded: true)}/labels"
11
+ response = api_interface.send_request(api_path, multipage: true)
12
+
13
+ response.map { |label_entry| label_entry.fetch('name') }
14
+ end
15
+ end
16
+ end
17
+ end
data/lib/geet/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Geet
4
- VERSION = '0.1.10'
4
+ VERSION = '0.1.11'
5
5
  end
@@ -4,7 +4,7 @@ require_relative '../../lib/geet/git/repository'
4
4
  require_relative '../../lib/geet/services/create_pr'
5
5
 
6
6
  describe Geet::Services::CreatePr do
7
- let(:repository) { Geet::Git::Repository.new() }
7
+ let(:repository) { Geet::Git::Repository.new }
8
8
  let(:upstream_repository) { Geet::Git::Repository.new(upstream: true) }
9
9
 
10
10
  context 'with labels, reviewers and milestones' do
@@ -4,7 +4,7 @@ require_relative '../../lib/geet/git/repository'
4
4
  require_relative '../../lib/geet/services/list_issues'
5
5
 
6
6
  describe Geet::Services::ListIssues do
7
- let(:repository) { Geet::Git::Repository.new() }
7
+ let(:repository) { Geet::Git::Repository.new }
8
8
  let(:upstream_repository) { Geet::Git::Repository.new(upstream: true) }
9
9
 
10
10
  it 'should list the issues' do
@@ -4,25 +4,53 @@ require_relative '../../lib/geet/git/repository'
4
4
  require_relative '../../lib/geet/services/list_labels'
5
5
 
6
6
  describe Geet::Services::ListLabels do
7
- let(:repository) { Geet::Git::Repository.new() }
8
-
9
- it 'should list the labels' do
10
- allow(repository).to receive(:remote).with('origin').and_return('git@github.com:donaldduck/geet')
11
-
12
- expected_output = <<~STR
13
- - bug
14
- - enhancement
15
- - technical_debt
16
- - top_priority
17
- STR
18
- expected_labels = %w[bug enhancement technical_debt top_priority]
19
-
20
- actual_output = StringIO.new
21
- actual_labels = VCR.use_cassette("list_labels") do
22
- described_class.new.execute(repository, output: actual_output)
7
+ let(:repository) { Geet::Git::Repository.new }
8
+
9
+ context 'with github.com' do
10
+ it 'should list the labels' do
11
+ allow(repository).to receive(:remote).with('origin').and_return('git@github.com:donaldduck/geet')
12
+
13
+ expected_output = <<~STR
14
+ - bug
15
+ - enhancement
16
+ - technical_debt
17
+ - top_priority
18
+ STR
19
+ expected_labels = %w[bug enhancement technical_debt top_priority]
20
+
21
+ actual_output = StringIO.new
22
+ actual_labels = VCR.use_cassette("github.com/list_labels") do
23
+ described_class.new.execute(repository, output: actual_output)
24
+ end
25
+
26
+ expect(actual_output.string).to eql(expected_output)
27
+ expect(actual_labels).to eql(expected_labels)
23
28
  end
29
+ end
24
30
 
25
- expect(actual_output.string).to eql(expected_output)
26
- expect(actual_labels).to eql(expected_labels)
31
+ context 'with gitlab.com' do
32
+ it 'should list the labels' do
33
+ allow(repository).to receive(:remote).with('origin').and_return('git@gitlab.com:donaldduck/testproject')
34
+
35
+ expected_output = <<~STR
36
+ - bug
37
+ - confirmed
38
+ - critical
39
+ - discussion
40
+ - documentation
41
+ - enhancement
42
+ - suggestion
43
+ - support
44
+ STR
45
+ expected_labels = %w[bug confirmed critical discussion documentation enhancement suggestion support]
46
+
47
+ actual_output = StringIO.new
48
+ actual_labels = VCR.use_cassette("gitlab.com/list_labels") do
49
+ described_class.new.execute(repository, output: actual_output)
50
+ end
51
+
52
+ expect(actual_output.string).to eql(expected_output)
53
+ expect(actual_labels).to eql(expected_labels)
54
+ end
27
55
  end
28
56
  end
@@ -4,7 +4,7 @@ require_relative '../../lib/geet/git/repository'
4
4
  require_relative '../../lib/geet/services/list_milestones'
5
5
 
6
6
  describe Geet::Services::ListMilestones do
7
- let(:repository) { Geet::Git::Repository.new() }
7
+ let(:repository) { Geet::Git::Repository.new }
8
8
 
9
9
  it 'should list the milestones' do
10
10
  allow(repository).to receive(:remote).with('origin').and_return('git@github.com:donaldduck/geet')
@@ -4,7 +4,7 @@ require_relative '../../lib/geet/git/repository'
4
4
  require_relative '../../lib/geet/services/list_prs'
5
5
 
6
6
  describe Geet::Services::ListPrs do
7
- let(:repository) { Geet::Git::Repository.new() }
7
+ let(:repository) { Geet::Git::Repository.new }
8
8
  let(:upstream_repository) { Geet::Git::Repository.new(upstream: true) }
9
9
 
10
10
  it 'should list the PRs' do
@@ -4,7 +4,7 @@ require_relative '../../lib/geet/git/repository'
4
4
  require_relative '../../lib/geet/services/merge_pr'
5
5
 
6
6
  describe Geet::Services::MergePr do
7
- let(:repository) { Geet::Git::Repository.new() }
7
+ let(:repository) { Geet::Git::Repository.new }
8
8
 
9
9
  it 'should merge the PR for the current branch' do
10
10
  allow(repository).to receive(:current_branch).and_return('mybranch1')
data/spec/spec_helper.rb CHANGED
@@ -14,6 +14,10 @@ VCR.configure do |config|
14
14
 
15
15
  Base64.strict_encode64("#{user}:#{api_token}")
16
16
  end
17
+
18
+ config.filter_sensitive_data('<GITLAB_CREDENTIALS>') do
19
+ ENV.fetch('GITLAB_API_TOKEN')
20
+ end
17
21
  end
18
22
 
19
23
  # This file was generated by the `rspec --init` command. Conventionally, all
@@ -0,0 +1,80 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://gitlab.com/api/v4/projects/donaldduck%2Ftestproject/labels
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - gitlab.com
18
+ Private-Token:
19
+ - <GITLAB_CREDENTIALS>
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Mon, 27 Nov 2017 19:57:22 GMT
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '1456'
33
+ Cache-Control:
34
+ - max-age=0, private, must-revalidate
35
+ Etag:
36
+ - W/"f1657db8486bd268ddde16fe1c342d0a"
37
+ Link:
38
+ - <https://gitlab.com/api/v4/projects/donaldduck%2Ftestproject/labels?id=donaldduck%2Ftestproject&page=1&per_page=20>;
39
+ rel="first", <https://gitlab.com/api/v4/projects/donaldduck%2Ftestproject/labels?id=donaldduck%2Ftestproject&page=1&per_page=20>;
40
+ rel="last"
41
+ Vary:
42
+ - Origin
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Frame-Options:
46
+ - SAMEORIGIN
47
+ X-Next-Page:
48
+ - ''
49
+ X-Page:
50
+ - '1'
51
+ X-Per-Page:
52
+ - '20'
53
+ X-Prev-Page:
54
+ - ''
55
+ X-Request-Id:
56
+ - 0ea3d7c7-7fdf-4042-a4e8-67f7a48b4987
57
+ X-Runtime:
58
+ - '0.930769'
59
+ X-Total:
60
+ - '8'
61
+ X-Total-Pages:
62
+ - '1'
63
+ Strict-Transport-Security:
64
+ - max-age=31536000
65
+ Ratelimit-Limit:
66
+ - '600'
67
+ Ratelimit-Observed:
68
+ - '1'
69
+ Ratelimit-Remaining:
70
+ - '599'
71
+ Ratelimit-Reset:
72
+ - '1511812702'
73
+ Ratelimit-Resettime:
74
+ - Tue, 27 Nov 2017 19:58:22 GMT
75
+ body:
76
+ encoding: UTF-8
77
+ string: '[{"id":3081606,"name":"bug","color":"#d9534f","description":null,"open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"priority":null,"subscribed":false},{"id":3081608,"name":"confirmed","color":"#d9534f","description":null,"open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"priority":null,"subscribed":false},{"id":3081607,"name":"critical","color":"#d9534f","description":null,"open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"priority":null,"subscribed":false},{"id":3081611,"name":"discussion","color":"#428bca","description":null,"open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"priority":null,"subscribed":false},{"id":3081609,"name":"documentation","color":"#f0ad4e","description":null,"open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"priority":null,"subscribed":false},{"id":3081613,"name":"enhancement","color":"#5cb85c","description":null,"open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"priority":null,"subscribed":false},{"id":3081612,"name":"suggestion","color":"#428bca","description":null,"open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"priority":null,"subscribed":false},{"id":3081610,"name":"support","color":"#f0ad4e","description":null,"open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"priority":null,"subscribed":false}]'
78
+ http_version:
79
+ recorded_at: Mon, 27 Nov 2017 19:57:22 GMT
80
+ recorded_with: VCR 3.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.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saverio Miroddi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-26 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simple_scripting
@@ -57,6 +57,7 @@ files:
57
57
  - lib/geet/github/pr.rb
58
58
  - lib/geet/gitlab/api_interface.rb
59
59
  - lib/geet/gitlab/issue.rb
60
+ - lib/geet/gitlab/label.rb
60
61
  - lib/geet/helpers/os_helper.rb
61
62
  - lib/geet/services/create_gist.rb
62
63
  - lib/geet/services/create_issue.rb
@@ -82,9 +83,10 @@ files:
82
83
  - spec/vcr_cassettes/create_issue_upstream.yml
83
84
  - spec/vcr_cassettes/create_pr.yml
84
85
  - spec/vcr_cassettes/create_pr_upstream.yml
86
+ - spec/vcr_cassettes/github_com/list_labels.yml
87
+ - spec/vcr_cassettes/gitlab_com/list_labels.yml
85
88
  - spec/vcr_cassettes/list_issues.yml
86
89
  - spec/vcr_cassettes/list_issues_upstream.yml
87
- - spec/vcr_cassettes/list_labels.yml
88
90
  - spec/vcr_cassettes/list_milestones.yml
89
91
  - spec/vcr_cassettes/list_prs.yml
90
92
  - spec/vcr_cassettes/list_prs_upstream.yml