module Fastlane::Helper

Public Class Methods

authenticate(gcloud_key_file) click to toggle source
# File lib/fastlane/plugin/snapshot_test/helper/helper.rb, line 7
def self.authenticate(gcloud_key_file)
  UI.message "Authenticate with GCP"
  Action.sh("gcloud auth activate-service-account --key-file #{gcloud_key_file}")
end
calc_aspect_ratio(imagePath) click to toggle source
# File lib/fastlane/plugin/snapshot_test/helper/helper.rb, line 37
def self.calc_aspect_ratio(imagePath)
  width, height = FastImage.size(imagePath)
  UI.message "Image(#{imagePath}) size #{width} * #{height}"
  height / width.to_f
end
find_base_commit_hash(bucket_name, base_branch, current_branch) click to toggle source
# File lib/fastlane/plugin/snapshot_test/helper/helper.rb, line 20
def self.find_base_commit_hash(bucket_name, base_branch, current_branch)
  base_commit_hash = Action.sh("git merge-base origin/#{base_branch} #{current_branch}").chomp!
  dirs = `gsutil ls gs://#{bucket_name}/ | grep -e "/$"`.split("\n")
             .map { |s| s[/(?<=gs:\/\/#{bucket_name}\/)(.*)(?=\/)/] }
  hashes = Action.sh("git log origin/#{base_branch} --pretty=%H").split("\n")
  hashes[hashes.index(base_commit_hash)..-1].each { |hash|
    if dirs.include?(hash)
      return hash
    end
  }
  nil
end
firebase_object_url(bucket, path) click to toggle source
# File lib/fastlane/plugin/snapshot_test/helper/helper.rb, line 33
def self.firebase_object_url(bucket, path)
  "https://firebasestorage.googleapis.com/v0/b/#{bucket}/o/#{CGI.escape(path)}?alt=media"
end
get_current_branch() click to toggle source
# File lib/fastlane/plugin/snapshot_test/helper/helper.rb, line 16
def self.get_current_branch
  Action.sh("git symbolic-ref --short HEAD").chomp!
end
get_current_commit_hash() click to toggle source
# File lib/fastlane/plugin/snapshot_test/helper/helper.rb, line 12
def self.get_current_commit_hash
  Action.sh("git rev-parse HEAD").chomp!
end