fastlane-plugin-bitbucket_cloud 0.3.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fa114b7562e3079e09ae0475e4155f70dd30836e5be01f9573091e4cc83d3da
4
- data.tar.gz: 1dcbd6681d16e0ae580e6baeef769a130eedbc206944a966b1a97a259760f05a
3
+ metadata.gz: 436c43be8735177c7e9be9dd73cd6273f9f5782d8a12b6105cc20250c73ccf83
4
+ data.tar.gz: 5bf801ac01c13ec8079de24039df8f174c1a08d2a171bb8acabf406ebedb2778
5
5
  SHA512:
6
- metadata.gz: 83073039b4add829fbaec43b56b97879b67e18412658d965b82bcb4e846aadb53b595ae4e5087f960289c0048455d7c2eeb4dc6c7e9f083b626e8bc1df3de1e3
7
- data.tar.gz: 345af27685c2dce6976f7fdc080d26bbcba15be777dca6cf15da046638a9b594758dae13dad8535447b6e86522e56bd3c47f609efcda8894d29ea5824235fbc5
6
+ metadata.gz: 7939558ef73b229b9c75a13587f35f8b79527afeaf5dd0bd0c1435cd6325225f2ffd4ff4818e7fd8478627f8b9580c3651eeb484b927cc424e6f764911ff4d84
7
+ data.tar.gz: 74f0cf4111265bf7a80c87eefc887a66f78b36be797f4e64eed4f6c07009701699a0f332877c720887e38ed4cc6db64509ba34d02a31f08279eae6651e725659
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require 'fastlane_core'
3
5
  require_relative '../helper/bitbucket_cloud_helper'
@@ -9,6 +11,7 @@ module Fastlane
9
11
  end
10
12
 
11
13
  class BitbucketCreatePullRequestAction < Action
14
+ # rubocop:disable Metrics/MethodLength
12
15
  def self.run(options)
13
16
  require 'excon'
14
17
 
@@ -16,25 +19,25 @@ module Fastlane
16
19
  description = options[:description]
17
20
  reviewers = options[:reviewers]
18
21
 
19
- api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api: "pullrequests")
22
+ api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api: 'pullrequests')
20
23
 
21
24
  headers = Helper::BitbucketCloudHelper.headers(username: options[:username], password: options[:password])
22
25
 
23
26
  payload = {
24
27
  title: options[:title],
25
28
  source: {
26
- branch: {
27
- name: options[:source_branch]
28
- }
29
+ branch: {
30
+ name: options[:source_branch]
31
+ }
29
32
  }
30
33
  }
31
34
 
32
35
  if destination_branch.instance_of?(NilClass)
33
- destination_log = ""
36
+ destination_log = ''
34
37
  else
35
38
  destination_obj = {
36
39
  branch: {
37
- name: destination_branch
40
+ name: destination_branch
38
41
  }
39
42
  }
40
43
  payload[:destination] = destination_obj
@@ -42,7 +45,7 @@ module Fastlane
42
45
  end
43
46
 
44
47
  if description.instance_of?(NilClass)
45
- description_log = ""
48
+ description_log = ''
46
49
  else
47
50
  payload[:description] = description
48
51
  description_log = " and description '#{description}'"
@@ -51,8 +54,7 @@ module Fastlane
51
54
  unless reviewers.instance_of?(NilClass)
52
55
  reviewers_obj = reviewers.map do |reviewer|
53
56
  {
54
- username: reviewer
55
-
57
+ uuid: reviewer
56
58
  }
57
59
  end
58
60
  payload[:reviewers] = reviewers_obj
@@ -66,108 +68,106 @@ module Fastlane
66
68
 
67
69
  result = Helper::BitbucketCloudHelper.formatted_result(response)
68
70
 
69
- UI.important("Plugin Bitbucket finished with result")
71
+ UI.important('Plugin Bitbucket finished with result')
70
72
  UI.important(result.to_s)
71
73
 
72
74
  Actions.lane_context[SharedValues::BITBUCKET_CREATE_PULL_REQUEST_RESULT] = Helper::BitbucketCloudHelper.formatted_context_result(response)
73
75
 
74
- if result[:status] != 201
75
- error_message = "Plugin Bitbucket finished with error code #{result[:status]} #{result[:reason_phrase]}"
76
- raise StandardError, error_message
77
- end
76
+ Helper::BitbucketCloudHelper.check_result(result: result, status: 201)
78
77
 
79
- UI.success("Successfully create a new Bitbucket pull request!")
80
- return result
78
+ UI.success('Successfully create a new Bitbucket pull request!')
79
+ result
81
80
  end
81
+ # rubocop:enable Metrics/MethodLength
82
82
 
