class Danger::DangerIosVersionChange
Asserts the version string has been changed in your iOS XCode project. This is done by checking the git diff of your project's Info.plist file. The plugin will either call Danger's fail method or do nothing if the version string was changed.
@example Assert the version string changed for your iOS project
# Calls Danger `fail` if the version string not updated or nothing if it has changed. ios_version_change.assert_version_changed("ProjectName/Info.plist")
@tags ios, xcode, ci, continuous integration
Public Class Methods
The instance name used in the Dangerfile @return [String]
# File lib/ios_version_change/plugin.rb, line 16 def self.instance_name "ios_version_change" end
# File lib/ios_version_change/plugin.rb, line 20 def initialize(dangerfile) super(dangerfile) end
Public Instance Methods
Asserts the version string has been changed in your iOS XCode project.
@example Assert the version string changed for your iOS project
# Calls Danger `fail` if the version string not updated or nothing if it has changed. ios_version_change.assert_version_changed("ProjectName/Info.plist")
@param [String] info_plist_file_path
Path to Info.plist file for XCode project.
@return [void]
# File lib/ios_version_change/plugin.rb, line 48 def assert_version_changed(info_plist_file_path) unless File.file?(info_plist_file_path) fail "Info.plist at path " + info_plist_file_path + " does not exist." return # rubocop:disable UnreachableCode end unless git.diff_for_file(info_plist_file_path) # No diff found for Info.plist file. fail "You did not edit your Info.plist file at all. Therefore, you did not change the iOS version." return # rubocop:disable UnreachableCode end git_diff_string = git.diff_for_file(info_plist_file_path).patch assert_version_changed_diff(git_diff_string) end
Ignore. Pass the git diff string here to see if the version string has been updated. Use `ios_version_change.assert_version_changed(“ProjectName/Info.plist”)` instead as it's more convenient sending the path to the Info.plist file. @return [void]
# File lib/ios_version_change/plugin.rb, line 26 def assert_version_changed_diff(git_diff_string) git_diff_lines = git_diff_string.lines git_diff_string.each_line.each_with_index do |line, index| next unless line.include? "<key>CFBundleShortVersionString</key>" # we need to check the next 2 lines of the string to determine if it's a git diff change. if git_diff_lines.length >= (index + 3) && git_diff_lines[index + 1][0] == "-" && git_diff_lines[index + 2][0] == "+" return # rubocop:disable NonLocalExitFromIterator end end fail "You did not change the iOS version." end