fastlane-plugin-stream_actions 0.4.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da3b36b0e6522ca379318f8ad60da491bf4142410448906362262a0cac7752be
4
- data.tar.gz: 5ab21d748b882e41449e65689cb4d8f0b57995a87886c9a0712f6ebd9f969149
3
+ metadata.gz: 5db13e6770f55566dab3812ca6cc13d72a4cfbf55a12c105fd7fd46da6fafa7a
4
+ data.tar.gz: 9066d128357a6b2513f3d395246d9c4ec7b9c5bfe7dd52d9cdb54a3a98432e7a
5
5
  SHA512:
6
- metadata.gz: 909b117ee8f4b36290a3aa1c3df805d273e76523dc99eff987a6a6d11973a99f28bf20e491943c4fe00cb041fedf56b946330f7a6e4256f7cea6d8b7e9305b3d
7
- data.tar.gz: 66b9a04b4941b8be74fa1dde59aa06a1a77c8463dff240d856fba76d8ef7c02f51529990dc8330879dd4174279001bd7fe5f84df02cc0b89dac07df8d3047581
6
+ metadata.gz: d916b54cef7c5304f0ec2467fa27e6426f1696212f3b6f857a74b674a04343e4042d0b39736dc30ef1031c487fb78cc3328c0041111405c3f5fd4902adb0c68f
7
+ data.tar.gz: 6c0239be3c703aa18bea7fe0b033c065a776c1e6e8ca1d26dd2d6b8e0bbb8648fee9cc4f6394042d3478d110a32702527f28edf43cd638ddc7643f71cd55485d
@@ -6,11 +6,11 @@ module Fastlane
6
6
 
7
7
  UI.message("Checking if check is required for PR ##{params[:github_pr_num]}")
8
8
 
9
- changed_files = Actions.sh("gh pr view #{params[:github_pr_num]} --json files -q '.files[].path'").split("\n")
9
+ changed_files = self.changed_file_paths(params)
10
10
 
11
11
  too_many_files = changed_files.size > 99 # TODO: https://github.com/cli/cli/issues/5368
12
12
  if too_many_files
13
- UI.important("Check it required because there were too many files changed.")
13
+ UI.important("Check is required because there were too many files changed.")
14
14
  return true
15
15
  end
16
16
 
@@ -23,6 +23,42 @@ module Fastlane
23
23
  is_check_required
24
24
  end
25
25
 
26
+ # For pull_request: use full PR for `opened` (etc.); for `synchronize` pass
27
+ # github_event_before/after (e.g. github.event.before/after) to scope to this push.
28
+ def self.changed_file_paths(params)
29
+ action = params[:github_event_action].to_s
30
+ before = params[:github_event_before].to_s.strip
31
+ after = params[:github_event_after].to_s.strip
32
+ repo = (params[:github_repository] || ENV['GITHUB_REPOSITORY']).to_s
33
+
34
+ if action == 'synchronize' && !before.empty? && !after.empty? && !repo.empty?
35
+ if before.match?(/\A0+\z/) || !before.match?(/\A[0-9a-f]{7,40}\z/i) || !after.match?(/\A[0-9a-f]{7,40}\z/i)
36
+ UI.important("Invalid before/after for compare; falling back to full PR file list")
37
+ else
38
+ out = self.compare_push_files(repo, before, after)
39
+ return out unless out.nil?
40
+
41
+ UI.important("Could not list push diff (e.g. fork/cross-repo); falling back to full PR file list")
42
+ end
43
+ end
44
+
45
+ self.gh_path_lines(Actions.sh("gh pr view #{params[:github_pr_num]} --json files -q '.files[].path'"))
46
+ end
47
+
48
+ def self.compare_push_files(repo, before, after)
49
+ self.gh_path_lines(Actions.sh(
50
+ "gh api \"repos/#{repo}/compare/#{before}...#{after}\" " \
51
+ "-H \"Accept: application/vnd.github.v3+json\" " \
52
+ "-q '.files[].filename'"
53
+ ))
54
+ rescue StandardError
55
+ nil
56
+ end
57
+
58
+ def self.gh_path_lines(output)
59
+ output.to_s.split("\n", -1).map(&:strip).reject(&:empty?)
60
+ end
61
+
26
62
  #####################################################
27
63
  # @!group Documentation
28
64
  #####################################################
