dude-cli 2.1.0.alpha4 → 2.1.0.alpha5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f7264800c0e6de9bae422ee26f44b4c8129e65c9d8b5252526a95368803eefa
4
- data.tar.gz: 8565b51b5bc62964c5ebec4850640ea11de193a7b9224e138e7b31c00929fb8e
3
+ metadata.gz: 5a9d94fda51194e817efc77f7d46cf2cf7f8e94351c7cb989f7dd0512637e16f
4
+ data.tar.gz: 842f71093238abc9e102594629dc20ea6dc4677968c526dc6d0695ffd99a61d4
5
5
  SHA512:
6
- metadata.gz: f6e0188b6ca2a619363e1f0490759f513dae7b62723cd9a548bb4d41835a7d6876b5aa437430d96e7ad1ba7260cbfba376f69b6a47e305d93e5422c2318ea2c6
7
- data.tar.gz: 95fc65ae99760c77347e17a9d7f4be0db2324ab5203d55956458e84a4f98e3330772f2c336ac2edafc6f298e43d6eae9da60273d253ea1bf19898d1ee7db11a2
6
+ metadata.gz: 6ff9e01d64edc716ec55b366a03774eeb29819061e9ff52d4075f68780eb5f9f3fdb8249b5f31dc032e24d859dac341badda6cb19a074f58e55becefeafd32ca
7
+ data.tar.gz: 1739d16b3db6b32d57d0f186ea918c6358c2ff6e026cb1a5daf29e9c9e0b8e09d509bc034cfc94030bdf2c4169e312b527870f01271512bdf36451bc0ab4467b
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ Style/Documentation:
4
4
  AllCops:
5
5
  NewCops: enable
6
6
  SuggestExtensions: false
7
- TargetRubyVersion: 2.5
7
+ TargetRubyVersion: 2.7
8
8
 
9
9
  Metrics/BlockLength:
10
10
  IgnoredMethods: ['describe', 'context']
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dude-cli (2.1.0.alpha4)
4
+ dude-cli (2.1.0.alpha5)
5
5
  colorize (~> 0.8.1)
6
6
  dry-cli (~> 0.6)
7
7
  faraday (~> 1.1)
data/dude.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  DESC
17
17
  spec.homepage = 'https://github.com/npupko/dude'
18
18
  spec.license = 'MIT'
19
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
19
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
20
20
 
21
21
  spec.metadata['homepage_uri'] = spec.homepage
22
22
  spec.metadata['source_code_uri'] = 'https://github.com/npupko/dude'
data/lib/dude.rb CHANGED
@@ -20,4 +20,5 @@ module Dude
20
20
  LIST_OF_AVAILABLE_PROJECT_MANAGEMENT_TOOLS = %w[jira trello].freeze
21
21
 
22
22
  class ToBeImplementedError < StandardError; end
23
+ class TaskNotFoundError < StandardError; end
23
24
  end
@@ -12,8 +12,13 @@ module Dude
12
12
  @repo = repo
13
13
  @params = params
14
14
 
15
+ return unless issue
16
+
15
17
  response = client.post("https://api.github.com/repos/#{owner}/#{repo}/pulls", body.to_json)
16
18
  res = JSON.parse(response.body)
19
+
20
+ return github_error unless res['errors'] && res['errors'].empty?
21
+
17
22
  url = res['html_url']
18
23
  puts "Pull request has been created: #{url}"
19
24
  end
@@ -22,20 +27,25 @@ module Dude
22
27
 
23
28
  attr_reader :issue, :owner, :repo, :params
24
29
 
30
+ def github_error
31
+ puts <<~HEREDOC
32
+ #{'Error:'.red.bold} GitHub cannot create new Pull Request from #{params[:head].bold} branch. Try to push your branch and try again
33
+ HEREDOC
34
+ end
35
+
25
36
  def body
26
37
  {
27
- title: params[:title] || template['title'],
28
- body: params[:body] || template['body'],
38
+ title: params[:title] || template[:title],
39
+ body: params[:body] || template[:body],
29
40
  head: params[:head],
30
41
  base: params[:base]
31
42
  }
32
43
  end
33
44
 
34
45
  def template
35
- file = YAML.load_file(File.join(File.dirname(__FILE__), '../../templates/pull_request_template'))
36
- file.tap do |template|
37
- template['title'] = fill_variables(template['title'])
38
- template['body'] = fill_variables(template['body'])
46
+ Dude::SETTINGS.dig(:github, :pr_template).tap do |template|
47
+ template[:title] = fill_variables(template[:title])
48
+ template[:body] = fill_variables(template[:body])
39
49
  end
40
50
  end
41
51
 
@@ -7,7 +7,7 @@ module Dude
7
7
  desc 'Remove'
8
8
 
9
9
  def call(*)
10
- puts '123'
10
+ puts 'To be created later'
11
11
  end
12
12
  end
13
13
  end
@@ -12,16 +12,14 @@ module Dude
12
12
  class Client
13
13
  attr_reader :client, :project
14
14
 
15
- class << self
16
- def options
17
- {
18
- username: Dude::SETTINGS.dig(:jira, :email),
19
- password: Dude::SETTINGS.dig(:jira, :token),
20
- site: Dude::SETTINGS.dig(:jira, :project, :url),
21
- context_path: '',
22
- auth_type: :basic
23
- }
24
- end
15
+ def options
16
+ {
17
+ username: Dude::SETTINGS.dig(:jira, :email),
18
+ password: Dude::SETTINGS.dig(:jira, :token),
19
+ site: Dude::SETTINGS.dig(:jira, :project, :url),
20
+ context_path: '',
21
+ auth_type: :basic
22
+ }
25
23
  end
26
24
 
27
25
  def initialize
@@ -13,6 +13,8 @@ module Dude
13
13
 
14
14
  def call
15
15
  create_issue(client.Issue.find(id))
16
+ rescue JIRA::HTTPError
17
+ puts "#{'Error:'.red.bold} Task #{id.bold} not found. Try again with correct task ID"
16
18
  end
17
19
 
18
20
  private
data/lib/dude/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dude
4
- VERSION = '2.1.0.alpha4'
4
+ VERSION = '2.1.0.alpha5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dude-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.alpha4
4
+ version: 2.1.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Pupko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-02 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -255,7 +255,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
255
  requirements:
256
256
  - - ">="
257
257
  - !ruby/object:Gem::Version
258
- version: 2.5.0
258
+ version: 2.7.0
259
259
  required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  requirements:
261
261
  - - ">"