83
83
  def self.description
84
- "Create a new pull request inside your Bitbucket project"
84
+ 'Create a new pull request inside your Bitbucket project'
85
85
  end
86
86
 
87
87
  def self.details
88
- "Wrapper of Bitbucket cloud rest apis in order to make easy integration of Bitbucket CI inside fastlane workflow"
88
+ 'Wrapper of Bitbucket cloud rest apis in order to make easy integration of Bitbucket CI inside fastlane workflow'
89
89
  end
90
90
 
91
91
  def self.authors
92
- ["Luca Tagliabue"]
92
+ ['Luca Tagliabue']
93
93
  end
94
94
 
95
+ # rubocop:disable Metrics/MethodLength
95
96
  def self.available_options
96
97
  [
97
98
  FastlaneCore::ConfigItem.new(key: :username,
98
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_USERNAME",
99
- description: "Bitbucket username",
99
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_USERNAME',
100
+ description: 'Bitbucket username',
100
101
  sensitive: true,
101
- code_gen_sensitive: true,
102
- is_string: true,
103
- default_value: ENV.fetch("BITBUCKET_USERNAME", nil),
104
- default_value_dynamic: true,
105
- optional: false),
102
+ type: String,
103
+ optional: false,
104
+ verify_block: ->(value) { verify_option(key: 'username', value: value) }),
106
105
  FastlaneCore::ConfigItem.new(key: :password,
107
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD",
108
- description: "Bitbucket password",
106
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD',
107
+ description: 'Bitbucket password',
109
108
  sensitive: true,
110
- code_gen_sensitive: true,
111
- is_string: true,
112
- default_value: ENV.fetch("BITBUCKET_PASSWORD", nil),
113
- default_value_dynamic: true,
114
- optional: false),
109
+ type: String,
110
+ optional: false,
111
+ verify_block: ->(value) { verify_option(key: 'password', value: value) }),
115
112
  FastlaneCore::ConfigItem.new(key: :company_host_name,
116
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME",
117
- description: "Bitbucket company host name",
113
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME',
114
+ description: 'Bitbucket company host name',
118
115
  sensitive: true,
119
- code_gen_sensitive: true,
120
- is_string: true,
121
- default_value: ENV.fetch("BITBUCKET_COMPANY_HOST_NAME", nil),
122
- default_value_dynamic: true,
123
- optional: false),
116
+ type: String,
117
+ optional: false,
118
+ verify_block: ->(value) { verify_option(key: 'company_host_name', value: value) }),
124
119
  FastlaneCore::ConfigItem.new(key: :repository_name,
125
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME",
126
- description: "Bitbucket repository name",
120
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME',
121
+ description: 'Bitbucket repository name',
127
122
  sensitive: true,
128
- code_gen_sensitive: true,
129
- is_string: true,
130
- default_value: ENV.fetch("BITBUCKET_REPOSITORY_NAME", nil),
131
- default_value_dynamic: true,
132
- optional: false),
123
+ type: String,
124
+ optional: false,
125
+ verify_block: ->(value) { verify_option(key: 'repository_name', value: value) }),
133
126
  FastlaneCore::ConfigItem.new(key: :title,
134
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_TITLE",
135
- description: "Title of the pull request",
136
- is_string: true,
137
- optional: false),
127
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_TITLE',
128
+ description: 'Title of the pull request',
129
+ type: String,
130
+ optional: false,
131
+ verify_block: ->(value) { verify_option(key: 'title', value: value) }),
138
132
  FastlaneCore::ConfigItem.new(key: :description,
139
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_DESCRIPTION",
140
- description: "Description of the pull request",
141
- is_string: true,
133
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_DESCRIPTION',
134
+ description: 'Description of the pull request',
135
+ type: String,
142
136
  optional: true),
143
137
  FastlaneCore::ConfigItem.new(key: :reviewers,
144
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_REVIEWERS",
145
- description: "List of reviewer's usernames for the pull request. If no reviewers are passed, fails back to default ones",
138
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REVIEWERS',
139
+ description: "List of reviewer's uuids for the pull request. If no reviewers are passed, fails back to default ones",
146
140
  type: Array,
147
141
  optional: true),
148
142
  FastlaneCore::ConfigItem.new(key: :source_branch,
149
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_SOURCE_BRANCH",
150
- description: "Name of the source branch",
151
- is_string: true,
143
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_SOURCE_BRANCH',
144
+ description: 'Name of the source branch',
145
+ type: String,
152
146
  optional: false),
