-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure swiftformat + modify license CI check (#247)
* Implement swiftformat to auto-format sample code * Add format build phase to MobileBuyIntegration
- Loading branch information
Showing
5 changed files
with
58 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--indent 4 | ||
--linebreaks lf | ||
--wraparguments before-first | ||
--wrapcollections before-first | ||
--commas inline | ||
--allman false | ||
--semicolons inline | ||
--trimwhitespace always | ||
--disable redundantReturn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'find' | ||
|
||
# Read and normalize the license text by removing extra whitespace | ||
license_text = "/*\n" + File.read('LICENSE') + "*/\n" | ||
normalized_license = license_text.gsub(/\s+/, ' ').strip | ||
|
||
Find.find('.') do |path| | ||
next unless File.file?(path) && path.end_with?('.swift') && !path.end_with?('Package.swift') | ||
|
||
# Read the current content of the Swift file | ||
content = File.read(path) | ||
|
||
# Extract the existing license part from the file, if present | ||
if content =~ /\A\s*\/\*.*?\*\//m | ||
existing_license = $&.gsub(/\s+/, ' ').strip | ||
else | ||
existing_license = "" | ||
end | ||
|
||
# Check if the existing license matches the normalized expected license | ||
if existing_license != normalized_license | ||
puts "License missing or incorrect in file: #{path}" | ||
exit 1 | ||
else | ||
puts "✔️ #{path}" | ||
end | ||
end |