Skip to content

Commit

Permalink
[gardening] Extract Submodule into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesyo committed Aug 22, 2017
1 parent 49e6657 commit 3e9cb2f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
4 changes: 4 additions & 0 deletions Carthage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
CD9F3D931E6E6FC000B98A1A /* BinaryJSONError.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD9F3D921E6E6FC000B98A1A /* BinaryJSONError.swift */; };
CDA0B6CA1C468E67006C499C /* GitURLSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDA0B6C91C468E67006C499C /* GitURLSpec.swift */; };
CDB099241E6DC2D40030B4A8 /* ScannableError.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDB099231E6DC2D40030B4A8 /* ScannableError.swift */; };
CDBE654C1F4BF0040060D94E /* Submodule.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDBE654B1F4BF0040060D94E /* Submodule.swift */; };
CDCE1CC41C170E8A00B2ED88 /* TestResolvedCartfile.resolved in Resources */ = {isa = PBXBuildFile; fileRef = CDCE1CC21C170E8100B2ED88 /* TestResolvedCartfile.resolved */; };
CDE559291E12263A00ED7F5F /* BuildSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDE559281E12263A00ED7F5F /* BuildSettings.swift */; };
CDF94D951E71144300200486 /* DuplicateDependency.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF94D941E71144300200486 /* DuplicateDependency.swift */; };
Expand Down Expand Up @@ -211,6 +212,7 @@
CD9F3D921E6E6FC000B98A1A /* BinaryJSONError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BinaryJSONError.swift; sourceTree = "<group>"; };
CDA0B6C91C468E67006C499C /* GitURLSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitURLSpec.swift; sourceTree = "<group>"; };
CDB099231E6DC2D40030B4A8 /* ScannableError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScannableError.swift; sourceTree = "<group>"; };
CDBE654B1F4BF0040060D94E /* Submodule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Submodule.swift; sourceTree = "<group>"; };
CDCE1CC21C170E8100B2ED88 /* TestResolvedCartfile.resolved */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TestResolvedCartfile.resolved; sourceTree = "<group>"; };
CDE559281E12263A00ED7F5F /* BuildSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BuildSettings.swift; sourceTree = "<group>"; };
CDF94D941E71144300200486 /* DuplicateDependency.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DuplicateDependency.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -506,6 +508,7 @@
D01D82D61A10160700F0DD94 /* Resolver.swift */,
D0DE89431A0F2D9B0030A3EC /* Scannable.swift */,
CDB099231E6DC2D40030B4A8 /* ScannableError.swift */,
CDBE654B1F4BF0040060D94E /* Submodule.swift */,
3BE5BD981E4E58ED00DDDC45 /* SwiftVersionError.swift */,
D0DE893F1A0F2CB00030A3EC /* Version.swift */,
F1CB3CFB1D63D05D00C9EB99 /* VersionFile.swift */,
Expand Down Expand Up @@ -833,6 +836,7 @@
D0A2025E1B114D1000C71375 /* ProducerQueue.swift in Sources */,
D0D1219019E88A15005E4BAA /* Cartfile.swift in Sources */,
F603929919EA29F80050A6AF /* Project.swift in Sources */,
CDBE654C1F4BF0040060D94E /* Submodule.swift in Sources */,
D069CA241A4E3B2700314A85 /* Archive.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
39 changes: 0 additions & 39 deletions Source/CarthageKit/Git.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,6 @@ public func strippingGitSuffix(_ string: String) -> String {
return string.stripping(suffix: ".git")
}

/// A Git submodule.
public struct Submodule {
/// The name of the submodule. Usually (but not always) the same as the
/// path.
public let name: String

/// The relative path at which the submodule is checked out.
public let path: String

/// The URL from which the submodule should be cloned, if present.
public var url: GitURL

/// The SHA checked out in the submodule.
public var sha: String

public init(name: String, path: String, url: GitURL, sha: String) {
self.name = name
self.path = path
self.url = url
self.sha = sha
}
}

extension Submodule: Hashable {
public static func == (_ lhs: Submodule, _ rhs: Submodule) -> Bool {
return lhs.name == rhs.name && lhs.path == rhs.path && lhs.url == rhs.url && lhs.sha == rhs.sha
}

public var hashValue: Int {
return name.hashValue
}
}

extension Submodule: CustomStringConvertible {
public var description: String {
return "\(name) @ \(sha)"
}
}

/// Struct to encapsulate global fetch interval cache
public struct FetchCache {
/// Amount of time before a git repository is fetched again. Defaults to 1 minute
Expand Down
38 changes: 38 additions & 0 deletions Source/CarthageKit/Submodule.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// A Git submodule.
public struct Submodule {
/// The name of the submodule. Usually (but not always) the same as the
/// path.
public let name: String

/// The relative path at which the submodule is checked out.
public let path: String

/// The URL from which the submodule should be cloned, if present.
public var url: GitURL

/// The SHA checked out in the submodule.
public var sha: String

public init(name: String, path: String, url: GitURL, sha: String) {
self.name = name
self.path = path
self.url = url
self.sha = sha
}
}

extension Submodule: Hashable {
public static func == (_ lhs: Submodule, _ rhs: Submodule) -> Bool {
return lhs.name == rhs.name && lhs.path == rhs.path && lhs.url == rhs.url && lhs.sha == rhs.sha
}

public var hashValue: Int {
return name.hashValue
}
}

extension Submodule: CustomStringConvertible {
public var description: String {
return "\(name) @ \(sha)"
}
}

0 comments on commit 3e9cb2f

Please sign in to comment.