153
147
  FastlaneCore::ConfigItem.new(key: :destination_branch,
154
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_DESTINATION_BRANCH",
155
- description: "Name of the destination branch",
156
- is_string: true,
148
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_DESTINATION_BRANCH',
149
+ description: 'Name of the destination branch',
150
+ type: String,
157
151
  optional: true)
158
152
  ]
159
153
  end
154
+ # rubocop:enable Metrics/MethodLength
155
+
156
+ def self.verify_option(options)
157
+ UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
158
+ end
160
159
 
161
160
  def self.output
162
161
  [
163
- ['BITBUCKET_CREATE_PULL_REQUEST_RESULT', 'The result of the bitbucket rest cloud api']
162
+ ['BITBUCKET_CREATE_PULL_REQUEST_RESULT', 'The result of the bitbucket pullrequests cloud api']
164
163
  ]
165
164
  end
166
165
 
167
166
  def self.return_value
168
- 'The result of the bitbucket rest cloud api'
167
+ 'The result of the bitbucket pullrequests cloud api'
169
168
  end
170
169
 
170
+ # rubocop:disable Metrics/MethodLength
171
171
  def self.example_code
172
172
  [
173
173
  'bitbucket_create_pull_request(
@@ -183,8 +183,9 @@ module Fastlane
183
183
  )'
184
184
  ]
185
185
  end
186
+ # rubocop:enable Metrics/MethodLength
186
187
 
187
- def self.is_supported?(platform)
188
+ def self.is_supported?(_platform)
188
189
  true
189
190
  end
190
191
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/action'
2
4
  require 'fastlane_core'
3
5
  require_relative '../helper/bitbucket_cloud_helper'
@@ -9,94 +11,91 @@ module Fastlane
9
11
  end
10
12
 
11
13
  class BitbucketListDefaultReviewersAction < Action
14
+ # rubocop:disable Metrics/MethodLength
12
15
  def self.run(options)
13
16
  require 'excon'
14
17
 
15
- api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api: "default-reviewers")
18
+ api_url = Helper::BitbucketCloudHelper.url(company_host_name: options[:company_host_name], repository_name: options[:repository_name], api: 'default-reviewers')
16
19
 
17
20
  headers = Helper::BitbucketCloudHelper.headers(username: options[:username], password: options[:password])
18
21
 
19
- UI.important("Plugin Bitbucket will list all defaults reviewers")
22
+ UI.important('Plugin Bitbucket will list all defaults reviewers')
20
23
 
21
24
  response = Excon.get(api_url, headers: headers)
22
25
 
23
26
  result = Helper::BitbucketCloudHelper.formatted_result(response)
24
27
 
25
- UI.important("Plugin Bitbucket finished with result")
28
+ UI.important('Plugin Bitbucket finished with result')
26
29
  UI.important(result.to_s)
27
30
 
28
31
  Actions.lane_context[SharedValues::BITBUCKET_LIST_DEFAULT_REVIEWERS_RESULT] = Helper::BitbucketCloudHelper.formatted_context_result(response)
29
32
 
30
- if result[:status] != 200
31
- error_message = "Plugin Bitbucket finished with error code #{result[:status]} #{result[:reason_phrase]}"
32
- raise StandardError, error_message
33
- end
33
+ Helper::BitbucketCloudHelper.check_result(result: result, status: 200)
34
34
 
35
- UI.success("Successfully list all default reviewers!")
36
- return result
35
+ UI.success('Successfully list all default reviewers!')
36
+ result
37
37
  end
38
+ # rubocop:enable Metrics/MethodLength
38
39
 
39
40
  def self.description
40
- "List of all defaults reviewers of pull requests"
41
+ 'List of all defaults reviewers of pull requests'
41
42
  end
42
43
 
43
44
  def self.details
44
- "Wrapper of Bitbucket cloud rest apis in order to make easy integration of Bitbucket CI inside fastlane workflow"
45
+ 'Wrapper of Bitbucket cloud rest apis in order to make easy integration of Bitbucket CI inside fastlane workflow'
45
46
  end
46
47
 
47
48
  def self.authors
48
- ["Luca Tagliabue"]
49
+ ['Luca Tagliabue']
49
50
  end
50
51
 
52
+ # rubocop:disable Metrics/MethodLength
51
53
  def self.available_options
