.gitmodules: Update LlamaKit to v0.5.0

This is the first of a series of commits intended to resolve issue #10,
which calls for proper error handling.

One way to test that libgit2 error messages are being propagated through
Result failures is by asserting that the error's description or code
match the message or code we expect. In order to do so, LlamaKit's
ErrorType is unweildy, and not future-proof--it would be easier and
safer to write assertions based on NSError.

Upgrade LlamaKit to v0.5.0, the latest version that supports Swift 1.1,
in order to define results as type `Result<T, NSError>`.
This commit is contained in:
Brian Gesiak 2015-02-17 22:18:51 -05:00
parent 860b30c506
commit 1019a94d53
5 changed files with 97 additions and 97 deletions

2
.gitmodules vendored
View File

@ -9,4 +9,4 @@
url = https://github.com/libgit2/libgit2.git
[submodule "External/LlamaKit"]
path = External/LlamaKit
url = https://github.com/ReactiveCocoa/LlamaKit.git
url = https://github.com/LlamaKit/LlamaKit.git

2
External/LlamaKit vendored

@ -1 +1 @@
Subproject commit 8ca536926dfe73bc51285d295ec0af42557db9cd
Subproject commit e37b966998df6ca05445c0b5d9c6c9560f1e7b61

View File

@ -32,7 +32,7 @@ final public class Repository {
/// URL - The URL of the repository.
///
/// Returns a `Result` with a `Repository` or an error.
class public func atURL(URL: NSURL) -> Result<Repository> {
class public func atURL(URL: NSURL) -> Result<Repository, NSError> {
let pointer = UnsafeMutablePointer<COpaquePointer>.alloc(1)
let result = git_repository_open(pointer, URL.fileSystemRepresentation)
@ -82,7 +82,7 @@ final public class Repository {
///
/// Returns the result of calling `transform` or an error if the object
/// cannot be loaded.
func withLibgit2Object<T>(oid: OID, type: git_otype, transform: COpaquePointer -> Result<T>) -> Result<T> {
func withLibgit2Object<T>(oid: OID, type: git_otype, transform: COpaquePointer -> Result<T, NSError>) -> Result<T, NSError> {
let pointer = UnsafeMutablePointer<COpaquePointer>.alloc(1)
let repository = self.pointer
var oid = oid.oid
@ -99,7 +99,7 @@ final public class Repository {
return value
}
func withLibgit2Object<T>(oid: OID, type: git_otype, transform: COpaquePointer -> T) -> Result<T> {
func withLibgit2Object<T>(oid: OID, type: git_otype, transform: COpaquePointer -> T) -> Result<T, NSError> {
return withLibgit2Object(oid, type: type) { success(transform($0)) }
}
@ -108,7 +108,7 @@ final public class Repository {
/// oid - The OID of the blob to look up.
///
/// Returns a `Blob`, `Commit`, `Tag`, or `Tree` if one exists, or an error.
public func objectWithOID(oid: OID) -> Result<ObjectType> {
public func objectWithOID(oid: OID) -> Result<ObjectType, NSError> {
return withLibgit2Object(oid, type: GIT_OBJ_ANY) { object in
let type = git_object_type(object)
if type == Blob.type {
@ -129,7 +129,7 @@ final public class Repository {
/// oid - The OID of the blob to look up.
///
/// Returns the blob if it exists, or an error.
public func blobWithOID(oid: OID) -> Result<Blob> {
public func blobWithOID(oid: OID) -> Result<Blob, NSError> {
return self.withLibgit2Object(oid, type: GIT_OBJ_BLOB) { Blob($0) }
}
@ -138,7 +138,7 @@ final public class Repository {
/// oid - The OID of the commit to look up.
///
/// Returns the commit if it exists, or an error.
public func commitWithOID(oid: OID) -> Result<Commit> {
public func commitWithOID(oid: OID) -> Result<Commit, NSError> {
return self.withLibgit2Object(oid, type: GIT_OBJ_COMMIT) { Commit($0) }
}
@ -147,7 +147,7 @@ final public class Repository {
/// oid - The OID of the tag to look up.
///
/// Returns the tag if it exists, or an error.
public func tagWithOID(oid: OID) -> Result<Tag> {
public func tagWithOID(oid: OID) -> Result<Tag, NSError> {
return self.withLibgit2Object(oid, type: GIT_OBJ_TAG) { Tag($0) }
}
@ -156,7 +156,7 @@ final public class Repository {
/// oid - The OID of the tree to look up.
///
/// Returns the tree if it exists, or an error.
public func treeWithOID(oid: OID) -> Result<Tree> {
public func treeWithOID(oid: OID) -> Result<Tree, NSError> {
return self.withLibgit2Object(oid, type: GIT_OBJ_TREE) { Tree($0) }
}
@ -165,7 +165,7 @@ final public class Repository {
/// pointer - A pointer to an object.
///
/// Returns the object if it exists, or an error.
public func objectFromPointer<T>(pointer: PointerTo<T>) -> Result<T> {
public func objectFromPointer<T>(pointer: PointerTo<T>) -> Result<T, NSError> {
return self.withLibgit2Object(pointer.oid, type: pointer.type) { T($0) }
}
@ -174,7 +174,7 @@ final public class Repository {
/// pointer - A pointer to an object.
///
/// Returns the object if it exists, or an error.
public func objectFromPointer(pointer: Pointer) -> Result<ObjectType> {
public func objectFromPointer(pointer: Pointer) -> Result<ObjectType, NSError> {
switch pointer {
case let .Blob(oid):
return blobWithOID(oid).map { $0 as ObjectType }
@ -192,7 +192,7 @@ final public class Repository {
/// Loads all the remotes in the repository.
///
/// Returns an array of remotes, or an error.
public func allRemotes() -> Result<[Remote]> {
public func allRemotes() -> Result<[Remote], NSError> {
let pointer = UnsafeMutablePointer<git_strarray>.alloc(1)
let repository = self.pointer
let result = git_remote_list(pointer, repository)
@ -203,17 +203,17 @@ final public class Repository {
}
let strarray = pointer.memory
let remotes: [Result<Remote>] = strarray.map {
let remotes: [Result<Remote, NSError>] = strarray.map {
return self.remoteWithName($0)
}
git_strarray_free(pointer)
pointer.dealloc(1)
let error = remotes.reduce(nil) { $0 == nil ? $0 : $1.error() }
let error = remotes.reduce(nil) { $0 == nil ? $0 : $1.error }
if let error = error {
return failure(error)
}
return success(remotes.map { $0.value()! })
return success(remotes.map { $0.value! })
}
/// Load a remote from the repository.
@ -221,7 +221,7 @@ final public class Repository {
/// name - The name of the remote.
///
/// Returns the remote if it exists, or an error.
public func remoteWithName(name: String) -> Result<Remote> {
public func remoteWithName(name: String) -> Result<Remote, NSError> {
let pointer = UnsafeMutablePointer<COpaquePointer>.alloc(1)
let repository = self.pointer
let result = git_remote_lookup(pointer, repository, name)
@ -240,7 +240,7 @@ final public class Repository {
// MARK: - Reference Lookups
/// Load all the references with the given prefix (e.g. "refs/heads/")
public func referencesWithPrefix(prefix: String) -> Result<[ReferenceType]> {
public func referencesWithPrefix(prefix: String) -> Result<[ReferenceType], NSError> {
let pointer = UnsafeMutablePointer<git_strarray>.alloc(1)
let repository = self.pointer
let result = git_reference_list(pointer, repository)
@ -261,11 +261,11 @@ final public class Repository {
git_strarray_free(pointer)
pointer.dealloc(1)
let error = references.reduce(nil) { $0 == nil ? $0 : $1.error() }
let error = references.reduce(nil) { $0 == nil ? $0 : $1.error }
if let error = error {
return failure(error)
}
return success(references.map { $0.value()! })
return success(references.map { $0.value! })
}
/// Load the reference with the given long name (e.g. "refs/heads/master")
@ -273,7 +273,7 @@ final public class Repository {
/// If the reference is a branch, a `Branch` will be returned. If the
/// reference is a tag, a `TagReference` will be returned. Otherwise, a
/// `Reference` will be returned.
public func referenceWithName(name: String) -> Result<ReferenceType> {
public func referenceWithName(name: String) -> Result<ReferenceType, NSError> {
let pointer = UnsafeMutablePointer<COpaquePointer>.alloc(1)
let repository = self.pointer
let result = git_reference_lookup(pointer, repository, name)
@ -298,7 +298,7 @@ final public class Repository {
}
/// Load and return a list of all local branches.
public func localBranches() -> Result<[Branch]> {
public func localBranches() -> Result<[Branch], NSError> {
return referencesWithPrefix("refs/heads/")
.map { (refs: [ReferenceType]) in
return refs.map { $0 as Branch }
@ -306,7 +306,7 @@ final public class Repository {
}
/// Load and return a list of all remote branches.
public func remoteBranches() -> Result<[Branch]> {
public func remoteBranches() -> Result<[Branch], NSError> {
return referencesWithPrefix("refs/remotes/")
.map { (refs: [ReferenceType]) in
return refs.map { $0 as Branch }
@ -314,17 +314,17 @@ final public class Repository {
}
/// Load the local branch with the given name (e.g., "master").
public func localBranchWithName(name: String) -> Result<Branch> {
public func localBranchWithName(name: String) -> Result<Branch, NSError> {
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> {
public func remoteBranchWithName(name: String) -> Result<Branch, NSError> {
return referenceWithName("refs/remotes/" + name).map { $0 as Branch }
}
/// Load and return a list of all the `TagReference`s.
public func allTags() -> Result<[TagReference]> {
public func allTags() -> Result<[TagReference], NSError> {
return referencesWithPrefix("refs/tags/")
.map { (refs: [ReferenceType]) in
return refs.map { $0 as TagReference }
@ -332,7 +332,7 @@ final public class Repository {
}
/// Load the tag with the given name (e.g., "tag-2").
public func tagWithName(name: String) -> Result<TagReference> {
public func tagWithName(name: String) -> Result<TagReference, NSError> {
return referenceWithName("refs/tags/" + name).map { $0 as TagReference }
}
}

View File

@ -59,7 +59,7 @@ final class Fixtures {
func repositoryWithName(name: String) -> Repository {
let url = directoryURL.URLByAppendingPathComponent(name, isDirectory: true)
return Repository.atURL(url).value()!
return Repository.atURL(url).value!
}
// MARK: - The Fixtures

View File

@ -22,7 +22,7 @@ class RepositorySpec: QuickSpec {
it("should fail if the repo doesn't exist") {
let url = NSURL(fileURLWithPath: "blah")!
let result = Repository.atURL(url)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -32,7 +32,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let result = repo.blobWithOID(oid)
let blob = result.value()
let blob = result.value
expect(blob).notTo(beNil())
expect(blob?.oid).to(equal(oid))
}
@ -42,7 +42,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.blobWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
it("should error if the oid doesn't point to a blob") {
@ -51,7 +51,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.blobWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -61,7 +61,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.commitWithOID(oid)
let commit = result.value()
let commit = result.value
expect(commit).notTo(beNil())
expect(commit?.oid).to(equal(oid))
}
@ -71,7 +71,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.commitWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
it("should error if the oid doesn't point to a commit") {
@ -80,7 +80,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.commitWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -90,7 +90,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let result = repo.tagWithOID(oid)
let tag = result.value()
let tag = result.value
expect(tag).notTo(beNil())
expect(tag?.oid).to(equal(oid))
}
@ -100,7 +100,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.tagWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
it("should error if the oid doesn't point to a tag") {
@ -109,7 +109,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.tagWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -119,7 +119,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.treeWithOID(oid)
let tree = result.value()
let tree = result.value
expect(tree).notTo(beNil())
expect(tree?.oid).to(equal(oid))
}
@ -129,7 +129,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.treeWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
it("should error if the oid doesn't point to a tree") {
@ -138,7 +138,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.treeWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -146,44 +146,44 @@ class RepositorySpec: QuickSpec {
it("should work with a blob") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob = repo.blobWithOID(oid).value()
let blob = repo.blobWithOID(oid).value
let result = repo.objectWithOID(oid)
expect(result.value()).notTo(beNil())
expect(result.value() as Blob?).to(equal(blob))
expect(result.value).notTo(beNil())
expect(result.value as Blob?).to(equal(blob))
}
it("should work with a commit") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let commit = repo.commitWithOID(oid).value()
let commit = repo.commitWithOID(oid).value
let result = repo.objectWithOID(oid)
expect(result.value()).notTo(beNil())
expect(result.value() as Commit?).to(equal(commit))
expect(result.value).notTo(beNil())
expect(result.value as Commit?).to(equal(commit))
}
it("should work with a tag") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let tag = repo.tagWithOID(oid).value()
let tag = repo.tagWithOID(oid).value
let result = repo.objectWithOID(oid)
expect(result.value()).notTo(beNil())
expect(result.value() as Tag?).to(equal(tag))
expect(result.value).notTo(beNil())
expect(result.value as Tag?).to(equal(tag))
}
it("should work with a tree") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let tree = repo.treeWithOID(oid).value()
let tree = repo.treeWithOID(oid).value
let result = repo.objectWithOID(oid)
expect(result.value()).notTo(beNil())
expect(result.value() as Tree?).to(equal(tree))
expect(result.value).notTo(beNil())
expect(result.value as Tree?).to(equal(tree))
}
it("should error if there's no object with that oid") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.objectWithOID(oid)
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -193,8 +193,8 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let pointer = PointerTo<Commit>(oid)
let commit = repo.commitWithOID(oid).value()!
expect(repo.objectFromPointer(pointer).value()).to(equal(commit))
let commit = repo.commitWithOID(oid).value!
expect(repo.objectFromPointer(pointer).value).to(equal(commit))
}
it("should work with trees") {
@ -202,8 +202,8 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let pointer = PointerTo<Tree>(oid)
let tree = repo.treeWithOID(oid).value()!
expect(repo.objectFromPointer(pointer).value()).to(equal(tree))
let tree = repo.treeWithOID(oid).value!
expect(repo.objectFromPointer(pointer).value).to(equal(tree))
}
it("should work with blobs") {
@ -211,8 +211,8 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let pointer = PointerTo<Blob>(oid)
let blob = repo.blobWithOID(oid).value()!
expect(repo.objectFromPointer(pointer).value()).to(equal(blob))
let blob = repo.blobWithOID(oid).value!
expect(repo.objectFromPointer(pointer).value).to(equal(blob))
}
it("should work with tags") {
@ -220,8 +220,8 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let pointer = PointerTo<Tag>(oid)
let tag = repo.tagWithOID(oid).value()!
expect(repo.objectFromPointer(pointer).value()).to(equal(tag))
let tag = repo.tagWithOID(oid).value!
expect(repo.objectFromPointer(pointer).value).to(equal(tag))
}
}
@ -231,8 +231,8 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let pointer = Pointer.Commit(oid)
let commit = repo.commitWithOID(oid).value()!
let result = repo.objectFromPointer(pointer).map { $0 as Commit }.value()
let commit = repo.commitWithOID(oid).value!
let result = repo.objectFromPointer(pointer).map { $0 as Commit }.value
expect(result).to(equal(commit))
}
@ -241,8 +241,8 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let pointer = Pointer.Tree(oid)
let tree = repo.treeWithOID(oid).value()!
let result = repo.objectFromPointer(pointer).map { $0 as Tree }.value()
let tree = repo.treeWithOID(oid).value!
let result = repo.objectFromPointer(pointer).map { $0 as Tree }.value
expect(result).to(equal(tree))
}
@ -251,8 +251,8 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let pointer = Pointer.Blob(oid)
let blob = repo.blobWithOID(oid).value()!
let result = repo.objectFromPointer(pointer).map { $0 as Blob }.value()
let blob = repo.blobWithOID(oid).value!
let result = repo.objectFromPointer(pointer).map { $0 as Blob }.value
expect(result).to(equal(blob))
}
@ -261,8 +261,8 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let pointer = Pointer.Tag(oid)
let tag = repo.tagWithOID(oid).value()!
let result = repo.objectFromPointer(pointer).map { $0 as Tag }.value()
let tag = repo.tagWithOID(oid).value!
let result = repo.objectFromPointer(pointer).map { $0 as Tag }.value
expect(result).to(equal(tag))
}
}
@ -271,12 +271,12 @@ class RepositorySpec: QuickSpec {
it("should return an empty list if there are no remotes") {
let repo = Fixtures.simpleRepository
let result = repo.allRemotes()
expect(result.value()).to(equal([]))
expect(result.value).to(equal([]))
}
it("should return all the remotes") {
let repo = Fixtures.mantleRepository
let remotes = repo.allRemotes().value()
let remotes = repo.allRemotes().value
let names = remotes?.map { $0.name }
expect(remotes?.count).to(equal(2))
expect(names).to(contain("origin", "upstream"))
@ -287,13 +287,13 @@ class RepositorySpec: QuickSpec {
it("should return the remote if it exists") {
let repo = Fixtures.mantleRepository
let result = repo.remoteWithName("upstream")
expect(result.value()?.name).to(equal("upstream"))
expect(result.value?.name).to(equal("upstream"))
}
it("should error if the remote doesn't exist") {
let repo = Fixtures.simpleRepository
let result = repo.remoteWithName("nonexistent")
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -301,33 +301,33 @@ class RepositorySpec: QuickSpec {
it("should return a local branch if it exists") {
let name = "refs/heads/master"
let result = Fixtures.simpleRepository.referenceWithName(name)
expect(result.value()?.longName).to(equal(name))
expect(result.value()? as? Branch).notTo(beNil())
expect(result.value?.longName).to(equal(name))
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.value()?.longName).to(equal(name))
expect(result.value()? as? Branch).notTo(beNil())
expect(result.value?.longName).to(equal(name))
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?.longName).to(equal(name))
expect(result.value? as? TagReference).notTo(beNil())
}
it("should return the reference if it exists") {
let name = "refs/other-ref"
let result = Fixtures.simpleRepository.referenceWithName(name)
expect(result.value()?.longName).to(equal(name))
expect(result.value?.longName).to(equal(name))
}
it("should error if the reference doesn't exist") {
let result = Fixtures.simpleRepository.referenceWithName("refs/heads/nonexistent")
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -335,11 +335,11 @@ class RepositorySpec: QuickSpec {
it("should return all the local branches") {
let repo = Fixtures.simpleRepository
let expected = [
repo.localBranchWithName("another-branch").value()!,
repo.localBranchWithName("master").value()!,
repo.localBranchWithName("yet-another-branch").value()!,
repo.localBranchWithName("another-branch").value!,
repo.localBranchWithName("master").value!,
repo.localBranchWithName("yet-another-branch").value!,
]
expect(repo.localBranches().value()).to(equal(expected))
expect(repo.localBranches().value).to(equal(expected))
}
}
@ -365,8 +365,8 @@ class RepositorySpec: QuickSpec {
"upstream/reversible-transformer",
"upstream/subclassing-notes",
]
let expected = expectedNames.map { repo.remoteBranchWithName($0).value()! }
let actual = repo.remoteBranches().value()!.sorted {
let expected = expectedNames.map { repo.remoteBranchWithName($0).value! }
let actual = repo.remoteBranches().value!.sorted {
return lexicographicalCompare($0.longName, $1.longName)
}
expect(actual).to(equal(expected))
@ -377,24 +377,24 @@ class RepositorySpec: QuickSpec {
describe("-localBranchWithName()") {
it("should return the branch if it exists") {
let result = Fixtures.simpleRepository.localBranchWithName("master")
expect(result.value()?.longName).to(equal("refs/heads/master"))
expect(result.value?.longName).to(equal("refs/heads/master"))
}
it("should error if the branch doesn't exists") {
let result = Fixtures.simpleRepository.localBranchWithName("nonexistent")
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
describe("-remoteBranchWithName()") {
it("should return the branch if it exists") {
let result = Fixtures.mantleRepository.remoteBranchWithName("upstream/master")
expect(result.value()?.longName).to(equal("refs/remotes/upstream/master"))
expect(result.value?.longName).to(equal("refs/remotes/upstream/master"))
}
it("should error if the branch doesn't exists") {
let result = Fixtures.simpleRepository.remoteBranchWithName("origin/nonexistent")
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
@ -402,22 +402,22 @@ class RepositorySpec: QuickSpec {
it("should return all the tags") {
let repo = Fixtures.simpleRepository
let expected = [
repo.tagWithName("tag-1").value()!,
repo.tagWithName("tag-2").value()!,
repo.tagWithName("tag-1").value!,
repo.tagWithName("tag-2").value!,
]
expect(repo.allTags().value()).to(equal(expected))
expect(repo.allTags().value).to(equal(expected))
}
}
describe("-tagWithName()") {
it("should return the tag if it exists") {
let result = Fixtures.simpleRepository.tagWithName("tag-2")
expect(result.value()?.longName).to(equal("refs/tags/tag-2"))
expect(result.value?.longName).to(equal("refs/tags/tag-2"))
}
it("should error if the branch doesn't exists") {
let result = Fixtures.simpleRepository.tagWithName("nonexistent")
expect(result.error()).notTo(beNil())
expect(result.error).notTo(beNil())
}
}
}