fastlane-plugin-bitbucket_cloud 0.3.1 → 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: 2d25959af32deea019cda65a40a426fbe4a1f2855e72836c0751e0a825687376
4
- data.tar.gz: e113acd322253daa69edfbd97f9c8bce0a33200f739cf3d080ad3cfde4119a40
3
+ metadata.gz: 436c43be8735177c7e9be9dd73cd6273f9f5782d8a12b6105cc20250c73ccf83
4
+ data.tar.gz: 5bf801ac01c13ec8079de24039df8f174c1a08d2a171bb8acabf406ebedb2778
5
5
  SHA512:
6
- metadata.gz: 1c2406fcf6ca1f2b36c3bf8be2e08c50e4ea82993245543524e6af3b3634139d80beb5f0d60f0ddeaff4ce16eccf8f3f068ed21bc28d8870f339fb2fc2bf403e
7
- data.tar.gz: ea793b4bfc9c11a11448c575d50c7c225244c46165995c8af951b6e5673e512828cfe5e199e630c72965412152746de9e6c84584a048d3713d407887b5983b57
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}'"
@@ -65,108 +68,106 @@ module Fastlane
65
68
 
66
69
  result = Helper::BitbucketCloudHelper.formatted_result(response)
67
70
 
68
- UI.important("Plugin Bitbucket finished with result")
71
+ UI.important('Plugin Bitbucket finished with result')
69
72
  UI.important(result.to_s)
70
73
 
71
74
  Actions.lane_context[SharedValues::BITBUCKET_CREATE_PULL_REQUEST_RESULT] = Helper::BitbucketCloudHelper.formatted_context_result(response)
72
75
 
73
- if result[:status] != 201
74
- error_message = "Plugin Bitbucket finished with error code #{result[:status]} #{result[:reason_phrase]}"
75
- raise StandardError, error_message
76
- end
76
+ Helper::BitbucketCloudHelper.check_result(result: result, status: 201)
77
77
 
78
- UI.success("Successfully create a new Bitbucket pull request!")
79
- return result
78
+ UI.success('Successfully create a new Bitbucket pull request!')
79
+ result
80
80
  end
81
+ # rubocop:enable Metrics/MethodLength
81
82
 
82
83
  def self.description
83
- "Create a new pull request inside your Bitbucket project"
84
+ 'Create a new pull request inside your Bitbucket project'
84
85
  end
85
86
 
86
87
  def self.details
87
- "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'
88
89
  end
89
90
 
90
91
  def self.authors
91
- ["Luca Tagliabue"]
92
+ ['Luca Tagliabue']
92
93
  end
93
94
 
95
+ # rubocop:disable Metrics/MethodLength
94
96
  def self.available_options
95
97
  [
96
98
  FastlaneCore::ConfigItem.new(key: :username,
97
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_USERNAME",
98
- description: "Bitbucket username",
99
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_USERNAME',
100
+ description: 'Bitbucket username',
99
101
  sensitive: true,
100
- code_gen_sensitive: true,
101
- is_string: true,
102
- default_value: ENV.fetch("BITBUCKET_USERNAME", nil),
103
- default_value_dynamic: true,
104
- optional: false),
102
+ type: String,
103
+ optional: false,
104
+ verify_block: ->(value) { verify_option(key: 'username', value: value) }),
105
105
  FastlaneCore::ConfigItem.new(key: :password,
106
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD",
107
- description: "Bitbucket password",
106
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_PASSWORD',
107
+ description: 'Bitbucket password',
108
108
  sensitive: true,
109
- code_gen_sensitive: true,
110
- is_string: true,
111
- default_value: ENV.fetch("BITBUCKET_PASSWORD", nil),
112
- default_value_dynamic: true,
113
- optional: false),
109
+ type: String,
110
+ optional: false,
111
+ verify_block: ->(value) { verify_option(key: 'password', value: value) }),
114
112
  FastlaneCore::ConfigItem.new(key: :company_host_name,
115
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME",
116
- description: "Bitbucket company host name",
113
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_COMPANY_HOST_NAME',
114
+ description: 'Bitbucket company host name',
117
115
  sensitive: true,
118
- code_gen_sensitive: true,
119
- is_string: true,
120
- default_value: ENV.fetch("BITBUCKET_COMPANY_HOST_NAME", nil),
121
- default_value_dynamic: true,
122
- optional: false),
116
+ type: String,
117
+ optional: false,
118
+ verify_block: ->(value) { verify_option(key: 'company_host_name', value: value) }),
123
119
  FastlaneCore::ConfigItem.new(key: :repository_name,
124
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME",
125
- description: "Bitbucket repository name",
120
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REPOSITORY_NAME',
121
+ description: 'Bitbucket repository name',
126
122
  sensitive: true,
127
- code_gen_sensitive: true,
128
- is_string: true,
129
- default_value: ENV.fetch("BITBUCKET_REPOSITORY_NAME", nil),
130
- default_value_dynamic: true,
131
- optional: false),
123
+ type: String,
124
+ optional: false,
125
+ verify_block: ->(value) { verify_option(key: 'repository_name', value: value) }),
132
126
  FastlaneCore::ConfigItem.new(key: :title,
133
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_TITLE",
134
- description: "Title of the pull request",
135
- is_string: true,
136
- 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) }),
137
132
  FastlaneCore::ConfigItem.new(key: :description,
138
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_DESCRIPTION",
139
- description: "Description of the pull request",
140
- is_string: true,
133
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_DESCRIPTION',
134
+ description: 'Description of the pull request',
135
+ type: String,
141
136
  optional: true),
142
137
  FastlaneCore::ConfigItem.new(key: :reviewers,
143
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_REVIEWERS",
138
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_REVIEWERS',
144
139
  description: "List of reviewer's uuids for the pull request. If no reviewers are passed, fails back to default ones",
145
140
  type: Array,
146
141
  optional: true),
147
142
  FastlaneCore::ConfigItem.new(key: :source_branch,
148
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_SOURCE_BRANCH",
149
- description: "Name of the source branch",
150
- is_string: true,
143
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_SOURCE_BRANCH',
144
+ description: 'Name of the source branch',
145
+ type: String,
151
146
  optional: false),
152
147
  FastlaneCore::ConfigItem.new(key: :destination_branch,
153
- env_name: "FL_POST_BITBUCKET_PULL_REQUEST_DESTINATION_BRANCH",
154
- description: "Name of the destination branch",
155
- is_string: true,
148
+ env_name: 'FL_POST_BITBUCKET_PULL_REQUEST_DESTINATION_BRANCH',
149
+ description: 'Name of the destination branch',
150
+ type: String,
156
151
  optional: true)
157
152
  ]
158
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
159
159
 
160
160
  def self.output
161
161
  [
162
- ['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']
163
163
  ]
164
164
  end
165
165
 
166
166
  def self.return_value
167
- 'The result of the bitbucket rest cloud api'
167
+ 'The result of the bitbucket pullrequests cloud api'
168
168
  end
169
169
 
170
+ # rubocop:disable Metrics/MethodLength
170
171
  def self.example_code
171
172
  [
172
173
  'bitbucket_create_pull_request(
@@ -182,8 +183,9 @@ module Fastlane
182
183
  )'
183
184
  ]
184
185
  end
186
+ # rubocop:enable Metrics/MethodLength
185
187
 
186
- def self.is_supported?(platform)
188
+ def self.is_supported?(_platform)
187
189
  true
188
190
  end
189
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.1"
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.1
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