Skip to content

Instantly share code, notes, and snippets.

@dbgrandi
Created February 23, 2016 02:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbgrandi/a3d8ff7ae4f897a4d1f8 to your computer and use it in GitHub Desktop.
Save dbgrandi/a3d8ff7ae4f897a4d1f8 to your computer and use it in GitHub Desktop.
Script I use to check public API diffs between pod specs
#!/usr/bin/env ruby
require 'cocoapods'
def get_public_changes_between_versions(path, podspec, old_tag, new_tag)
pathlist = Pod::Sandbox::PathList.new(Pathname.new(path))
headers = []
spec = Pod::Specification.from_file podspec
# https://github.com/CocoaPods/cocoadocs.org/issues/35
[spec, *spec.recursive_subspecs].each do |internal_spec|
internal_spec.available_platforms.each do |platform|
consumer = Pod::Specification::Consumer.new(internal_spec, platform)
accessor = Pod::Sandbox::FileAccessor.new(pathlist, consumer)
# puts accessor.public_headers(true)
public_headers = accessor.public_headers(true)
if public_headers
headers += public_headers.map(&:to_s)
else
puts "Skipping headers for #{internal_spec} on platform #{platform} (no headers found).".blue
end
end
end
headers.uniq
end
unless ARGV.count == 4
puts "usage: ./public_diff.rb <path> <podspec> <old_tag> <new_tag>"
exit(-1)
end
# Input
#
# path -> path to checked out project
# podspec -> path to podspec
# old_tag -> tag of old commit
# new_tag -> tag of new commit
#
path = ARGV[0]
podspec = ARGV[1]
old_tag = ARGV[2]
new_tag = ARGV[3]
headers = get_public_changes_between_versions(path, podspec, old_tag, new_tag)
# puts headers
Dir.chdir path
puts "path = #{Dir.pwd}"
headers.each do |header|
h_path = header.sub(path, ".")
system "git diff #{old_tag} #{new_tag} '#{h_path}'"
end
Dir.chdir ".."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment