fastlane-plugin-wpmreleasetoolkit 12.0.0 → 12.1.0

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: 2f4bad14f2aca7e44fede245ed91674426c688395c9d6a5085a4d25a5e30e361
4
- data.tar.gz: 66e0440a5340b12dff4a5e35c37759c48d04c8f157e83e4c57ca94cde2c4135e
3
+ metadata.gz: b71377d7f0e796edf717a11ca452dd7c155106e8950500a183b59284649741cd
4
+ data.tar.gz: f948046099b8a967323e81aa409ccd806cbe6fc5d87a0a5624e0800055638511
5
5
  SHA512:
6
- metadata.gz: 1ed67cfa98a54dfe351d5e90ac318f97f1d40d777ac498f427b7c417f32651f16574eb441de44730ef5a7299edef57b096137b06ab64a4964aca56d072e7a0c0
7
- data.tar.gz: a698dc1828a99415b4b88b373541ad20b264933cb2d13b0c65b2efd6c4608361b40bb0dca4756f9a518dee3a9e7fa4f8c43e142dfb3a50bba391398f76744bd5
6
+ metadata.gz: 4431300d4963531af3f7c001a1f9b321ba1cdb8720721f9293046dccc07588b7a4bf5b00fa812623ddeb6e38e8a6f61fca84061f793fd9fc13ba46c6e4671d00
7
+ data.tar.gz: 39da07fb31ddad66c5a8140b1ef35e1150607d8761dae047e56bae804b90e618ece0f6a04bdff3c3e92ee2c3e5f68acf1072cf90602e67dc3ec71a9ffc3620fc
@@ -103,10 +103,7 @@ module Fastlane
103
103
  # if there's a callback, make sure it didn't switch branches
104
104
  other_action.ensure_git_branch(branch: "^#{intermediate_branch}/") unless intermediate_branch_created_callback.nil?
105
105
 
106
- base_branch_ref = base_branch.start_with?('origin/') ? base_branch : "origin/#{base_branch}"
107
- head_branch_ref = head_branch.start_with?('origin/') ? head_branch : "origin/#{head_branch}"
108
-
109
- if Fastlane::Helper::GitHelper.point_to_same_commit?(base_branch_ref, head_branch_ref)
106
+ if Fastlane::Helper::GitHelper.point_to_same_commit?(base_branch, head_branch)
110
107
  UI.error("No differences between #{head_branch} and #{base_branch}. Skipping PR creation.")
111
108
  return nil
112
109
  end
@@ -2,15 +2,39 @@ module Fastlane
2
2
  module Actions
3
3
  class IosGenerateStringsFileFromCodeAction < Action
4
4
  def self.run(params)
5
- files = files_matching(paths: params[:paths], exclude: params[:exclude])
6
- flags = [('-q' if params[:quiet]), ('-SwiftUI' if params[:swiftui])].compact
7
- flags += Array(params[:routines]).flat_map { |routine| ['-s', routine] }
8
- cmd = ['genstrings', '-o', params[:output_dir], *flags, *files]
9
- out = Actions.sh_control_output(*cmd, print_command: FastlaneCore::Globals.verbose?, print_command_output: true)
10
- out = out.scrub.strip.split("\n")
11
- errors = out.select { |line| line.include?('genstrings: error: ') }
12
- UI.user_error!(errors.join("\n")) unless !params[:fail_on_error] || errors.empty?
13
- out
5
+ output_encoding = begin
6
+ Encoding.find(params[:output_encoding])
7
+ rescue ArgumentError => e
8
+ UI.user_error!(e.message)
9
+ end
10
+
11
+ Dir.mktmpdir('genstrings-output-') do |tmpdir|
12
+ # Build the command arguments
13
+ files = files_matching(paths: params[:paths], exclude: params[:exclude])
14
+ flags = [
15
+ ('-q' if params[:quiet]),
16
+ ('-SwiftUI' if params[:swiftui]),
17
+ # If no endianness (-bigEndian vs -littleEndian) is specified, genstrings will use endianness of the current OS.
18
+ # Currently, genstrings runs only on macOS, which is little-endian, so this parameter is not strictly necessary.
19
+ # We make it explicit here to raise visibility on the relationship between the endianness of the genstring output and that of the encoding later on.
20
+ '-littleEndian',
21
+ ].compact
22
+ flags += Array(params[:routines]).flat_map { |routine| ['-s', routine] }
23
+ cmd = ['genstrings', '-o', tmpdir, *flags, *files]
24
+
25
+ # Run the genstrings command
26
+ cmd_output = Actions.sh_control_output(*cmd, print_command: FastlaneCore::Globals.verbose?, print_command_output: true)
27
+
28
+ # Extract errors from output, if any
29
+ cmd_output = cmd_output.scrub.strip.split("\n")
30
+ errors = cmd_output.select { |line| line.include?('genstrings: error: ') }
31
+ UI.user_error!(errors.join("\n")) unless !params[:fail_on_error] || errors.empty?
32
+
33
+ # Convert generated files to requested encoding if necessary, and copy to final destination
34
+ post_process_generated_files(source_dir: tmpdir, dest_dir: params[:output_dir], dest_encoding: output_encoding)
35
+
36
+ cmd_output
37
+ end
14
38
  end
