diff --git a/.github/actions/notices_generation/app.rb b/.github/actions/notices_generation/app.rb index 2f2858e688..fd48d1b3c3 100644 --- a/.github/actions/notices_generation/app.rb +++ b/.github/actions/notices_generation/app.rb @@ -16,6 +16,7 @@ require 'cocoapods' require 'digest' +require 'open3' require 'optparse' require 'plist' require 'tmpdir' @@ -67,7 +68,7 @@ def create_podfile(path: , sources: , target: , pods: [], min_ios_version: , sea if source == "https://cdn.cocoapods.org/" next end - `pod repo add #{Digest::MD5.hexdigest source} #{source}` + system('pod', 'repo', 'add', Digest::SHA256.hexdigest(source), source) end end output += "use_frameworks! :linkage => :static\n" @@ -77,11 +78,18 @@ def create_podfile(path: , sources: , target: , pods: [], min_ios_version: , sea for pod in pods do if search_local_pod_version # `pod search` will search a pod locally and generate a corresonding pod - # config in a Podfile with `grep`, e.g. - # pod search Firebase | grep "pod '.*" -m 1 + # config in a Podfile with ruby match, e.g. + # pod search Firebase # will generate # pod 'Firebase', '~> 9.0.0' - output += `pod search "#{pod}" | grep "pod '.*" -m 1` + stdout, status = Open3.capture2('pod', 'search', pod) + match = status.success? ? stdout.match(/pod '.*/) : nil + if match + output += "#{match[0]}\n" + else + puts "Warning: pod search failed or found no match for '#{pod}'. Falling back to unversioned pod." + output += "pod \'#{pod}\'\n" + end else output += "pod \'#{pod}\'\n" end diff --git a/scripts/create_pull_request.rb b/scripts/create_pull_request.rb index bb24943efd..e4f00531c5 100644 --- a/scripts/create_pull_request.rb +++ b/scripts/create_pull_request.rb @@ -52,11 +52,17 @@ BASE_BRANCH=@options[:base_branch] COMMIT_COMMENT=@options[:commit_comment] def generate_pr_for_target_changes(repo_root:, target_path:) - if `git diff #{TARGET_PATH}`=="" - puts "The file, #{TARGET_PATH}, has no changes." - return + abs_target_path = File.expand_path(target_path) + Dir.chdir(repo_root) do + if system('git', 'diff', '--quiet', abs_target_path) + puts "The file, #{target_path}, has no changes." + return + end + system('git', 'checkout', '-B', BASE_BRANCH) || raise("git checkout failed") + system('git', 'add', abs_target_path) || raise("git add failed") + system('git', 'commit', '-m', COMMIT_COMMENT) || raise("git commit failed") + system('git', 'push', '-u', 'origin', BASE_BRANCH) || raise("git push failed") end - system("cd #{REPO_ROOT}\ngit checkout -b #{BASE_BRANCH}\ngit add #{TARGET_PATH}\ngit commit -m \"#{COMMIT_COMMENT}\"\ngit push -u origin #{BASE_BRANCH}") client = Octokit::Client.new(access_token: ACCESS_TOKEN) client.create_pull_request("firebase/firebase-ios-sdk", "main", BASE_BRANCH, PR_TITLE, PR_BODY) end