@@ -52,6 +88,31 @@ module Fastlane
52
88
  description: 'GitHub PR number',
53
89
  optional: true,
54
90
  is_string: false
91
+ ),
92
+ FastlaneCore::ConfigItem.new(
93
+ env_name: 'GITHUB_EVENT_ACTION',
94
+ key: :github_event_action,
95
+ description: 'pull_request action: e.g. opened, synchronize. When synchronize and before/after ' \
96
+ 'are set, only files in that push are considered',
97
+ optional: true
98
+ ),
99
+ FastlaneCore::ConfigItem.new(
100
+ env_name: 'GITHUB_EVENT_BEFORE',
101
+ key: :github_event_before,
102
+ description: 'github.event.before (head ref before the push) for pull_request',
103
+ optional: true
104
+ ),
105
+ FastlaneCore::ConfigItem.new(
106
+ env_name: 'GITHUB_EVENT_AFTER',
107
+ key: :github_event_after,
108
+ description: 'github.event.after (head ref after the push) for pull_request',
109
+ optional: true
110
+ ),
111
+ FastlaneCore::ConfigItem.new(
112
+ env_name: 'GITHUB_REPOSITORY',
113
+ key: :github_repository,
114
+ description: 'owner/repo; required for push-scoped file list (defaults to GITHUB_REPOSITORY in CI)',
115
+ optional: true
55
116
  )
56
117
  ]
57
118
  end
@@ -0,0 +1,49 @@
1
+ module Fastlane
2
+ module Actions
3
+ class NextPrNumberAction < Action
4
+ def self.run(params)
5
+ uri = URI('https://api.github.com/repos')
6
+ uri.path += "/#{params[:github_repo]}/issues"
7
+ uri.query = URI.encode_www_form('state' => 'all', 'sort' => 'created', 'direction' => 'desc', 'per_page' => 1)
8
+
9
+ http = Net::HTTP.new(uri.host, uri.port)
10
+ http.use_ssl = true
11
+ request = Net::HTTP::Get.new(uri.request_uri)
12
+ token = ENV.fetch('GITHUB_TOKEN') { nil }
13
+ token = ENV.fetch('GH_TOKEN') { nil } if token.to_s.empty?
14
+ request['Authorization'] = "Bearer #{token}" unless token.to_s.empty?
15
+
16
+ response = http.request(request)
17
+ UI.user_error!("GitHub API request failed: #{response.code} #{response.message} — body: #{response.body}") if response.code != '200'
18
+
19
+ list = JSON.parse(response.body)
20
+ max_num = list.empty? ? 0 : list[0]['number'].to_i
21
+ next_num = max_num + 1
22
+ UI.important("Next pull request number: #{next_num}")
23
+ next_num
24
+ end
25
+
26
+ #####################################################
27
+ # @!group Documentation
28
+ #####################################################
29
+
30
+ def self.description
31
+ 'Get next pull request number'
32
+ end
33
+
34
+ def self.available_options
35
+ [
36
+ FastlaneCore::ConfigItem.new(
37
+ key: :github_repo,
38
+ env_name: 'GITHUB_REPOSITORY',
39
+ description: 'GitHub repo name'
40
+ )
41
+ ]
42
+ end
43
+
44
+ def self.is_supported?(platform)
45
+ [:ios].include?(platform)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -22,7 +22,6 @@ module Fastlane
22
22
  [
23
23
  FastlaneCore::ConfigItem.new(
24
24
  key: :version,
25
- env_name: 'GITHUB_REPOSITORY',
26
25
  description: 'Xcode version'
27
26
  )
28
27
  ]
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module StreamActions
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-stream_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GetStream
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-24 00:00:00.000000000 Z
11
+ date: 2026-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xctest_list
@@ -242,6 +242,7 @@ files:
242
242
  - lib/fastlane/plugin/stream_actions/actions/is_check_required.rb
243
243
  - lib/fastlane/plugin/stream_actions/actions/merge_main_to_develop.rb
244
244
  - lib/fastlane/plugin/stream_actions/actions/merge_release_to_main.rb
245
+ - lib/fastlane/plugin/stream_actions/actions/next_pr_number.rb
245
246
  - lib/fastlane/plugin/stream_actions/actions/pod_push_safely.rb
246
247
  - lib/fastlane/plugin/stream_actions/actions/pr_comment.rb
247
248
  - lib/fastlane/plugin/stream_actions/actions/pr_create.rb