diff --git a/Cartfile b/Cartfile index 9e4df54..04b9229 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "antitypical/Result" ~> 0.4.1 +github "antitypical/Result" ~> 1.0.1 diff --git a/Cartfile.private b/Cartfile.private index 1393c22..b4bf4dd 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,4 +1,4 @@ github "jspahrsummers/xcconfigs" >= 0.7.2 -github "Quick/Quick" "155f858bce082373fc60d0c0a63415bf336c676b" -github "Quick/Nimble" ~> 0.4.1 -github "modocache/Guanaco" "26b6ceff4b8912abd0dfc3a9eed0a46527e040e3" +github "Quick/Quick" "v0.8.0" +github "Quick/Nimble" ~> 3.0.0 +github "modocache/Guanaco" "5031bf67297afbe61ac0f2fbf3e3e8400b3f8888" diff --git a/Cartfile.resolved b/Cartfile.resolved index 85eb6a0..db7e069 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,6 +1,5 @@ -github "robrix/Box" "1.2.2" -github "modocache/Guanaco" "26b6ceff4b8912abd0dfc3a9eed0a46527e040e3" -github "Quick/Nimble" "v0.4.2" -github "Quick/Quick" "155f858bce082373fc60d0c0a63415bf336c676b" -github "jspahrsummers/xcconfigs" "0.8" -github "antitypical/Result" "0.4.1" +github "modocache/Guanaco" "5031bf67297afbe61ac0f2fbf3e3e8400b3f8888" +github "Quick/Nimble" "v3.0.0" +github "Quick/Quick" "v0.8.0" +github "antitypical/Result" "1.0.1" +github "jspahrsummers/xcconfigs" "0.8.1" diff --git a/Carthage/Checkouts/Box b/Carthage/Checkouts/Box deleted file mode 160000 index bbe4e61..0000000 --- a/Carthage/Checkouts/Box +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bbe4e612a03ffe0bbb0e2e476c2be4534b6777a5 diff --git a/Carthage/Checkouts/Guanaco b/Carthage/Checkouts/Guanaco index 26b6cef..5031bf6 160000 --- a/Carthage/Checkouts/Guanaco +++ b/Carthage/Checkouts/Guanaco @@ -1 +1 @@ -Subproject commit 26b6ceff4b8912abd0dfc3a9eed0a46527e040e3 +Subproject commit 5031bf67297afbe61ac0f2fbf3e3e8400b3f8888 diff --git a/Carthage/Checkouts/Nimble b/Carthage/Checkouts/Nimble index 8927113..676d1c8 160000 --- a/Carthage/Checkouts/Nimble +++ b/Carthage/Checkouts/Nimble @@ -1 +1 @@ -Subproject commit 8927113f877f32c8a01b41b746c4ac261b42c48e +Subproject commit 676d1c8aedd09253229474a5dca2fddbf3b445a1 diff --git a/Carthage/Checkouts/Quick b/Carthage/Checkouts/Quick index 155f858..46b38c9 160000 --- a/Carthage/Checkouts/Quick +++ b/Carthage/Checkouts/Quick @@ -1 +1 @@ -Subproject commit 155f858bce082373fc60d0c0a63415bf336c676b +Subproject commit 46b38c9c06b068baede09586aa281a6f075b2494 diff --git a/Carthage/Checkouts/Result b/Carthage/Checkouts/Result index 7ae33c6..1a2c456 160000 --- a/Carthage/Checkouts/Result +++ b/Carthage/Checkouts/Result @@ -1 +1 @@ -Subproject commit 7ae33c66eb7ed815d6066f2e9ecc372091423832 +Subproject commit 1a2c456268f4106f1b9b9e107920851f7fd2a8cd diff --git a/Carthage/Checkouts/xcconfigs b/Carthage/Checkouts/xcconfigs index 813127f..d78854b 160000 --- a/Carthage/Checkouts/xcconfigs +++ b/Carthage/Checkouts/xcconfigs @@ -1 +1 @@ -Subproject commit 813127f87f66fa14a7da03d3fa8410c02d2075d6 +Subproject commit d78854b22b9567e7f30d748bdd4966c86bcc93a5 diff --git a/SwiftGit2.xcodeproj/project.pbxproj b/SwiftGit2.xcodeproj/project.pbxproj index 8d30757..32e20db 100644 --- a/SwiftGit2.xcodeproj/project.pbxproj +++ b/SwiftGit2.xcodeproj/project.pbxproj @@ -634,7 +634,8 @@ BEB31F1A1A0D6F7A00F525B9 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastSwiftUpdateCheck = 0720; + LastUpgradeCheck = 0720; ORGANIZATIONNAME = "GitHub, Inc"; TargetAttributes = { BEB31F221A0D6F7A00F525B9 = { @@ -765,6 +766,7 @@ COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -868,6 +870,7 @@ "-lcrypto", "-lssl", ); + PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = SwiftGit2; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -897,6 +900,7 @@ "-lcrypto", "-lssl", ); + PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = SwiftGit2; SKIP_INSTALL = YES; }; @@ -917,6 +921,7 @@ ); INFOPLIST_FILE = SwiftGit2Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -932,6 +937,7 @@ ); INFOPLIST_FILE = SwiftGit2Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.libgit2.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/SwiftGit2.xcodeproj/xcshareddata/xcschemes/SwiftGit2-OSX.xcscheme b/SwiftGit2.xcodeproj/xcshareddata/xcschemes/SwiftGit2-OSX.xcscheme index ae0c67e..ccfba7c 100644 --- a/SwiftGit2.xcodeproj/xcshareddata/xcschemes/SwiftGit2-OSX.xcscheme +++ b/SwiftGit2.xcodeproj/xcshareddata/xcschemes/SwiftGit2-OSX.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -39,15 +39,18 @@ + + - - diff --git a/SwiftGit2.xcworkspace/xcshareddata/SwiftGit2.xcscmblueprint b/SwiftGit2.xcworkspace/xcshareddata/SwiftGit2.xcscmblueprint new file mode 100644 index 0000000..dcf961c --- /dev/null +++ b/SwiftGit2.xcworkspace/xcshareddata/SwiftGit2.xcscmblueprint @@ -0,0 +1,107 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "0B2A3BCB00C86293DA74B6A9239BA502F6488D88+++937A20B", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "95438028B10BBB846574013D29F154A00556A9D1+++D5553EB" : 0, + "D0725CAC6FF2D66F2C83C2C48DC12106D42DAA64+++8BD7695" : 0, + "57C931977B7D2307CC013C2BD93F90CF7C676790+++139D2B1" : 0, + "956D2B21DD155C49504BB67697A67F7C5351A353+++5CC92F5" : 0, + "E35CE1831829A79469F2167CADA9B1D9BA6B0BA6+++3D78C67" : 0, + "956D2B21DD155C49504BB67697A67F7C5351A353+++0FC0BCD" : 0, + "95438028B10BBB846574013D29F154A00556A9D1+++5AB1F94" : 0, + "956D2B21DD155C49504BB67697A67F7C5351A353+++3988B36" : 0, + "0B2A3BCB00C86293DA74B6A9239BA502F6488D88+++937A20B" : 0, + "E084C86B03F81D63323C9E7510697EA528A758C7+++9C11E0D" : 0, + "57C931977B7D2307CC013C2BD93F90CF7C676790+++27D14BF" : 0, + "57C931977B7D2307CC013C2BD93F90CF7C676790+++8DA764B" : 0, + "70783EE7218D87FCBAABD7787F6E3A25EFFAFB2F+++E1067AA" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "ABD5A4E5-DBDA-485E-A4B2-44A76138E5AA", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "95438028B10BBB846574013D29F154A00556A9D1+++D5553EB" : "SwiftGit2\/Carthage\/Checkouts\/Nimble\/", + "D0725CAC6FF2D66F2C83C2C48DC12106D42DAA64+++8BD7695" : "SwiftGit2\/Carthage\/Checkouts\/Quick\/", + "57C931977B7D2307CC013C2BD93F90CF7C676790+++139D2B1" : "SwiftGit2\/Carthage\/Checkouts\/Result\/Carthage\/Checkouts\/Box\/", + "956D2B21DD155C49504BB67697A67F7C5351A353+++5CC92F5" : "SwiftGit2\/Carthage\/Checkouts\/Result\/", + "E35CE1831829A79469F2167CADA9B1D9BA6B0BA6+++3D78C67" : "SwiftGit2\/Carthage\/Checkouts\/Guanaco\/", + "956D2B21DD155C49504BB67697A67F7C5351A353+++0FC0BCD" : "SwiftGit2\/Carthage\/Checkouts\/Guanaco\/External\/Result\/", + "95438028B10BBB846574013D29F154A00556A9D1+++5AB1F94" : "SwiftGit2\/Carthage\/Checkouts\/Nimble\/", + "956D2B21DD155C49504BB67697A67F7C5351A353+++3988B36" : "SwiftGit2\/Carthage\/Checkouts\/Result\/", + "0B2A3BCB00C86293DA74B6A9239BA502F6488D88+++937A20B" : "SwiftGit2\/", + "E084C86B03F81D63323C9E7510697EA528A758C7+++9C11E0D" : "SwiftGit2\/Carthage\/Checkouts\/xcconfigs\/", + "57C931977B7D2307CC013C2BD93F90CF7C676790+++27D14BF" : "SwiftGit2\/Carthage\/Checkouts\/Box\/", + "57C931977B7D2307CC013C2BD93F90CF7C676790+++8DA764B" : "SwiftGit2\/Carthage\/Checkouts\/Box\/", + "70783EE7218D87FCBAABD7787F6E3A25EFFAFB2F+++E1067AA" : "SwiftGit2\/External\/libgit2\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "SwiftGit2", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "SwiftGit2.xcworkspace", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:windmill-io\/SwiftGit2.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "0B2A3BCB00C86293DA74B6A9239BA502F6488D88+++937A20B" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/robrix\/Box.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "57C931977B7D2307CC013C2BD93F90CF7C676790+++139D2B1" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/robrix\/Box.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "57C931977B7D2307CC013C2BD93F90CF7C676790+++27D14BF" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/robrix\/Box.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "57C931977B7D2307CC013C2BD93F90CF7C676790+++8DA764B" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/libgit2\/libgit2.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "70783EE7218D87FCBAABD7787F6E3A25EFFAFB2F+++E1067AA" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Quick\/Nimble.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "95438028B10BBB846574013D29F154A00556A9D1+++5AB1F94" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Quick\/Nimble.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "95438028B10BBB846574013D29F154A00556A9D1+++D5553EB" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/antitypical\/Result", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "956D2B21DD155C49504BB67697A67F7C5351A353+++0FC0BCD" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/antitypical\/Result.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "956D2B21DD155C49504BB67697A67F7C5351A353+++3988B36" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/antitypical\/Result", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "956D2B21DD155C49504BB67697A67F7C5351A353+++5CC92F5" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Quick\/Quick.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "D0725CAC6FF2D66F2C83C2C48DC12106D42DAA64+++8BD7695" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/jspahrsummers\/xcconfigs.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "E084C86B03F81D63323C9E7510697EA528A758C7+++9C11E0D" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/modocache\/Guanaco.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "E35CE1831829A79469F2167CADA9B1D9BA6B0BA6+++3D78C67" + } + ] +} \ No newline at end of file diff --git a/SwiftGit2/CheckoutStrategy.swift b/SwiftGit2/CheckoutStrategy.swift index 470658d..9075c95 100644 --- a/SwiftGit2/CheckoutStrategy.swift +++ b/SwiftGit2/CheckoutStrategy.swift @@ -8,7 +8,7 @@ /// The flags defining how a checkout should be performed. /// More detail is available in the libgit2 documentation for `git_checkout_strategy_t`. -public struct CheckoutStrategy : RawOptionSetType { +public struct CheckoutStrategy : OptionSetType { private let value: UInt // MARK: - Initialization @@ -23,11 +23,11 @@ public struct CheckoutStrategy : RawOptionSetType { } public init(_ strategy: git_checkout_strategy_t) { - self.value = UInt(strategy.value) + self.value = UInt(strategy.rawValue) } public static var allZeros: CheckoutStrategy { - return self(rawValue: 0) + return self.init(rawValue: 0) } // MARK: - Properties diff --git a/SwiftGit2/Errors.swift b/SwiftGit2/Errors.swift index 1a0d16d..dff93bd 100644 --- a/SwiftGit2/Errors.swift +++ b/SwiftGit2/Errors.swift @@ -40,7 +40,7 @@ private func errorMessage(errorCode: Int32) -> String? { let last = giterr_last() if last != nil { return String.fromCString(last.memory.message) - } else if UInt32(errorCode) == GITERR_OS.value { + } else if UInt32(errorCode) == GITERR_OS.rawValue { return String.fromCString(strerror(errno)) } else { return nil diff --git a/SwiftGit2/Info.plist b/SwiftGit2/Info.plist index 19194bd..9f8153b 100644 --- a/SwiftGit2/Info.plist +++ b/SwiftGit2/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.libgit2.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/SwiftGit2/Libgit2.swift b/SwiftGit2/Libgit2.swift index 71f17c4..425f9fb 100644 --- a/SwiftGit2/Libgit2.swift +++ b/SwiftGit2/Libgit2.swift @@ -7,7 +7,7 @@ // func == (lhs: git_otype, rhs: git_otype) -> Bool { - return lhs.value == rhs.value + return lhs.rawValue == rhs.rawValue } extension git_strarray { @@ -16,7 +16,7 @@ extension git_strarray { } func map(f: (String) -> T) -> [T] { - return Swift.map(0...alloc(1) let result = git_oid_fromstr(pointer, string) - if result < GIT_OK.value { + if result < GIT_OK.rawValue { pointer.dealloc(1) return nil; } @@ -45,7 +45,7 @@ public struct OID { public let oid: git_oid } -extension OID: Printable { +extension OID: CustomStringConvertible { public var description: String { let length = Int(GIT_OID_RAWSZ) * 2 let string = UnsafeMutablePointer.alloc(length) @@ -68,7 +68,7 @@ extension OID: Hashable { self.oid.id.6, self.oid.id.7 ] - return reduce(bytes, 0, { (hash, byte) in + return bytes.reduce(0, combine:{ (hash, byte) in return Int(hash << 8) | Int(byte) }) } diff --git a/SwiftGit2/Objects.swift b/SwiftGit2/Objects.swift index caee9bc..bc3c1b4 100644 --- a/SwiftGit2/Objects.swift +++ b/SwiftGit2/Objects.swift @@ -88,7 +88,7 @@ public struct Commit: ObjectType { committer = Signature(git_commit_committer(pointer).memory) tree = PointerTo(OID(git_commit_tree_id(pointer).memory)) - self.parents = map(0..(lhs: P, rhs: P) -> Bool { - return lhs.oid == rhs.oid && lhs.type.value == rhs.type.value + return lhs.oid == rhs.oid && lhs.type.rawValue == rhs.type.rawValue } /// A pointer to a git object. @@ -45,27 +45,29 @@ public enum Pointer: PointerType { public var type: git_otype { switch self { - case let Commit(oid): + case Commit(oid): return GIT_OBJ_COMMIT - case let Tree(oid): + case Tree(oid): return GIT_OBJ_TREE - case let Blob(oid): + case Blob(oid): return GIT_OBJ_BLOB - case let Tag(oid): + case Tag(oid): return GIT_OBJ_TAG + default: + return GIT_OBJ_ANY } } /// Create an instance with an OID and a libgit2 `git_otype`. init?(oid: OID, type: git_otype) { - switch type.value { - case GIT_OBJ_COMMIT.value: + switch type { + case GIT_OBJ_COMMIT: self = Commit(oid) - case GIT_OBJ_TREE.value: + case GIT_OBJ_TREE: self = Tree(oid) - case GIT_OBJ_BLOB.value: + case GIT_OBJ_BLOB: self = Blob(oid) - case GIT_OBJ_TAG.value: + case GIT_OBJ_TAG: self = Tag(oid) default: return nil @@ -79,7 +81,7 @@ extension Pointer: Hashable { } } -extension Pointer: Printable { +extension Pointer: CustomStringConvertible { public var description: String { switch self { case Commit: diff --git a/SwiftGit2/References.swift b/SwiftGit2/References.swift index 38a241e..dc47f16 100644 --- a/SwiftGit2/References.swift +++ b/SwiftGit2/References.swift @@ -96,7 +96,7 @@ public struct Branch: ReferenceType { public init?(_ pointer: COpaquePointer) { let namePointer = UnsafeMutablePointer>.alloc(1) let success = git_branch_name(namePointer, pointer) - if success != GIT_OK.value { + if success != GIT_OK.rawValue { namePointer.dealloc(1) return nil } @@ -106,10 +106,10 @@ public struct Branch: ReferenceType { longName = String.fromCString(git_reference_name(pointer))! var oid: OID - if git_reference_type(pointer).value == GIT_REF_SYMBOLIC.value { + if git_reference_type(pointer).rawValue == GIT_REF_SYMBOLIC.rawValue { var resolved: COpaquePointer = nil let success = git_reference_resolve(&resolved, pointer) - if success != GIT_OK.value { + if success != GIT_OK.rawValue { return nil } oid = OID(git_reference_target(resolved).memory) @@ -184,7 +184,7 @@ public enum TagReference: ReferenceType { var pointer: COpaquePointer = nil let result = git_object_lookup(&pointer, repo, &oid, GIT_OBJ_TAG) - if result == GIT_OK.value { + if result == GIT_OK.rawValue { self = .Annotated(name, Tag(pointer)) } else { self = .Lightweight(name, OID(oid)) diff --git a/SwiftGit2/Repository.swift b/SwiftGit2/Repository.swift index 1663b3c..a8a4177 100644 --- a/SwiftGit2/Repository.swift +++ b/SwiftGit2/Repository.swift @@ -25,12 +25,12 @@ final public class Repository { var pointer: COpaquePointer = nil let result = git_repository_open(&pointer, URL.fileSystemRepresentation) - if result != GIT_OK.value { - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_open")) + if result != GIT_OK.rawValue { + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_open")) } let repository = Repository(pointer) - return Result.success(repository) + return Result.Success(repository) } // MARK: - Initializers @@ -74,8 +74,8 @@ final public class Repository { var oid = oid.oid let result = git_object_lookup(&pointer, self.pointer, &oid, type) - if result != GIT_OK.value { - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_object_lookup")) + if result != GIT_OK.rawValue { + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_object_lookup")) } let value = transform(pointer) @@ -84,7 +84,7 @@ final public class Repository { } func withLibgit2Object(oid: OID, type: git_otype, transform: COpaquePointer -> T) -> Result { - return withLibgit2Object(oid, type: type) { Result.success(transform($0)) } + return withLibgit2Object(oid, type: type) { Result.Success(transform($0)) } } /// Loads the object with the given OID. @@ -96,15 +96,15 @@ final public class Repository { return withLibgit2Object(oid, type: GIT_OBJ_ANY) { object in let type = git_object_type(object) if type == Blob.type { - return Result.success(Blob(object)) + return Result.Success(Blob(object)) } else if type == Commit.type { - return Result.success(Commit(object)) + return Result.Success(Commit(object)) } else if type == Tag.type { - return Result.success(Tag(object)) + return Result.Success(Tag(object)) } else if type == Tree.type { - return Result.success(Tree(object)) + return Result.Success(Tree(object)) } - + let error = NSError( domain: "org.libgit2.SwiftGit2", code: 1, @@ -112,7 +112,7 @@ final public class Repository { NSLocalizedDescriptionKey: "Unrecognized git_otype '\(type)' for oid '\(oid)'." ] ) - return Result.failure(error) + return Result.Failure(error) } } @@ -124,7 +124,7 @@ final public class Repository { public func blobWithOID(oid: OID) -> Result { return self.withLibgit2Object(oid, type: GIT_OBJ_BLOB) { Blob($0) } } - + /// Loads the commit with the given OID. /// /// oid - The OID of the commit to look up. @@ -188,9 +188,9 @@ final public class Repository { let pointer = UnsafeMutablePointer.alloc(1) let result = git_remote_list(pointer, self.pointer) - if result != GIT_OK.value { + if result != GIT_OK.rawValue { pointer.dealloc(1) - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_remote_list")) + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_remote_list")) } let strarray = pointer.memory @@ -202,9 +202,9 @@ final public class Repository { let error = remotes.reduce(nil) { $0 == nil ? $0 : $1.error } if let error = error { - return Result.failure(error) + return Result.Failure(error) } - return Result.success(remotes.map { $0.value! }) + return Result.Success(remotes.map { $0.value! }) } /// Load a remote from the repository. @@ -216,13 +216,13 @@ final public class Repository { var pointer: COpaquePointer = nil let result = git_remote_lookup(&pointer, self.pointer, name) - if result != GIT_OK.value { - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_remote_lookup")) + if result != GIT_OK.rawValue { + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_remote_lookup")) } let value = Remote(pointer) git_remote_free(pointer) - return Result.success(value) + return Result.Success(value) } // MARK: - Reference Lookups @@ -232,9 +232,9 @@ final public class Repository { let pointer = UnsafeMutablePointer.alloc(1) let result = git_reference_list(pointer, self.pointer) - if result != GIT_OK.value { + if result != GIT_OK.rawValue { pointer.dealloc(1) - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_reference_list")) + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_reference_list")) } let strarray = pointer.memory @@ -244,15 +244,15 @@ final public class Repository { } .map { self.referenceWithName($0) - } + } git_strarray_free(pointer) pointer.dealloc(1) let error = references.reduce(nil) { $0 == nil ? $0 : $1.error } if let error = error { - return Result.failure(error) + return Result.Failure(error) } - return Result.success(references.map { $0.value! }) + return Result.Success(references.map { $0.value! }) } /// Load the reference with the given long name (e.g. "refs/heads/master") @@ -264,13 +264,13 @@ final public class Repository { var pointer: COpaquePointer = nil let result = git_reference_lookup(&pointer, self.pointer, name) - if result != GIT_OK.value { - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_reference_lookup")) + if result != GIT_OK.rawValue { + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_reference_lookup")) } let value = referenceWithLibGit2Reference(pointer) git_reference_free(pointer) - return Result.success(value) + return Result.Success(value) } /// Load and return a list of all local branches. @@ -278,7 +278,7 @@ final public class Repository { return referencesWithPrefix("refs/heads/") .map { (refs: [ReferenceType]) in return refs.map { $0 as! Branch } - } + } } /// Load and return a list of all remote branches. @@ -286,7 +286,7 @@ final public class Repository { return referencesWithPrefix("refs/remotes/") .map { (refs: [ReferenceType]) in return refs.map { $0 as! Branch } - } + } } /// Load the local branch with the given name (e.g., "master"). @@ -304,7 +304,7 @@ final public class Repository { return referencesWithPrefix("refs/tags/") .map { (refs: [ReferenceType]) in return refs.map { $0 as! TagReference } - } + } } /// Load the tag with the given name (e.g., "tag-2"). @@ -320,12 +320,12 @@ final public class Repository { public func HEAD() -> Result { var pointer: COpaquePointer = nil let result = git_repository_head(&pointer, self.pointer) - if result != GIT_OK.value { - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_head")) + if result != GIT_OK.rawValue { + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_head")) } let value = referenceWithLibGit2Reference(pointer) git_reference_free(pointer) - return Result.success(value) + return Result.Success(value) } /// Set HEAD to the given oid (detached). @@ -335,10 +335,10 @@ final public class Repository { public func setHEAD(oid: OID) -> Result<(), NSError> { var oid = oid.oid let result = git_repository_set_head_detached(self.pointer, &oid); - if result != GIT_OK.value { - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_set_head")) + if result != GIT_OK.rawValue { + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_set_head")) } - return Result.success() + return Result.Success() } /// Set HEAD to the given reference. @@ -347,10 +347,10 @@ final public class Repository { /// :returns: Returns a result with void or the error that occurred. public func setHEAD(reference: ReferenceType) -> Result<(), NSError> { let result = git_repository_set_head(self.pointer, reference.longName); - if result != GIT_OK.value { - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_set_head")) + if result != GIT_OK.rawValue { + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_set_head")) } - return Result.success() + return Result.Success() } /// Check out HEAD. @@ -358,16 +358,16 @@ final public class Repository { /// :param: strategy The checkout strategy to use. /// :param: progress A block that's called with the progress of the checkout. /// :returns: Returns a result with void or the error that occurred. - public func checkout(#strategy: CheckoutStrategy, progress: CheckoutProgressBlock? = nil) -> Result<(), NSError> { + public func checkout(strategy strategy: CheckoutStrategy, progress: CheckoutProgressBlock? = nil) -> Result<(), NSError> { var options = SG2CheckoutOptions(progress) - options.checkout_strategy = strategy.git_checkout_strategy.value + options.checkout_strategy = strategy.git_checkout_strategy.rawValue let result = git_checkout_head(self.pointer, &options) - if result != GIT_OK.value { - return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_checkout_head")) + if result != GIT_OK.rawValue { + return Result.Failure(libGit2Error(result, libGit2PointOfFailure: "git_checkout_head")) } - return Result.success() + return Result.Success() } /// Check out the given OID. diff --git a/SwiftGit2Tests/Fixtures/Fixtures.swift b/SwiftGit2Tests/Fixtures/Fixtures.swift index 574efc6..f7632b9 100644 --- a/SwiftGit2Tests/Fixtures/Fixtures.swift +++ b/SwiftGit2Tests/Fixtures/Fixtures.swift @@ -21,10 +21,9 @@ final class Fixtures { } init() { - let path = NSTemporaryDirectory() - .stringByAppendingPathComponent("org.libgit2.SwiftGit2") - .stringByAppendingPathComponent(NSProcessInfo.processInfo().globallyUniqueString) - directoryURL = NSURL.fileURLWithPath(path, isDirectory: true)! + directoryURL = NSURL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true) + .URLByAppendingPathComponent("org.libgit2.SwiftGit2") + .URLByAppendingPathComponent(NSProcessInfo.processInfo().globallyUniqueString) } // MARK: - Setup and Teardown @@ -32,10 +31,10 @@ final class Fixtures { let directoryURL: NSURL func setUp() { - NSFileManager.defaultManager().createDirectoryAtURL(directoryURL, withIntermediateDirectories: true, attributes: nil, error: nil) + try! NSFileManager.defaultManager().createDirectoryAtURL(directoryURL, withIntermediateDirectories: true, attributes: nil) let bundle = NSBundle(identifier: "org.libgit2.SwiftGit2-OSXTests")! - let zipURLs = bundle.URLsForResourcesWithExtension("zip", subdirectory: nil)! as! [NSURL] + let zipURLs = bundle.URLsForResourcesWithExtension("zip", subdirectory: nil)! as [NSURL] for URL in zipURLs { unzipFileAtURL(URL, intoDirectoryAtURL: directoryURL) @@ -43,7 +42,7 @@ final class Fixtures { } func tearDown() { - NSFileManager.defaultManager().removeItemAtURL(directoryURL, error: nil) + try! NSFileManager.defaultManager().removeItemAtURL(directoryURL) } func unzipFileAtURL(fileURL: NSURL, intoDirectoryAtURL directoryURL: NSURL) { diff --git a/SwiftGit2Tests/Info.plist b/SwiftGit2Tests/Info.plist index a058904..ba72822 100644 --- a/SwiftGit2Tests/Info.plist +++ b/SwiftGit2Tests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.libgit2.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/SwiftGit2Tests/ObjectsSpec.swift b/SwiftGit2Tests/ObjectsSpec.swift index bcd4e53..a06edae 100644 --- a/SwiftGit2Tests/ObjectsSpec.swift +++ b/SwiftGit2Tests/ObjectsSpec.swift @@ -30,7 +30,7 @@ class SignatureSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! - let raw_signature = from_git_object(repo, oid) { git_commit_author($0).memory } + let raw_signature = from_git_object(repo, oid: oid) { git_commit_author($0).memory } let signature = Signature(raw_signature) expect(signature.name).to(equal("Matt Diephouse")) @@ -45,7 +45,7 @@ class SignatureSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! - let author1 = from_git_object(repo, oid) { commit in + let author1 = from_git_object(repo, oid: oid) { commit in Signature(git_commit_author(commit).memory) } let author2 = author1 @@ -58,10 +58,10 @@ class SignatureSpec: QuickSpec { let oid1 = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! let oid2 = OID(string: "24e1e40ee77525d9e279f079f9906ad6d98c8940")! - let author1 = from_git_object(repo, oid1) { commit in + let author1 = from_git_object(repo, oid: oid1) { commit in Signature(git_commit_author(commit).memory) } - let author2 = from_git_object(repo, oid2) { commit in + let author2 = from_git_object(repo, oid: oid2) { commit in Signature(git_commit_author(commit).memory) } @@ -74,7 +74,7 @@ class SignatureSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! - let author1 = from_git_object(repo, oid) { commit in + let author1 = from_git_object(repo, oid: oid) { commit in Signature(git_commit_author(commit).memory) } let author2 = author1 @@ -92,11 +92,11 @@ class CommitSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "24e1e40ee77525d9e279f079f9906ad6d98c8940")! - let commit = from_git_object(repo, oid) { Commit($0) } - let author = from_git_object(repo, oid) { commit in + let commit = from_git_object(repo, oid: oid) { Commit($0) } + let author = from_git_object(repo, oid: oid) { commit in Signature(git_commit_author(commit).memory) } - let committer = from_git_object(repo, oid) { commit in + let committer = from_git_object(repo, oid: oid) { commit in Signature(git_commit_committer(commit).memory) } let tree = PointerTo(OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!) @@ -115,7 +115,7 @@ class CommitSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! - let commit = from_git_object(repo, oid) { Commit($0) } + let commit = from_git_object(repo, oid: oid) { Commit($0) } expect(commit.parents).to(equal([])) } @@ -123,7 +123,7 @@ class CommitSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "c4ed03a6b7d7ce837d31d83757febbe84dd465fd")! - let commit = from_git_object(repo, oid) { Commit($0) } + let commit = from_git_object(repo, oid: oid) { Commit($0) } let parents: [PointerTo] = [ PointerTo(OID(string: "315b3f344221db91ddc54b269f3c9af422da0f2e")!), PointerTo(OID(string: "57f6197561d1f99b03c160f4026a07f06b43cf20")!), @@ -137,7 +137,7 @@ class CommitSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! - let commit1 = from_git_object(repo, oid) { Commit($0) } + let commit1 = from_git_object(repo, oid: oid) { Commit($0) } let commit2 = commit1 expect(commit1).to(equal(commit2)) } @@ -147,8 +147,8 @@ class CommitSpec: QuickSpec { let oid1 = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! let oid2 = OID(string: "c4ed03a6b7d7ce837d31d83757febbe84dd465fd")! - let commit1 = from_git_object(repo, oid1) { Commit($0) } - let commit2 = from_git_object(repo, oid2) { Commit($0) } + let commit1 = from_git_object(repo, oid: oid1) { Commit($0) } + let commit2 = from_git_object(repo, oid: oid2) { Commit($0) } expect(commit1).notTo(equal(commit2)) } } @@ -158,7 +158,7 @@ class CommitSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! - let commit1 = from_git_object(repo, oid) { Commit($0) } + let commit1 = from_git_object(repo, oid: oid) { Commit($0) } let commit2 = commit1 expect(commit1.hashValue).to(equal(commit2.hashValue)) } @@ -170,7 +170,7 @@ class TreeEntrySpec: QuickSpec { override func spec() { describe("Tree.Entry(attributes:object:name:)") { it("should set its properties") { - let attributes = Int32(GIT_FILEMODE_BLOB.value) + let attributes = Int32(GIT_FILEMODE_BLOB.rawValue) let object = Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!) let name = "README.md" @@ -186,8 +186,8 @@ class TreeEntrySpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")! - let entry = from_git_object(repo, oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) } - expect(entry.attributes).to(equal(Int32(GIT_FILEMODE_BLOB.value))) + let entry = from_git_object(repo, oid: oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) } + expect(entry.attributes).to(equal(Int32(GIT_FILEMODE_BLOB.rawValue))) expect(entry.object).to(equal(Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!))) expect(entry.name).to(equal("README.md")) } @@ -198,7 +198,7 @@ class TreeEntrySpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")! - let entry1 = from_git_object(repo, oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) } + let entry1 = from_git_object(repo, oid: oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) } let entry2 = entry1 expect(entry1).to(equal(entry2)) } @@ -208,8 +208,8 @@ class TreeEntrySpec: QuickSpec { let oid1 = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")! let oid2 = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")! - let entry1 = from_git_object(repo, oid1) { Tree.Entry(git_tree_entry_byindex($0, 0)) } - let entry2 = from_git_object(repo, oid2) { Tree.Entry(git_tree_entry_byindex($0, 0)) } + let entry1 = from_git_object(repo, oid: oid1) { Tree.Entry(git_tree_entry_byindex($0, 0)) } + let entry2 = from_git_object(repo, oid: oid2) { Tree.Entry(git_tree_entry_byindex($0, 0)) } expect(entry1).notTo(equal(entry2)) } } @@ -219,7 +219,7 @@ class TreeEntrySpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")! - let entry1 = from_git_object(repo, oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) } + let entry1 = from_git_object(repo, oid: oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) } let entry2 = entry1 expect(entry1.hashValue).to(equal(entry2.hashValue)) } @@ -234,9 +234,9 @@ class TreeSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")! - let tree = from_git_object(repo, oid) { Tree($0) } + let tree = from_git_object(repo, oid: oid) { Tree($0) } let entries = [ - "README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.value), object: .Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!), name: "README.md"), + "README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.rawValue), object: .Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!), name: "README.md"), ] expect(tree.entries).to(equal(entries)) } @@ -247,7 +247,7 @@ class TreeSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")! - let tree1 = from_git_object(repo, oid) { Tree($0) } + let tree1 = from_git_object(repo, oid: oid) { Tree($0) } let tree2 = tree1 expect(tree1).to(equal(tree2)) } @@ -257,8 +257,8 @@ class TreeSpec: QuickSpec { let oid1 = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")! let oid2 = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")! - let tree1 = from_git_object(repo, oid1) { Tree($0) } - let tree2 = from_git_object(repo, oid2) { Tree($0) } + let tree1 = from_git_object(repo, oid: oid1) { Tree($0) } + let tree2 = from_git_object(repo, oid: oid2) { Tree($0) } expect(tree1).notTo(equal(tree2)) } } @@ -268,7 +268,7 @@ class TreeSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")! - let tree1 = from_git_object(repo, oid) { Tree($0) } + let tree1 = from_git_object(repo, oid: oid) { Tree($0) } let tree2 = tree1 expect(tree1.hashValue).to(equal(tree2.hashValue)) } @@ -283,7 +283,7 @@ class BlobSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")! - let blob = from_git_object(repo, oid) { Blob($0) } + let blob = from_git_object(repo, oid: oid) { Blob($0) } let contents = "# Simple Repository\nA simple repository used for testing SwiftGit2.\n\n## Branches\n\n- master\n\n" let data = (contents as NSString).dataUsingEncoding(NSUTF8StringEncoding)! expect(blob.oid).to(equal(oid)) @@ -296,7 +296,7 @@ class BlobSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")! - let blob1 = from_git_object(repo, oid) { Blob($0) } + let blob1 = from_git_object(repo, oid: oid) { Blob($0) } let blob2 = blob1 expect(blob1).to(equal(blob2)) } @@ -306,8 +306,8 @@ class BlobSpec: QuickSpec { let oid1 = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")! let oid2 = OID(string: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391")! - let blob1 = from_git_object(repo, oid1) { Blob($0) } - let blob2 = from_git_object(repo, oid2) { Blob($0) } + let blob1 = from_git_object(repo, oid: oid1) { Blob($0) } + let blob2 = from_git_object(repo, oid: oid2) { Blob($0) } expect(blob1).notTo(equal(blob2)) } } @@ -317,7 +317,7 @@ class BlobSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")! - let blob1 = from_git_object(repo, oid) { Blob($0) } + let blob1 = from_git_object(repo, oid: oid) { Blob($0) } let blob2 = blob1 expect(blob1.hashValue).to(equal(blob2.hashValue)) } @@ -332,8 +332,8 @@ class TagSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")! - let tag = from_git_object(repo, oid) { Tag($0) } - let tagger = from_git_object(repo, oid) { Signature(git_tag_tagger($0).memory) } + let tag = from_git_object(repo, oid: oid) { Tag($0) } + let tagger = from_git_object(repo, oid: oid) { Signature(git_tag_tagger($0).memory) } expect(tag.oid).to(equal(oid)) expect(tag.target).to(equal(Pointer.Commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!))) @@ -348,7 +348,7 @@ class TagSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")! - let tag1 = from_git_object(repo, oid) { Tag($0) } + let tag1 = from_git_object(repo, oid: oid) { Tag($0) } let tag2 = tag1 expect(tag1).to(equal(tag2)) } @@ -358,8 +358,8 @@ class TagSpec: QuickSpec { let oid1 = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")! let oid2 = OID(string: "13bda91157f255ab224ff88d0a11a82041c9d0c1")! - let tag1 = from_git_object(repo, oid1) { Tag($0) } - let tag2 = from_git_object(repo, oid2) { Tag($0) } + let tag1 = from_git_object(repo, oid: oid1) { Tag($0) } + let tag2 = from_git_object(repo, oid: oid2) { Tag($0) } expect(tag1).notTo(equal(tag2)) } } @@ -369,7 +369,7 @@ class TagSpec: QuickSpec { let repo = Fixtures.simpleRepository let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")! - let tag1 = from_git_object(repo, oid) { Tag($0) } + let tag1 = from_git_object(repo, oid: oid) { Tag($0) } let tag2 = tag1 expect(tag1.hashValue).to(equal(tag2.hashValue)) } diff --git a/SwiftGit2Tests/ReferencesSpec.swift b/SwiftGit2Tests/ReferencesSpec.swift index 84da487..c2ead4d 100644 --- a/SwiftGit2Tests/ReferencesSpec.swift +++ b/SwiftGit2Tests/ReferencesSpec.swift @@ -27,7 +27,7 @@ class ReferenceSpec: QuickSpec { describe("Reference(pointer)") { it("should initialize its properties") { let repo = Fixtures.simpleRepository - let ref = from_git_reference(repo, "refs/heads/master") { Reference($0) } + let ref = from_git_reference(repo, name: "refs/heads/master") { Reference($0) } expect(ref.longName).to(equal("refs/heads/master")) expect(ref.shortName).to(equal("master")) expect(ref.oid).to(equal(OID(string: "c4ed03a6b7d7ce837d31d83757febbe84dd465fd")!)) @@ -37,15 +37,15 @@ class ReferenceSpec: QuickSpec { describe("==(Reference, Reference)") { it("should be true with equal references") { let repo = Fixtures.simpleRepository - let ref1 = from_git_reference(repo, "refs/heads/master") { Reference($0) } - let ref2 = from_git_reference(repo, "refs/heads/master") { Reference($0) } + let ref1 = from_git_reference(repo, name: "refs/heads/master") { Reference($0) } + let ref2 = from_git_reference(repo, name: "refs/heads/master") { Reference($0) } expect(ref1).to(equal(ref2)) } it("should be false with unequal references") { let repo = Fixtures.simpleRepository - let ref1 = from_git_reference(repo, "refs/heads/master") { Reference($0) } - let ref2 = from_git_reference(repo, "refs/heads/another-branch") { Reference($0) } + let ref1 = from_git_reference(repo, name: "refs/heads/master") { Reference($0) } + let ref2 = from_git_reference(repo, name: "refs/heads/another-branch") { Reference($0) } expect(ref1).notTo(equal(ref2)) } } @@ -53,8 +53,8 @@ class ReferenceSpec: QuickSpec { describe("Reference.hashValue") { it("should be equal with equal references") { let repo = Fixtures.simpleRepository - let ref1 = from_git_reference(repo, "refs/heads/master") { Reference($0) } - let ref2 = from_git_reference(repo, "refs/heads/master") { Reference($0) } + let ref1 = from_git_reference(repo, name: "refs/heads/master") { Reference($0) } + let ref2 = from_git_reference(repo, name: "refs/heads/master") { Reference($0) } expect(ref1.hashValue).to(equal(ref2.hashValue)) } } @@ -66,7 +66,7 @@ class BranchSpec: QuickSpec { describe("Branch(pointer)") { it("should initialize its properties") { let repo = Fixtures.mantleRepository - let branch = from_git_reference(repo, "refs/heads/master") { Branch($0)! } + let branch = from_git_reference(repo, name: "refs/heads/master") { Branch($0)! } expect(branch.longName).to(equal("refs/heads/master")) expect(branch.name).to(equal("master")) expect(branch.shortName).to(equal(branch.name)) @@ -78,7 +78,7 @@ class BranchSpec: QuickSpec { it("should work with symoblic refs") { let repo = Fixtures.mantleRepository - let branch = from_git_reference(repo, "refs/remotes/origin/HEAD") { Branch($0)! } + let branch = from_git_reference(repo, name: "refs/remotes/origin/HEAD") { Branch($0)! } expect(branch.longName).to(equal("refs/remotes/origin/HEAD")) expect(branch.name).to(equal("origin/HEAD")) expect(branch.shortName).to(equal(branch.name)) @@ -92,15 +92,15 @@ class BranchSpec: QuickSpec { describe("==(Branch, Branch)") { it("should be true with equal branches") { let repo = Fixtures.simpleRepository - let branch1 = from_git_reference(repo, "refs/heads/master") { Branch($0)! } - let branch2 = from_git_reference(repo, "refs/heads/master") { Branch($0)! } + let branch1 = from_git_reference(repo, name: "refs/heads/master") { Branch($0)! } + let branch2 = from_git_reference(repo, name: "refs/heads/master") { Branch($0)! } expect(branch1).to(equal(branch2)) } it("should be false with unequal branches") { let repo = Fixtures.simpleRepository - let branch1 = from_git_reference(repo, "refs/heads/master") { Branch($0)! } - let branch2 = from_git_reference(repo, "refs/heads/another-branch") { Branch($0)! } + let branch1 = from_git_reference(repo, name: "refs/heads/master") { Branch($0)! } + let branch2 = from_git_reference(repo, name: "refs/heads/another-branch") { Branch($0)! } expect(branch1).notTo(equal(branch2)) } } @@ -108,8 +108,8 @@ class BranchSpec: QuickSpec { describe("Branch.hashValue") { it("should be equal with equal references") { let repo = Fixtures.simpleRepository - let branch1 = from_git_reference(repo, "refs/heads/master") { Branch($0)! } - let branch2 = from_git_reference(repo, "refs/heads/master") { Branch($0)! } + let branch1 = from_git_reference(repo, name: "refs/heads/master") { Branch($0)! } + let branch2 = from_git_reference(repo, name: "refs/heads/master") { Branch($0)! } expect(branch1.hashValue).to(equal(branch2.hashValue)) } } @@ -121,7 +121,7 @@ class TagReferenceSpec: QuickSpec { describe("TagReference(pointer)") { it("should work with an annotated tag") { let repo = Fixtures.simpleRepository - let tag = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! } + let tag = from_git_reference(repo, name: "refs/tags/tag-2") { TagReference($0)! } expect(tag.longName).to(equal("refs/tags/tag-2")) expect(tag.name).to(equal("tag-2")) expect(tag.shortName).to(equal(tag.name)) @@ -130,7 +130,7 @@ class TagReferenceSpec: QuickSpec { it("should work with a lightweight tag") { let repo = Fixtures.mantleRepository - let tag = from_git_reference(repo, "refs/tags/1.5.4") { TagReference($0)! } + let tag = from_git_reference(repo, name: "refs/tags/1.5.4") { TagReference($0)! } expect(tag.longName).to(equal("refs/tags/1.5.4")) expect(tag.name).to(equal("1.5.4")) expect(tag.shortName).to(equal(tag.name)) @@ -139,7 +139,7 @@ class TagReferenceSpec: QuickSpec { it("should return nil if not a tag") { let repo = Fixtures.simpleRepository - let tag = from_git_reference(repo, "refs/heads/master") { TagReference($0) } + let tag = from_git_reference(repo, name: "refs/heads/master") { TagReference($0) } expect(tag).to(beNil()) } } @@ -147,24 +147,24 @@ class TagReferenceSpec: QuickSpec { describe("==(TagReference, TagReference)") { it("should be true with equal tag references") { let repo = Fixtures.simpleRepository - let tag1 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! } - let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! } + let tag1 = from_git_reference(repo, name: "refs/tags/tag-2") { TagReference($0)! } + let tag2 = from_git_reference(repo, name: "refs/tags/tag-2") { TagReference($0)! } expect(tag1).to(equal(tag2)) } it("should be false with unequal tag references") { let repo = Fixtures.simpleRepository - let tag1 = from_git_reference(repo, "refs/tags/tag-1") { TagReference($0)! } - let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! } + let tag1 = from_git_reference(repo, name: "refs/tags/tag-1") { TagReference($0)! } + let tag2 = from_git_reference(repo, name: "refs/tags/tag-2") { TagReference($0)! } expect(tag1).notTo(equal(tag2)) } } - + describe("TagReference.hashValue") { it("should be equal with equal references") { let repo = Fixtures.simpleRepository - let tag1 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! } - let tag2 = from_git_reference(repo, "refs/tags/tag-2") { TagReference($0)! } + let tag1 = from_git_reference(repo, name: "refs/tags/tag-2") { TagReference($0)! } + let tag2 = from_git_reference(repo, name: "refs/tags/tag-2") { TagReference($0)! } expect(tag1.hashValue).to(equal(tag2.hashValue)) } } diff --git a/SwiftGit2Tests/RemotesSpec.swift b/SwiftGit2Tests/RemotesSpec.swift index 7d5a347..ca04f6e 100644 --- a/SwiftGit2Tests/RemotesSpec.swift +++ b/SwiftGit2Tests/RemotesSpec.swift @@ -27,7 +27,7 @@ class RemoteSpec: QuickSpec { describe("Remote(pointer)") { it("should initialize its properties") { let repo = Fixtures.mantleRepository - let remote = with_git_remote(repo, "upstream") { Remote($0) } + let remote = with_git_remote(repo, name: "upstream") { Remote($0) } expect(remote.name).to(equal("upstream")) expect(remote.URL).to(equal("git@github.com:Mantle/Mantle.git")) @@ -37,15 +37,15 @@ class RemoteSpec: QuickSpec { describe("==(Remote, Remote)") { it("should be true with equal objects") { let repo = Fixtures.mantleRepository - let remote1 = with_git_remote(repo, "upstream") { Remote($0) } + let remote1 = with_git_remote(repo, name: "upstream") { Remote($0) } let remote2 = remote1 expect(remote1).to(equal(remote2)) } it("should be false with unequal objcets") { let repo = Fixtures.mantleRepository - let origin = with_git_remote(repo, "origin") { Remote($0) } - let upstream = with_git_remote(repo, "upstream") { Remote($0) } + let origin = with_git_remote(repo, name: "origin") { Remote($0) } + let upstream = with_git_remote(repo, name: "upstream") { Remote($0) } expect(origin).notTo(equal(upstream)) } } @@ -53,7 +53,7 @@ class RemoteSpec: QuickSpec { describe("Remote.hashValue") { it("should be equal with equal objcets") { let repo = Fixtures.mantleRepository - let remote1 = with_git_remote(repo, "upstream") { Remote($0) } + let remote1 = with_git_remote(repo, name: "upstream") { Remote($0) } let remote2 = remote1 expect(remote1.hashValue).to(equal(remote2.hashValue)) } diff --git a/SwiftGit2Tests/RepositorySpec.swift b/SwiftGit2Tests/RepositorySpec.swift index cc1248b..c499824 100644 --- a/SwiftGit2Tests/RepositorySpec.swift +++ b/SwiftGit2Tests/RepositorySpec.swift @@ -21,7 +21,7 @@ class RepositorySpec: QuickSpec { } it("should fail if the repo doesn't exist") { - let url = NSURL(fileURLWithPath: "blah")! + let url = NSURL(fileURLWithPath: "blah") let result = Repository.atURL(url) expect(result).to(haveFailed(beAnError( domain: equal(libGit2ErrorDomain), @@ -358,8 +358,8 @@ class RepositorySpec: QuickSpec { "upstream/subclassing-notes", ] let expected = expectedNames.map { repo.remoteBranchWithName($0).value! } - let actual = repo.remoteBranches().value!.sorted { - return lexicographicalCompare($0.longName, $1.longName) + let actual = repo.remoteBranches().value!.sort { + return $0.longName.characters.lexicographicalCompare($1.longName.characters) } expect(actual).to(equal(expected)) expect(actual.map { $0.name }).to(equal(expectedNames))