Class: Danger::DangerSpmVersionUpdates
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerSpmVersionUpdates
- Defined in:
- lib/spm_version_updates/plugin.rb
Overview
A Danger plugin for checking if there are versions upgrades available for SPM dependencies
Instance Attribute Summary collapse
-
#check_when_exact ⇒ Boolean
Whether to check when dependencies are exact versions or commits, default false.
-
#ignore_repos ⇒ Array<String>
A list of repository URLs for packages to ignore entirely.
-
#report_above_maximum ⇒ Boolean
Whether to report versions above the maximum version range, default false.
-
#report_pre_releases ⇒ Boolean
Whether to report pre-release versions, default false.
Instance Method Summary collapse
-
#check_for_updates(xcodeproj_path) ⇒ void
A method that you can call from your Dangerfile.
Instance Attribute Details
#check_when_exact ⇒ Boolean
Whether to check when dependencies are exact versions or commits, default false
19 20 21 |
# File 'lib/spm_version_updates/plugin.rb', line 19 def check_when_exact @check_when_exact end |
#ignore_repos ⇒ Array<String>
A list of repository URLs for packages to ignore entirely
31 32 33 |
# File 'lib/spm_version_updates/plugin.rb', line 31 def ignore_repos @ignore_repos end |
#report_above_maximum ⇒ Boolean
Whether to report versions above the maximum version range, default false
23 24 25 |
# File 'lib/spm_version_updates/plugin.rb', line 23 def report_above_maximum @report_above_maximum end |
#report_pre_releases ⇒ Boolean
Whether to report pre-release versions, default false
27 28 29 |
# File 'lib/spm_version_updates/plugin.rb', line 27 def report_pre_releases @report_pre_releases end |
Instance Method Details
#check_for_updates(xcodeproj_path) ⇒ void
This method returns an undefined value.
A method that you can call from your Dangerfile
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/spm_version_updates/plugin.rb', line 38 def check_for_updates(xcodeproj_path) remote_packages = Xcode.get_packages(xcodeproj_path) resolved_versions = Xcode.get_resolved_versions(xcodeproj_path) $stderr.puts("Found resolved versions for #{resolved_versions.size} packages") self.ignore_repos = self.ignore_repos&.map! { |repo| Git.trim_repo_url(repo) } remote_packages.each { |repository_url, requirement| next if self.ignore_repos&.include?(repository_url) name = Git.repo_name(repository_url) resolved_version = resolved_versions[repository_url] kind = requirement["kind"] if resolved_version.nil? $stderr.puts("Unable to locate the current version for #{name} (#{repository_url})") next end if kind == "branch" branch = requirement["branch"] last_commit = Git.branch_last_commit(repository_url, branch) warn("Newer commit available for #{name} (#{branch}): #{last_commit}") unless last_commit == resolved_version next end available_versions = Git.(repository_url) next if available_versions.first.to_s == resolved_version if kind == "exactVersion" && @check_when_exact warn_for_new_versions_exact(available_versions, name, resolved_version) elsif kind == "upToNextMajorVersion" warn_for_new_versions(:major, available_versions, name, resolved_version) elsif kind == "upToNextMinorVersion" warn_for_new_versions(:minor, available_versions, name, resolved_version) elsif kind == "versionRange" warn_for_new_versions_range(available_versions, name, requirement, resolved_version) end } end |