52
54
  [
53
55
  FastlaneCore::ConfigItem.new(key: :username,
54
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_USERNAME",
55
- description: "Bitbucket username",
56
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_USERNAME',
57
+ description: 'Bitbucket username',
56
58
  sensitive: true,
57
- code_gen_sensitive: true,
58
- is_string: true,
59
- default_value: ENV.fetch("BITBUCKET_USERNAME", nil),
60
- default_value_dynamic: true,
61
- optional: false),
59
+ type: String,
60
+ optional: false,
61
+ verify_block: ->(value) { verify_option(key: 'username', value: value) }),
62
62
  FastlaneCore::ConfigItem.new(key: :password,
63
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD",
64
- description: "Bitbucket password",
63
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD',
64
+ description: 'Bitbucket password',
65
65
  sensitive: true,
66
- code_gen_sensitive: true,
67
- is_string: true,
68
- default_value: ENV.fetch("BITBUCKET_PASSWORD", nil),
69
- default_value_dynamic: true,
70
- optional: false),
66
+ type: String,
67
+ optional: false,
68
+ verify_block: ->(value) { verify_option(key: 'password', value: value) }),
71
69
  FastlaneCore::ConfigItem.new(key: :company_host_name,
72
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME",
73
- description: "Bitbucket company host name",
70
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME',
71
+ description: 'Bitbucket company host name',
74
72
  sensitive: true,
75
- code_gen_sensitive: true,
76
- is_string: true,
77
- default_value: ENV.fetch("BITBUCKET_COMPANY_HOST_NAME", nil),
78
- default_value_dynamic: true,
79
- optional: false),
73
+ type: String,
74
+ optional: false,
75
+ verify_block: ->(value) { verify_option(key: 'company_host_name', value: value) }),
80
76
  FastlaneCore::ConfigItem.new(key: :repository_name,
81
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME",
82
- description: "Bitbucket repository name",
77
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME',
78
+ description: 'Bitbucket repository name',
83
79
  sensitive: true,
84
- code_gen_sensitive: true,
85
- is_string: true,
86
- default_value: ENV.fetch("BITBUCKET_REPOSITORY_NAME", nil),
87
- default_value_dynamic: true,
88
- optional: false)
80
+ type: String,
81
+ optional: false,
82
+ verify_block: ->(value) { verify_option(key: 'repository_name', value: value) })
89
83
  ]
90
84
  end
85
+ # rubocop:enable Metrics/MethodLength
86
+
87
+ def self.verify_option(options)
88
+ UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
89
+ end
91
90
 
92
91
  def self.output
93
92
  [
94
- ['BITBUCKET_LIST_DEFAULT_REVIEWERS_RESULT', 'The result of the bitbucket rest cloud api']
93
+ ['BITBUCKET_LIST_DEFAULT_REVIEWERS_RESULT', 'The result of the bitbucket default-reviewers cloud api']
95
94
  ]
96
95
  end
97
96
 
98
97
  def self.return_value
99
- 'The result of the bitbucket rest cloud api'
98
+ 'The result of the bitbucket default-reviewers cloud api'
100
99
  end
101
100
 
102
101
  def self.example_code
@@ -110,7 +109,7 @@ module Fastlane
110
109
  ]
111
110
  end
112
111
 
113
- def self.is_supported?(platform)
112
+ def self.is_supported?(_platform)
114
113
  true
115
114
  end
116
115
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane_core/ui/ui'
2
4
 
3
5
  module Fastlane
@@ -19,15 +21,15 @@ module Fastlane
19
21
  def self.headers(options)
20
22
  api_token = Base64.strict_encode64("#{options[:username]}:#{options[:password]}")
21
23
 
22
- { "Content-Type": "application/json", Authorization: "Basic #{api_token}" }
24
+ { 'Content-Type': 'application/json', Authorization: "Basic #{api_token}" }
23
25
  end
24
26
 
25
27
  def self.formatted_result(response)
26
28
  {
27
29
  status: response[:status],
28
30
  reason_phrase: response[:reason_phrase],
29
- body: response.body || "",
30
- json: self.parse_json(response.body) || {}
31
+ body: response.body || '',
32
+ json: parse_json(response.body) || {}
31
33
  }
32
34
  end
33
35
 
@@ -42,6 +44,14 @@ module Fastlane
42
44
  rescue JSON::ParserError
43
45
  nil
44
46
  end
47
+
48
+ def self.check_result(options)
49
+ result = options[:result]
50
+ return unless result[:status] != options[:status]
51
+
52
+ error_message = "Plugin Bitbucket finished with error code #{result[:status]} #{result[:reason_phrase]}"
53
+ raise StandardError, error_message
54
+ end
45
55
  end
46
56
  end
47
57
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fastlane
2
4
  module BitbucketCloud
3
- VERSION = "0.3.0"
5
+ VERSION = '0.3.2'
4
6
  end
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fastlane/plugin/bitbucket_cloud/version'
2
4
 
3
5
  module Fastlane
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-bitbucket_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Tagliabue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-07 00:00:00.000000000 Z
11
+ date: 2024-02-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: lu.tagliabue@reply.it