Class: SpmChecker
- Inherits:
-
Object
- Object
- SpmChecker
- Defined in:
- lib/spm_version_updates/spm_checker.rb
Overview
Core SPM version checking logic (migrated from Danger plugin)
Defined Under Namespace
Classes: DisallowedRepositoryHost
Constant Summary collapse
- VERSION_TAG_WORKER_COUNT =
8
Instance Attribute Summary collapse
-
#allow_hosts ⇒ Object
Returns the value of attribute allow_hosts.
-
#check_branches ⇒ Object
Returns the value of attribute check_branches.
-
#check_revisions ⇒ Object
Returns the value of attribute check_revisions.
-
#check_when_exact ⇒ Object
Returns the value of attribute check_when_exact.
-
#ignore_repos ⇒ Object
Returns the value of attribute ignore_repos.
-
#lookup_failure_handler ⇒ Object
Optional callable ‘(package, error)` invoked instead of raising when a git lookup fails, so callers like the Danger plugin can warn and keep checking the remaining packages.
-
#malformed_resolved_handler ⇒ Object
Optional callable ‘(resolved_path, error)` invoked instead of raising when a Package.resolved file is malformed; the file is skipped.
-
#report_above_maximum ⇒ Object
Returns the value of attribute report_above_maximum.
-
#report_pre_releases ⇒ Object
Returns the value of attribute report_pre_releases.
-
#repository_update_rules ⇒ Object
Returns the value of attribute repository_update_rules.
-
#version_tags_cache_dir ⇒ Object
Returns the value of attribute version_tags_cache_dir.
-
#version_tags_cache_ttl_seconds ⇒ Object
Returns the value of attribute version_tags_cache_ttl_seconds.
-
#warning_details ⇒ Object
readonly
Structured facts about each warning, used by the GitHub Action comment renderer.
Class Method Summary collapse
Instance Method Summary collapse
-
#check_for_updates(xcodeproj_path) ⇒ Array<String>
Check for SPM updates using an Xcode project as the source of dependencies.
-
#check_manifests(manifest_paths, resolved_paths = nil) ⇒ Array<String>
Check for SPM updates using one or more ‘Package.swift` manifests as the source of dependencies.
-
#initialize ⇒ SpmChecker
constructor
A new instance of SpmChecker.
Constructor Details
#initialize ⇒ SpmChecker
Returns a new instance of SpmChecker.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/spm_version_updates/spm_checker.rb', line 54 def initialize @check_when_exact = @check_revisions = @report_above_maximum = @report_pre_releases = false @check_branches = true @lookup_failure_handler = @malformed_resolved_handler = nil @ignore_repos = [] @repository_update_rules = RepositoryUpdateRules.empty @allow_hosts = [] @warnings = [] @warning_details = [] @version_tags_cache = {} @version_tag_lookup_errors = {} @reported_lookup_failures = {} @version_tags_cache_dir = nil @version_tags_cache_ttl_seconds = VersionTagsPersistentCache::DEFAULT_TTL_SECONDS end |
Instance Attribute Details
#allow_hosts ⇒ Object
Returns the value of attribute allow_hosts.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def allow_hosts @allow_hosts end |
#check_branches ⇒ Object
Returns the value of attribute check_branches.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def check_branches @check_branches end |
#check_revisions ⇒ Object
Returns the value of attribute check_revisions.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def check_revisions @check_revisions end |
#check_when_exact ⇒ Object
Returns the value of attribute check_when_exact.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def check_when_exact @check_when_exact end |
#ignore_repos ⇒ Object
Returns the value of attribute ignore_repos.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def ignore_repos @ignore_repos end |
#lookup_failure_handler ⇒ Object
Optional callable ‘(package, error)` invoked instead of raising when a git lookup fails, so callers like the Danger plugin can warn and keep checking the remaining packages. When nil (the default), lookup failures raise one combined GitOperations::LsRemoteError exactly as before.
43 44 45 |
# File 'lib/spm_version_updates/spm_checker.rb', line 43 def lookup_failure_handler @lookup_failure_handler end |
#malformed_resolved_handler ⇒ Object
Optional callable ‘(resolved_path, error)` invoked instead of raising when a Package.resolved file is malformed; the file is skipped. When nil (the default), PackageResolved::MalformedFileError is raised.
48 49 50 |
# File 'lib/spm_version_updates/spm_checker.rb', line 48 def malformed_resolved_handler @malformed_resolved_handler end |
#report_above_maximum ⇒ Object
Returns the value of attribute report_above_maximum.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def report_above_maximum @report_above_maximum end |
#report_pre_releases ⇒ Object
Returns the value of attribute report_pre_releases.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def report_pre_releases @report_pre_releases end |
#repository_update_rules ⇒ Object
Returns the value of attribute repository_update_rules.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def repository_update_rules @repository_update_rules end |
#version_tags_cache_dir ⇒ Object
Returns the value of attribute version_tags_cache_dir.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def @version_tags_cache_dir end |
#version_tags_cache_ttl_seconds ⇒ Object
Returns the value of attribute version_tags_cache_ttl_seconds.
28 29 30 |
# File 'lib/spm_version_updates/spm_checker.rb', line 28 def @version_tags_cache_ttl_seconds end |
#warning_details ⇒ Object (readonly)
Structured facts about each warning, used by the GitHub Action comment renderer. ‘check_for_updates` and `check_manifests` still return the legacy string warnings for compatibility with existing plugin-style callers.
26 27 28 |
# File 'lib/spm_version_updates/spm_checker.rb', line 26 def warning_details @warning_details end |
Class Method Details
.redact_credentials(value) ⇒ Object
50 51 52 |
# File 'lib/spm_version_updates/spm_checker.rb', line 50 def self.redact_credentials(value) CredentialRedactor.redact(value) end |
Instance Method Details
#check_for_updates(xcodeproj_path) ⇒ Array<String>
Check for SPM updates using an Xcode project as the source of dependencies.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/spm_version_updates/spm_checker.rb', line 74 def check_for_updates(xcodeproj_path) clear_warnings normalize_ignore_repos normalize_allow_hosts remote_packages = XcodeParser.get_packages(xcodeproj_path) resolved_versions = XcodeParser.get_resolved_versions(xcodeproj_path, &@malformed_resolved_handler) puts("Found resolved versions for #{resolved_versions.size} packages") warn_for_empty_xcode_project(remote_packages, resolved_versions, xcodeproj_path) check_packages(remote_packages, resolved_versions) @warnings end |
#check_manifests(manifest_paths, resolved_paths = nil) ⇒ Array<String>
Check for SPM updates using one or more ‘Package.swift` manifests as the source of dependencies.
Resolved pins from every ‘Package.resolved` are merged by normalized repository URL into a single lookup. Each manifest’s direct dependencies are then compared against that lookup, and the originating manifest is attached to every warning so multi-manifest repos can tell where an update applies.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/spm_version_updates/spm_checker.rb', line 103 def check_manifests(manifest_paths, resolved_paths = nil) clear_warnings normalize_ignore_repos normalize_allow_hosts resolved_versions = merged_resolved_versions(manifest_paths, resolved_paths) puts("Found resolved versions for #{resolved_versions.size} packages") manifest_paths.each { |manifest_path| remote_packages = ManifestParser.get_packages(manifest_path) check_packages(remote_packages, resolved_versions, manifest_path) } @warnings end |