15
39
 
16
40
  # Adds the proper `**/*.{m,swift}` to the list of paths
@@ -24,6 +48,7 @@ module Fastlane
24
48
  end
25
49
  end
26
50
 
51
+ # List files matching a list of glob patterns, except the ones matching the list of exclusion patterns
27
52
  def self.files_matching(paths:, exclude:)
28
53
  globbed_paths = paths.map { |p| glob_pattern(p) }
29
54
  Dir.glob(globbed_paths).reject do |file|
@@ -31,6 +56,24 @@ module Fastlane
31
56
  end
32
57
  end
33
58
 
59
+ # Convert the generated files in `source_dir` to the `dest_encoding` if necessary, then copy them to the final `dest_dir`
60
+ def self.post_process_generated_files(source_dir:, dest_dir:, dest_encoding:)
61
+ Dir.each_child(source_dir) do |filename|
62
+ source = File.join(source_dir, filename)
63
+ next if filename.start_with?('.') || !File.file?(source)
64
+
65
+ destination = File.join(dest_dir, filename)
66
+ if dest_encoding.name == 'UTF-16LE'
67
+ # genstrings generates UTF-16 LittleEndian by default, so if that's the requested output encoding, we just copy
68
+ # the file directly, to avoid the read/write dance, reduce memory footprint, and reduce risk of encoding errors on read
69
+ FileUtils.cp(source, destination)
70
+ else
71
+ content = File.read(source, binmode: true, encoding: 'BOM|UTF-16LE')
72
+ File.write(destination, content, binmode: true, encoding: dest_encoding.name)
73
+ end
74
+ end
75
+ end
76
+
34
77
  #####################################################
35
78
  # @!group Documentation
36
79
  #####################################################
@@ -85,6 +128,11 @@ module Fastlane
85
128
  env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_OUTPUT_DIR',
86
129
  description: 'The path to the directory where the generated `.strings` files should be created',
87
130
  type: String),
131
+ FastlaneCore::ConfigItem.new(key: :output_encoding,
132
+ env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_OUTPUT_ENCODING',
133
+ description: 'The encoding to convert the generated files to',
134
+ type: String,
135
+ default_value: 'UTF-16LE'), # The default encoding used by `genstrings` for generated files
88
136
  FastlaneCore::ConfigItem.new(key: :fail_on_error,
89
137
  env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_FAIL_ON_ERROR',
90
138
  description: 'If true, will fail with user_error! if `genstrings` printed any error while parsing',
@@ -174,20 +174,23 @@ module Fastlane
174
174
  #
175
175
  # @param ref1 [String] the first git reference to check.
176
176
  # @param ref2 [String] the second git reference to check.
177
+ # @param remote_name [String] the name of the remote repository to use (default is 'origin').
178
+ # If nil or empty, no remote prefix will be used.
177
179
  #
178
180
  # @return [Boolean] true if the two references point to the same commit, false otherwise.
179
181
  #
180
- def self.point_to_same_commit?(ref1, ref2)
182
+ def self.point_to_same_commit?(ref1, ref2, remote_name: 'origin')
181
183
  git_repo = Git.open(Dir.pwd)
182
184
 
185
+ ref1_full = remote_name.to_s.empty? ? ref1 : "#{remote_name}/#{ref1}"
186
+ ref2_full = remote_name.to_s.empty? ? ref2 : "#{remote_name}/#{ref2}"
183
187
  begin
184
- ref1_commit = git_repo.gcommit(ref1)
185
- ref2_commit = git_repo.gcommit(ref2)
188
+ ref1_commit = git_repo.gcommit(ref1_full)
189
+ ref2_commit = git_repo.gcommit(ref2_full)
186
190
  rescue StandardError => e
187
- puts "Error: #{e.message}"
191
+ UI.error "Error fetching commits for #{ref1_full} and #{ref2_full}: #{e.message}"
188
192
  return false
189
193
  end
190
-
191
194
  ref1_commit.sha == ref2_commit.sha
192
195
  end
193
196
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module Wpmreleasetoolkit
5
- VERSION = '12.0.0'
5
+ VERSION = '12.1.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-wpmreleasetoolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.0.0
4
+ version: 12.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-03 00:00:00.000000000 Z
11
+ date: 2024-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport