Skip to content

Commit

Permalink
Support Swift 1.2
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
modocache committed Feb 22, 2015
1 parent 5af50ab commit ba9a951
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion External/LlamaKit
2 changes: 1 addition & 1 deletion External/Quick
Submodule Quick updated 51 files
+1 −1 .gitmodules
+1 −1 .travis.yml
+11 −9 CONTRIBUTING.md
+1 −1 Externals/Nimble
+22 −0 Quick.podspec
+323 −166 Quick.xcodeproj/project.pbxproj
+29 −1 Quick.xcodeproj/xcshareddata/xcschemes/Quick-OSX.xcscheme
+11 −1 Quick.xcodeproj/xcshareddata/xcschemes/Quick-iOS.xcscheme
+10 −0 Quick.xcworkspace/contents.xcworkspacedata
+21 −2 Quick/Callsite.swift
+54 −1 Quick/Configuration/Configuration.swift
+57 −19 Quick/DSL/DSL.swift
+101 −8 Quick/DSL/QCKDSL.h
+21 −9 Quick/DSL/QCKDSL.m
+37 −11 Quick/DSL/World+DSL.swift
+72 −27 Quick/Example.swift
+63 −58 Quick/ExampleGroup.swift
+15 −2 Quick/ExampleMetadata.swift
+1 −1 Quick/Failure.swift
+29 −0 Quick/Filter.swift
+0 −1 Quick/Hooks/Closures.swift
+1 −1 Quick/Hooks/ExampleHooks.swift
+1 −1 Quick/Hooks/SuiteHooks.swift
+0 −18 Quick/NSException+Callsite.swift
+1 −2 Quick/QuickSpec.m
+0 −8 Quick/World+Singleton.swift
+144 −38 Quick/World.swift
+56 −0 QuickFocusedTests/FocusedTests+ObjC.m
+48 −0 QuickFocusedTests/FocusedTests.swift
+24 −0 QuickFocusedTests/Info.plist
+0 −25 QuickTests/ExampleMetadataFunctionalTests.swift
+1 −1 QuickTests/Fixtures/FunctionalTests_SharedExamplesTests_SharedExamples.swift
+0 −27 QuickTests/Fixtures/Person.swift
+0 −11 QuickTests/Fixtures/Poet.swift
+0 −65 QuickTests/FunctionalTests+ObjC.m
+0 −156 QuickTests/FunctionalTests.swift
+81 −0 QuickTests/FunctionalTests/AfterEachTests+ObjC.m
+52 −28 QuickTests/FunctionalTests/AfterEachTests.swift
+42 −0 QuickTests/FunctionalTests/AfterSuiteTests+ObjC.m
+1 −1 QuickTests/FunctionalTests/AfterSuiteTests.swift
+68 −0 QuickTests/FunctionalTests/BeforeEachTests+ObjC.m
+35 −27 QuickTests/FunctionalTests/BeforeEachTests.swift
+39 −0 QuickTests/FunctionalTests/BeforeSuiteTests+ObjC.m
+1 −1 QuickTests/FunctionalTests/BeforeSuiteTests.swift
+36 −0 QuickTests/FunctionalTests/ItTests+ObjC.m
+60 −0 QuickTests/FunctionalTests/PendingTests+ObjC.m
+1 −1 QuickTests/FunctionalTests/PendingTests.swift
+59 −0 QuickTests/FunctionalTests/SharedExamples+BeforeEachTests+ObjC.m
+36 −0 QuickTests/FunctionalTests/SharedExamplesTests+ObjC.m
+248 −9 README.md
+2 −2 Rakefile
8 changes: 4 additions & 4 deletions SwiftGit2.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -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 */
Expand Down Expand Up @@ -109,7 +109,6 @@
BEB31F571A0D75EE00F525B9 /* Mac-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "Mac-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
BEB31F581A0D75EE00F525B9 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
BEB31F6C1A0D78F300F525B9 /* Repository.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Repository.swift; sourceTree = "<group>"; };
BEB31F7E1A0D79C800F525B9 /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = "../../../Library/Developer/Xcode/DerivedData/SwiftGit2-hhirbsygtzljdvasajovfqnfzwwb/Build/Products/Debug/Quick.framework"; sourceTree = "<group>"; };
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 = "<group>"; };
BEB31F9D1A0E595100F525B9 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; };
Expand All @@ -121,6 +120,7 @@
DA50239F1A969F1A004175D7 /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = ../External/Nimble/build/Debug/Nimble.framework; sourceTree = "<group>"; };
DA59146C1A94549A00AED74C /* Guanaco.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Guanaco.framework; path = ../External/Guanaco/build/Debug/Guanaco.framework; sourceTree = "<group>"; };
DA5914751A94579000AED74C /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = "<group>"; };
DAC8143C1A99749D0063D88C /* Quick.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quick.framework; path = "../../../../Library/Developer/Xcode/DerivedData/SwiftGit2-ezqqkevntxbroughwcioyxqriijk/Build/Products/Debug/Quick.framework"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -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;
Expand Down Expand Up @@ -227,7 +227,7 @@
isa = PBXGroup;
children = (
DA50239F1A969F1A004175D7 /* Nimble.framework */,
BEB31F7E1A0D79C800F525B9 /* Quick.framework */,
DAC8143C1A99749D0063D88C /* Quick.framework */,
DA59146C1A94549A00AED74C /* Guanaco.framework */,
BEB31F341A0D6F7A00F525B9 /* Info.plist */,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0610"
LastUpgradeVersion = "0630"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion SwiftGit2/Objects.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

/// A git object.
public protocol ObjectType {
class var type: git_otype { get }
static var type: git_otype { get }

/// The OID of the object.
var oid: OID { get }
Expand Down
14 changes: 7 additions & 7 deletions SwiftGit2/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final public class Repository {
self.pointer = pointer

let path = git_repository_workdir(pointer)
self.directoryURL = (path == nil ? nil : NSURL.fileURLWithPath(NSString(CString: path, encoding: NSUTF8StringEncoding)!, isDirectory: true))
self.directoryURL = (path == nil ? nil : NSURL.fileURLWithPath(String.fromCString(path)!, isDirectory: true))
}

deinit {
Expand Down Expand Up @@ -309,38 +309,38 @@ final public class Repository {
public func localBranches() -> Result<[Branch], NSError> {
return referencesWithPrefix("refs/heads/")
.map { (refs: [ReferenceType]) in
return refs.map { $0 as Branch }
return refs.map { $0 as! Branch }
}
}

/// Load and return a list of all remote branches.
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<Branch, NSError> {
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<Branch, NSError> {
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<TagReference, NSError> {
return referenceWithName("refs/tags/" + name).map { $0 as TagReference }
return referenceWithName("refs/tags/" + name).map { $0 as! TagReference }
}
}
4 changes: 2 additions & 2 deletions SwiftGit2/SwiftGit2.modulemap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

framework module SwiftGit2 {
umbrella header "SwiftGit2.h"
header "git2/annotated_commit.h"
header "git2/attr.h"
header "git2/blob.h"
Expand Down Expand Up @@ -60,7 +60,7 @@ framework module SwiftGit2 {
header "git2/tree.h"
header "git2/types.h"
header "git2/version.h"
export *
module * { export * }
}
2 changes: 1 addition & 1 deletion SwiftGit2Tests/Fixtures/Fixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions SwiftGit2Tests/RepositorySpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,31 @@ 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") {
let repo = Fixtures.simpleRepository
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") {
let repo = Fixtures.simpleRepository
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") {
let repo = Fixtures.simpleRepository
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") {
Expand Down Expand Up @@ -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)))
}

Expand All @@ -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)))
}

Expand All @@ -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)))
}

Expand All @@ -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)))
}
}
Expand Down Expand Up @@ -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") {
Expand Down

0 comments on commit ba9a951

Please sign in to comment.