Skip to content

Commit

Permalink
Rename dependencyVersions as requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonboyle committed Jul 23, 2018
1 parent 5c72cef commit 2fb7565
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Source/CarthageKit/CompatibilityInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ public struct CompatibilityInfo: Equatable {
public let pinnedVersion: PinnedVersion

/// Versions of this dependency with which it may or may not be compatible
public let dependencyVersions: [(Dependency, VersionSpecifier)]
public let requirements: [(Dependency, VersionSpecifier)]

/// The versions which are not compatible with the pinned version of this dependency
public var incompatibleVersions: [(Dependency, VersionSpecifier)] {
return dependencyVersions.filter { _, version in !version.isSatisfied(by: pinnedVersion) }
public var incompatibleRequirements: [(Dependency, VersionSpecifier)] {
return requirements.filter { _, version in !version.isSatisfied(by: pinnedVersion) }
}

public static func == (lhs: CompatibilityInfo, rhs: CompatibilityInfo) -> Bool {
return lhs.dependency == rhs.dependency &&
lhs.pinnedVersion == rhs.pinnedVersion &&
lhs.dependencyVersions.elementsEqual(rhs.dependencyVersions, by: { $0.0 == $1.0 && $0.1 == $1.1 })
lhs.requirements.elementsEqual(rhs.requirements, by: { $0.0 == $1.0 && $0.1 == $1.1 })
}
}
2 changes: 1 addition & 1 deletion Source/CarthageKit/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ extension CarthageError: CustomStringConvertible {
var message = "The following incompatibilities were found in Cartfile.resolved:\n"
var lines: [String] = []
incompatibilities.forEach { incompatibility in
for (dependency, version) in incompatibility.dependencyVersions {
for (dependency, version) in incompatibility.requirements {
lines.append("* \(incompatibility.dependency.name) is incompatible with \(dependency.name) \(version)")
}
}
Expand Down
20 changes: 10 additions & 10 deletions Source/CarthageKit/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ public final class Project { // swiftlint:disable:this type_body_length
.collect()
.map { parentAndTransitiveDependencies in
var dict: [Dependency: [(Dependency, VersionSpecifier)]] = [:]
parentAndTransitiveDependencies.forEach { parentDependency, dependencyVersions in
parentAndTransitiveDependencies.forEach { parentDependency, requirements in
var array = dict[parentDependency] ?? []
array.append(dependencyVersions)
array.append(requirements)
dict[parentDependency] = array
}
return dict
Expand Down Expand Up @@ -1138,7 +1138,7 @@ public final class Project { // swiftlint:disable:this type_body_length
/// of each dependency in Cartfile.resolved which is incompatible with
/// one or more of the versions specified in a transitive dependency's
/// Cartfile. The incompatible versions are stored in the
/// dependencyVersions property of the CompatibilityInfo object.
/// requirements property of the CompatibilityInfo object.
public func verify(resolvedCartfile: ResolvedCartfile) -> SignalProducer<(), CarthageError> {
let resolvedCartfileProducer = SignalProducer(value: resolvedCartfile).replayLazily(upTo: 1)

Expand All @@ -1154,8 +1154,8 @@ public final class Project { // swiftlint:disable:this type_body_length
}
.map { (dependencyDict: [Dependency: [(Dependency, VersionSpecifier)]]) -> [Dependency: [(Dependency, VersionSpecifier)]] in
var dict: [Dependency: [(Dependency, VersionSpecifier)]] = [:]
dependencyDict.forEach { parentDependency, dependencyVersions in
dependencyVersions.forEach { dependency, version in
dependencyDict.forEach { parentDependency, requirements in
requirements.forEach { dependency, version in
var array = dict[dependency] ?? []
array.append((parentDependency, version))
dict[dependency] = array
Expand All @@ -1170,20 +1170,20 @@ public final class Project { // swiftlint:disable:this type_body_length
var result: [CompatibilityInfo] = []
for (dependency, pinnedVersion) in dependenciesWithPinnedVersion {
// Skip non-semantic resolved versions and transitive dependencies without semantic versions
if case .success = SemanticVersion.from(pinnedVersion), let dependencyVersions = dependenciesWithVersionSpecifiers[dependency] {
result.append(CompatibilityInfo(dependency: dependency, pinnedVersion: pinnedVersion, dependencyVersions: dependencyVersions))
if case .success = SemanticVersion.from(pinnedVersion), let requirements = dependenciesWithVersionSpecifiers[dependency] {
result.append(CompatibilityInfo(dependency: dependency, pinnedVersion: pinnedVersion, requirements: requirements))
}
}
return result
}
.flatMap(.merge) { (compatibilityInfos: [CompatibilityInfo]) -> SignalProducer<(), CarthageError> in
let incompatibleInfos: [CompatibilityInfo] = compatibilityInfos.compactMap { compatibilityInfo in
let incompatibleVersions = compatibilityInfo.incompatibleVersions
if !incompatibleVersions.isEmpty {
let incompatibleRequirements = compatibilityInfo.incompatibleRequirements
if !incompatibleRequirements.isEmpty {
return CompatibilityInfo(
dependency: compatibilityInfo.dependency,
pinnedVersion: compatibilityInfo.pinnedVersion,
dependencyVersions: incompatibleVersions)
requirements: incompatibleRequirements)
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/CarthageKitTests/VerifySpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ class VerifySpec: QuickSpec {
expect(infos?[0].dependency) == alamofireDependency
expect(infos?[0].pinnedVersion) == PinnedVersion("5.0.0")

expect(infos?[0].dependencyVersions.contains(where: { $0 == moya_4_1_0 })) == true
expect(infos?[0].requirements.contains(where: { $0 == moya_4_1_0 })) == true

expect(infos?[1].dependency) == resultDependency
expect(infos?[1].pinnedVersion) == PinnedVersion("4.0.0")

expect(infos?[1].dependencyVersions.contains(where: { $0 == moya_3_1_0 })) == true
expect(infos?[1].dependencyVersions.contains(where: { $0 == reactiveSwift_3_2_1 })) == true
expect(infos?[1].requirements.contains(where: { $0 == moya_3_1_0 })) == true
expect(infos?[1].requirements.contains(where: { $0 == reactiveSwift_3_2_1 })) == true
}
}
}
Expand Down

0 comments on commit 2fb7565

Please sign in to comment.