From ba9a951b6250e8f0cb3d7c45277931abd10ce58a Mon Sep 17 00:00:00 2001 From: Brian Gesiak Date: Sat, 21 Feb 2015 21:13:36 -0500 Subject: [PATCH] Support Swift 1.2 - Update Guanaco, LlamaKit, Nimble, and Quick to versions that support Swift 1.2. - Update Xcode project and scheme files for "latest Xcode version" parameters. - Use Swift 1.2's new fallible casts for casts that may fail at runtime. --- .gitmodules | 6 ++--- External/Guanaco | 2 +- External/LlamaKit | 2 +- External/Nimble | 2 +- External/Quick | 2 +- SwiftGit2.xcodeproj/project.pbxproj | 8 +++---- .../xcschemes/SwiftGit2-OSX.xcscheme | 2 +- SwiftGit2/Objects.swift | 2 +- SwiftGit2/Repository.swift | 14 +++++------ SwiftGit2/SwiftGit2.modulemap | 4 ++-- SwiftGit2Tests/Fixtures/Fixtures.swift | 2 +- SwiftGit2Tests/RepositorySpec.swift | 24 +++++++++---------- 12 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.gitmodules b/.gitmodules index d82fac8..7492ac7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "External/Configuration"] path = External/Configuration url = https://github.com/jspahrsummers/xcconfigs.git -[submodule "External/Quick"] - path = External/Quick - url = https://github.com/github/Quick.git [submodule "External/libgit2"] path = External/libgit2 url = https://github.com/libgit2/libgit2.git @@ -16,3 +13,6 @@ [submodule "External/Nimble"] path = External/Nimble url = https://github.com/Quick/Nimble.git +[submodule "External/Quick"] + path = External/Quick + url = https://github.com/Quick/Quick.git diff --git a/External/Guanaco b/External/Guanaco index 7961d98..18126c0 160000 --- a/External/Guanaco +++ b/External/Guanaco @@ -1 +1 @@ -Subproject commit 7961d9851d72e2c8c8e2c620054041c6217806e7 +Subproject commit 18126c0c8ba9a7cb3cc5d43aec83c81047410ab6 diff --git a/External/LlamaKit b/External/LlamaKit index e37b966..e28d7f6 160000 --- a/External/LlamaKit +++ b/External/LlamaKit @@ -1 +1 @@ -Subproject commit e37b966998df6ca05445c0b5d9c6c9560f1e7b61 +Subproject commit e28d7f6e82fbd5dcd5388b36e2acf4eedb44b4e8 diff --git a/External/Nimble b/External/Nimble index 9538a30..6c1fa51 160000 --- a/External/Nimble +++ b/External/Nimble @@ -1 +1 @@ -Subproject commit 9538a301d5320fd607f01c931dc282868b0e827a +Subproject commit 6c1fa5137c585e6e78c4e63302850828e39365d0 diff --git a/External/Quick b/External/Quick index 3d22cf4..2103cf3 160000 --- a/External/Quick +++ b/External/Quick @@ -1 +1 @@ -Subproject commit 3d22cf4d05f4fe965b8a607ea2c7efcb70d5d3d6 +Subproject commit 2103cf332b2bb8b85b0b25a85cc81514d03612a5 diff --git a/SwiftGit2.xcodeproj/project.pbxproj b/SwiftGit2.xcodeproj/project.pbxproj index 807ed5d..c5f52d1 100644 --- a/SwiftGit2.xcodeproj/project.pbxproj +++ b/SwiftGit2.xcodeproj/project.pbxproj @@ -26,7 +26,6 @@ BEB31F2F1A0D6F7A00F525B9 /* SwiftGit2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEB31F231A0D6F7A00F525B9 /* SwiftGit2.framework */; }; BEB31F361A0D6F7A00F525B9 /* RepositorySpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB31F351A0D6F7A00F525B9 /* RepositorySpec.swift */; }; BEB31F6D1A0D78F300F525B9 /* Repository.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEB31F6C1A0D78F300F525B9 /* Repository.swift */; }; - BEB31F7F1A0D79C800F525B9 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEB31F7E1A0D79C800F525B9 /* Quick.framework */; }; BEB31F9E1A0E595100F525B9 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BEB31F9D1A0E595100F525B9 /* libiconv.dylib */; }; BEB31FA01A0E595600F525B9 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BEB31F9F1A0E595600F525B9 /* libz.dylib */; }; BECB5F6A1A56F19900999413 /* References.swift in Sources */ = {isa = PBXBuildFile; fileRef = BECB5F691A56F19900999413 /* References.swift */; }; @@ -36,6 +35,7 @@ DA5023A01A969F1A004175D7 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA50239F1A969F1A004175D7 /* Nimble.framework */; }; DA59146D1A94549A00AED74C /* Guanaco.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA59146C1A94549A00AED74C /* Guanaco.framework */; }; DA5914761A94579000AED74C /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA5914751A94579000AED74C /* Errors.swift */; }; + DAC8143D1A99749D0063D88C /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAC8143C1A99749D0063D88C /* Quick.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -109,7 +109,6 @@ BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-StaticLibrary.xcconfig"; sourceTree = ""; }; BEB31F581A0D75EE00F525B9 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; BEB31F6C1A0D78F300F525B9 /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = ""; }; - BEB31F7E1A0D79C800F525B9 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = "../../../Library/Developer/Xcode/DerivedData/SwiftGit2-hhirbsygtzljdvasajovfqnfzwwb/Build/Products/Debug/Quick.framework"; sourceTree = ""; }; BEB31F8F1A0E563900F525B9 /* liblibgit2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = liblibgit2.a; sourceTree = BUILT_PRODUCTS_DIR; }; BEB31F9B1A0E581400F525B9 /* git2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = git2.h; path = External/libgit2/include/git2.h; sourceTree = ""; }; BEB31F9D1A0E595100F525B9 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; }; @@ -121,6 +120,7 @@ DA50239F1A969F1A004175D7 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = ../External/Nimble/build/Debug/Nimble.framework; sourceTree = ""; }; DA59146C1A94549A00AED74C /* Guanaco.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Guanaco.framework; path = ../External/Guanaco/build/Debug/Guanaco.framework; sourceTree = ""; }; DA5914751A94579000AED74C /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = ""; }; + DAC8143C1A99749D0063D88C /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = "../../../../Library/Developer/Xcode/DerivedData/SwiftGit2-ezqqkevntxbroughwcioyxqriijk/Build/Products/Debug/Quick.framework"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -140,7 +140,7 @@ files = ( DA59146D1A94549A00AED74C /* Guanaco.framework in Frameworks */, DA5023A01A969F1A004175D7 /* Nimble.framework in Frameworks */, - BEB31F7F1A0D79C800F525B9 /* Quick.framework in Frameworks */, + DAC8143D1A99749D0063D88C /* Quick.framework in Frameworks */, BEB31F2F1A0D6F7A00F525B9 /* SwiftGit2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -227,7 +227,7 @@ isa = PBXGroup; children = ( DA50239F1A969F1A004175D7 /* Nimble.framework */, - BEB31F7E1A0D79C800F525B9 /* Quick.framework */, + DAC8143C1A99749D0063D88C /* Quick.framework */, DA59146C1A94549A00AED74C /* Guanaco.framework */, BEB31F341A0D6F7A00F525B9 /* Info.plist */, ); diff --git a/SwiftGit2.xcodeproj/xcshareddata/xcschemes/SwiftGit2-OSX.xcscheme b/SwiftGit2.xcodeproj/xcshareddata/xcschemes/SwiftGit2-OSX.xcscheme index fec856e..ae0c67e 100644 --- a/SwiftGit2.xcodeproj/xcshareddata/xcschemes/SwiftGit2-OSX.xcscheme +++ b/SwiftGit2.xcodeproj/xcshareddata/xcschemes/SwiftGit2-OSX.xcscheme @@ -1,6 +1,6 @@ Result<[Branch], NSError> { return referencesWithPrefix("refs/heads/") .map { (refs: [ReferenceType]) in - return refs.map { $0 as Branch } + return refs.map { $0 as! Branch } } } @@ -317,30 +317,30 @@ final public class Repository { public func remoteBranches() -> Result<[Branch], NSError> { return referencesWithPrefix("refs/remotes/") .map { (refs: [ReferenceType]) in - return refs.map { $0 as Branch } + return refs.map { $0 as! Branch } } } /// Load the local branch with the given name (e.g., "master"). public func localBranchWithName(name: String) -> Result { - return referenceWithName("refs/heads/" + name).map { $0 as Branch } + return referenceWithName("refs/heads/" + name).map { $0 as! Branch } } /// Load the remote branch with the given name (e.g., "origin/master"). public func remoteBranchWithName(name: String) -> Result { - return referenceWithName("refs/remotes/" + name).map { $0 as Branch } + return referenceWithName("refs/remotes/" + name).map { $0 as! Branch } } /// Load and return a list of all the `TagReference`s. public func allTags() -> Result<[TagReference], NSError> { return referencesWithPrefix("refs/tags/") .map { (refs: [ReferenceType]) in - return refs.map { $0 as TagReference } + return refs.map { $0 as! TagReference } } } /// Load the tag with the given name (e.g., "tag-2"). public func tagWithName(name: String) -> Result { - return referenceWithName("refs/tags/" + name).map { $0 as TagReference } + return referenceWithName("refs/tags/" + name).map { $0 as! TagReference } } } diff --git a/SwiftGit2/SwiftGit2.modulemap b/SwiftGit2/SwiftGit2.modulemap index 300a89c..af706ab 100644 --- a/SwiftGit2/SwiftGit2.modulemap +++ b/SwiftGit2/SwiftGit2.modulemap @@ -1,7 +1,7 @@ framework module SwiftGit2 { umbrella header "SwiftGit2.h" - + header "git2/annotated_commit.h" header "git2/attr.h" header "git2/blob.h" @@ -60,7 +60,7 @@ framework module SwiftGit2 { header "git2/tree.h" header "git2/types.h" header "git2/version.h" - + export * module * { export * } } diff --git a/SwiftGit2Tests/Fixtures/Fixtures.swift b/SwiftGit2Tests/Fixtures/Fixtures.swift index 8b98ac8..cf31e88 100644 --- a/SwiftGit2Tests/Fixtures/Fixtures.swift +++ b/SwiftGit2Tests/Fixtures/Fixtures.swift @@ -35,7 +35,7 @@ final class Fixtures { NSFileManager.defaultManager().createDirectoryAtURL(directoryURL, withIntermediateDirectories: true, attributes: nil, error: 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) diff --git a/SwiftGit2Tests/RepositorySpec.swift b/SwiftGit2Tests/RepositorySpec.swift index ce34a6b..6c5d7d4 100644 --- a/SwiftGit2Tests/RepositorySpec.swift +++ b/SwiftGit2Tests/RepositorySpec.swift @@ -144,7 +144,7 @@ class RepositorySpec: QuickSpec { let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")! let blob = repo.blobWithOID(oid).value let result = repo.objectWithOID(oid) - expect(result.map { $0 as Blob }).to(haveSucceeded(equal(blob))) + expect(result.map { $0 as! Blob }).to(haveSucceeded(equal(blob))) } it("should work with a commit") { @@ -152,7 +152,7 @@ class RepositorySpec: QuickSpec { let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")! let commit = repo.commitWithOID(oid).value let result = repo.objectWithOID(oid) - expect(result.map { $0 as Commit }).to(haveSucceeded(equal(commit))) + expect(result.map { $0 as! Commit }).to(haveSucceeded(equal(commit))) } it("should work with a tag") { @@ -160,7 +160,7 @@ class RepositorySpec: QuickSpec { let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")! let tag = repo.tagWithOID(oid).value let result = repo.objectWithOID(oid) - expect(result.map { $0 as Tag }).to(haveSucceeded(equal(tag))) + expect(result.map { $0 as! Tag }).to(haveSucceeded(equal(tag))) } it("should work with a tree") { @@ -168,7 +168,7 @@ class RepositorySpec: QuickSpec { let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")! let tree = repo.treeWithOID(oid).value let result = repo.objectWithOID(oid) - expect(result.map { $0 as Tree }).to(haveSucceeded(equal(tree))) + expect(result.map { $0 as! Tree }).to(haveSucceeded(equal(tree))) } it("should error if there's no object with that oid") { @@ -224,7 +224,7 @@ class RepositorySpec: QuickSpec { let pointer = Pointer.Commit(oid) let commit = repo.commitWithOID(oid).value! - let result = repo.objectFromPointer(pointer).map { $0 as Commit } + let result = repo.objectFromPointer(pointer).map { $0 as! Commit } expect(result).to(haveSucceeded(equal(commit))) } @@ -234,7 +234,7 @@ class RepositorySpec: QuickSpec { let pointer = Pointer.Tree(oid) let tree = repo.treeWithOID(oid).value! - let result = repo.objectFromPointer(pointer).map { $0 as Tree } + let result = repo.objectFromPointer(pointer).map { $0 as! Tree } expect(result).to(haveSucceeded(equal(tree))) } @@ -244,7 +244,7 @@ class RepositorySpec: QuickSpec { let pointer = Pointer.Blob(oid) let blob = repo.blobWithOID(oid).value! - let result = repo.objectFromPointer(pointer).map { $0 as Blob } + let result = repo.objectFromPointer(pointer).map { $0 as! Blob } expect(result).to(haveSucceeded(equal(blob))) } @@ -254,7 +254,7 @@ class RepositorySpec: QuickSpec { let pointer = Pointer.Tag(oid) let tag = repo.tagWithOID(oid).value! - let result = repo.objectFromPointer(pointer).map { $0 as Tag } + let result = repo.objectFromPointer(pointer).map { $0 as! Tag } expect(result).to(haveSucceeded(equal(tag))) } } @@ -294,21 +294,21 @@ class RepositorySpec: QuickSpec { let name = "refs/heads/master" let result = Fixtures.simpleRepository.referenceWithName(name) expect(result.map { $0.longName }).to(haveSucceeded(equal(name))) - expect(result.value? as? Branch).notTo(beNil()) + expect(result.value as? Branch).notTo(beNil()) } - + it("should return a remote branch if it exists") { let name = "refs/remotes/upstream/master" let result = Fixtures.mantleRepository.referenceWithName(name) expect(result.map { $0.longName }).to(haveSucceeded(equal(name))) - expect(result.value? as? Branch).notTo(beNil()) + expect(result.value as? Branch).notTo(beNil()) } it("should return a tag if it exists") { let name = "refs/tags/tag-2" let result = Fixtures.simpleRepository.referenceWithName(name) expect(result.value?.longName).to(equal(name)) - expect(result.value? as? TagReference).notTo(beNil()) + expect(result.value as? TagReference).notTo(beNil()) } it("should return the reference if it exists") {