Remove the OID argument label for object getters

This commit is contained in:
Matt Rubin 2016-12-22 23:36:25 -05:00
parent 6da9e7810c
commit c746c720c3
3 changed files with 88 additions and 88 deletions

View File

@ -185,7 +185,7 @@ final public class Repository {
///
/// Returns the result of calling `transform` or an error if the object
/// cannot be loaded.
private func withGitObject<T>(withIdentity oid: OID, type: git_otype, transform: (OpaquePointer) -> Result<T, NSError>) -> Result<T, NSError> {
private func withGitObject<T>(_ oid: OID, type: git_otype, transform: (OpaquePointer) -> Result<T, NSError>) -> Result<T, NSError> {
var pointer: OpaquePointer? = nil
var oid = oid.oid
let result = git_object_lookup(&pointer, self.pointer, &oid, type)
@ -199,8 +199,8 @@ final public class Repository {
return value
}
private func withGitObject<T>(withIdentity oid: OID, type: git_otype, transform: (OpaquePointer) -> T) -> Result<T, NSError> {
return withGitObject(withIdentity: oid, type: type) { Result.success(transform($0)) }
private func withGitObject<T>(_ oid: OID, type: git_otype, transform: (OpaquePointer) -> T) -> Result<T, NSError> {
return withGitObject(oid, type: type) { Result.success(transform($0)) }
}
/// Loads the object with the given OID.
@ -208,8 +208,8 @@ 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 object(withIdentity oid: OID) -> Result<ObjectType, NSError> {
return withGitObject(withIdentity: oid, type: GIT_OBJ_ANY) { object in
public func object(_ oid: OID) -> Result<ObjectType, NSError> {
return withGitObject(oid, type: GIT_OBJ_ANY) { object in
let type = git_object_type(object)
if type == Blob.type {
return Result.success(Blob(object))
@ -237,8 +237,8 @@ final public class Repository {
/// oid - The OID of the blob to look up.
///
/// Returns the blob if it exists, or an error.
public func blob(withIdentity oid: OID) -> Result<Blob, NSError> {
return withGitObject(withIdentity: oid, type: GIT_OBJ_BLOB) { Blob($0) }
public func blob(_ oid: OID) -> Result<Blob, NSError> {
return withGitObject(oid, type: GIT_OBJ_BLOB) { Blob($0) }
}
/// Loads the commit with the given OID.
@ -246,8 +246,8 @@ final public class Repository {
/// oid - The OID of the commit to look up.
///
/// Returns the commit if it exists, or an error.
public func commit(withIdentity oid: OID) -> Result<Commit, NSError> {
return withGitObject(withIdentity: oid, type: GIT_OBJ_COMMIT) { Commit($0) }
public func commit(_ oid: OID) -> Result<Commit, NSError> {
return withGitObject(oid, type: GIT_OBJ_COMMIT) { Commit($0) }
}
/// Loads the tag with the given OID.
@ -255,8 +255,8 @@ final public class Repository {
/// oid - The OID of the tag to look up.
///
/// Returns the tag if it exists, or an error.
public func tag(withIdentity oid: OID) -> Result<Tag, NSError> {
return withGitObject(withIdentity: oid, type: GIT_OBJ_TAG) { Tag($0) }
public func tag(_ oid: OID) -> Result<Tag, NSError> {
return withGitObject(oid, type: GIT_OBJ_TAG) { Tag($0) }
}
/// Loads the tree with the given OID.
@ -264,8 +264,8 @@ final public class Repository {
/// oid - The OID of the tree to look up.
///
/// Returns the tree if it exists, or an error.
public func tree(withIdentity oid: OID) -> Result<Tree, NSError> {
return withGitObject(withIdentity: oid, type: GIT_OBJ_TREE) { Tree($0) }
public func tree(_ oid: OID) -> Result<Tree, NSError> {
return withGitObject(oid, type: GIT_OBJ_TREE) { Tree($0) }
}
/// Loads the referenced object from the pointer.
@ -274,7 +274,7 @@ final public class Repository {
///
/// Returns the object if it exists, or an error.
public func object<T>(from pointer: PointerTo<T>) -> Result<T, NSError> {
return withGitObject(withIdentity: pointer.oid, type: pointer.type) { T($0) }
return withGitObject(pointer.oid, type: pointer.type) { T($0) }
}
/// Loads the referenced object from the pointer.
@ -285,13 +285,13 @@ final public class Repository {
public func object(from pointer: Pointer) -> Result<ObjectType, NSError> {
switch pointer {
case let .Blob(oid):
return blob(withIdentity: oid).map { $0 as ObjectType }
return blob(oid).map { $0 as ObjectType }
case let .Commit(oid):
return commit(withIdentity: oid).map { $0 as ObjectType }
return commit(oid).map { $0 as ObjectType }
case let .Tag(oid):
return tag(withIdentity: oid).map { $0 as ObjectType }
return tag(oid).map { $0 as ObjectType }
case let .Tree(oid):
return tree(withIdentity: oid).map { $0 as ObjectType }
return tree(oid).map { $0 as ObjectType }
}
}

View File

@ -13,7 +13,7 @@ import Quick
import libgit2
private extension Repository {
func withGitObject<T>(withIdentity oid: OID, transform: (OpaquePointer) -> T) -> T {
func withGitObject<T>(_ oid: OID, transform: (OpaquePointer) -> T) -> T {
let repository = self.pointer
var oid = oid.oid
@ -33,7 +33,7 @@ class SignatureSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let raw_signature = repo.withGitObject(withIdentity: oid) { git_commit_author($0).pointee }
let raw_signature = repo.withGitObject(oid) { git_commit_author($0).pointee }
let signature = Signature(raw_signature)
expect(signature.name).to(equal("Matt Diephouse"))
@ -48,7 +48,7 @@ class SignatureSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let author1 = repo.withGitObject(withIdentity: oid) { commit in
let author1 = repo.withGitObject(oid) { commit in
Signature(git_commit_author(commit).pointee)
}
let author2 = author1
@ -61,10 +61,10 @@ class SignatureSpec: QuickSpec {
let oid1 = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let oid2 = OID(string: "24e1e40ee77525d9e279f079f9906ad6d98c8940")!
let author1 = repo.withGitObject(withIdentity: oid1) { commit in
let author1 = repo.withGitObject(oid1) { commit in
Signature(git_commit_author(commit).pointee)
}
let author2 = repo.withGitObject(withIdentity: oid2) { commit in
let author2 = repo.withGitObject(oid2) { commit in
Signature(git_commit_author(commit).pointee)
}
@ -77,7 +77,7 @@ class SignatureSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let author1 = repo.withGitObject(withIdentity: oid) { commit in
let author1 = repo.withGitObject(oid) { commit in
Signature(git_commit_author(commit).pointee)
}
let author2 = author1
@ -95,11 +95,11 @@ class CommitSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "24e1e40ee77525d9e279f079f9906ad6d98c8940")!
let commit = repo.withGitObject(withIdentity: oid) { Commit($0) }
let author = repo.withGitObject(withIdentity: oid) { commit in
let commit = repo.withGitObject(oid) { Commit($0) }
let author = repo.withGitObject(oid) { commit in
Signature(git_commit_author(commit).pointee)
}
let committer = repo.withGitObject(withIdentity: oid) { commit in
let committer = repo.withGitObject(oid) { commit in
Signature(git_commit_committer(commit).pointee)
}
let tree = PointerTo<Tree>(OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!)
@ -118,7 +118,7 @@ class CommitSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let commit = repo.withGitObject(withIdentity: oid) { Commit($0) }
let commit = repo.withGitObject(oid) { Commit($0) }
expect(commit.parents).to(equal([]))
}
@ -126,7 +126,7 @@ class CommitSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "c4ed03a6b7d7ce837d31d83757febbe84dd465fd")!
let commit = repo.withGitObject(withIdentity: oid) { Commit($0) }
let commit = repo.withGitObject(oid) { Commit($0) }
let parents: [PointerTo<Commit>] = [
PointerTo(OID(string: "315b3f344221db91ddc54b269f3c9af422da0f2e")!),
PointerTo(OID(string: "57f6197561d1f99b03c160f4026a07f06b43cf20")!),
@ -140,7 +140,7 @@ class CommitSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let commit1 = repo.withGitObject(withIdentity: oid) { Commit($0) }
let commit1 = repo.withGitObject(oid) { Commit($0) }
let commit2 = commit1
expect(commit1).to(equal(commit2))
}
@ -150,8 +150,8 @@ class CommitSpec: QuickSpec {
let oid1 = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let oid2 = OID(string: "c4ed03a6b7d7ce837d31d83757febbe84dd465fd")!
let commit1 = repo.withGitObject(withIdentity: oid1) { Commit($0) }
let commit2 = repo.withGitObject(withIdentity: oid2) { Commit($0) }
let commit1 = repo.withGitObject(oid1) { Commit($0) }
let commit2 = repo.withGitObject(oid2) { Commit($0) }
expect(commit1).notTo(equal(commit2))
}
}
@ -161,7 +161,7 @@ class CommitSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let commit1 = repo.withGitObject(withIdentity: oid) { Commit($0) }
let commit1 = repo.withGitObject(oid) { Commit($0) }
let commit2 = commit1
expect(commit1.hashValue).to(equal(commit2.hashValue))
}
@ -189,7 +189,7 @@ class TreeEntrySpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let entry = repo.withGitObject(withIdentity: oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry = repo.withGitObject(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"))
@ -201,7 +201,7 @@ class TreeEntrySpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let entry1 = repo.withGitObject(withIdentity: oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry1 = repo.withGitObject(oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry2 = entry1
expect(entry1).to(equal(entry2))
}
@ -211,8 +211,8 @@ class TreeEntrySpec: QuickSpec {
let oid1 = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let oid2 = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let entry1 = repo.withGitObject(withIdentity: oid1) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry2 = repo.withGitObject(withIdentity: oid2) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry1 = repo.withGitObject(oid1) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry2 = repo.withGitObject(oid2) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
expect(entry1).notTo(equal(entry2))
}
}
@ -222,7 +222,7 @@ class TreeEntrySpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let entry1 = repo.withGitObject(withIdentity: oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry1 = repo.withGitObject(oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
let entry2 = entry1
expect(entry1.hashValue).to(equal(entry2.hashValue))
}
@ -237,7 +237,7 @@ class TreeSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let tree = repo.withGitObject(withIdentity: oid) { Tree($0) }
let tree = repo.withGitObject(oid) { Tree($0) }
let entries = [
"README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.rawValue), object: .Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!), name: "README.md"),
]
@ -250,7 +250,7 @@ class TreeSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let tree1 = repo.withGitObject(withIdentity: oid) { Tree($0) }
let tree1 = repo.withGitObject(oid) { Tree($0) }
let tree2 = tree1
expect(tree1).to(equal(tree2))
}
@ -260,8 +260,8 @@ class TreeSpec: QuickSpec {
let oid1 = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let oid2 = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let tree1 = repo.withGitObject(withIdentity: oid1) { Tree($0) }
let tree2 = repo.withGitObject(withIdentity: oid2) { Tree($0) }
let tree1 = repo.withGitObject(oid1) { Tree($0) }
let tree2 = repo.withGitObject(oid2) { Tree($0) }
expect(tree1).notTo(equal(tree2))
}
}
@ -271,7 +271,7 @@ class TreeSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
let tree1 = repo.withGitObject(withIdentity: oid) { Tree($0) }
let tree1 = repo.withGitObject(oid) { Tree($0) }
let tree2 = tree1
expect(tree1.hashValue).to(equal(tree2.hashValue))
}
@ -286,7 +286,7 @@ class BlobSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob = repo.withGitObject(withIdentity: oid) { Blob($0) }
let blob = repo.withGitObject(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.data(using: String.Encoding.utf8)!
expect(blob.oid).to(equal(oid))
@ -299,7 +299,7 @@ class BlobSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob1 = repo.withGitObject(withIdentity: oid) { Blob($0) }
let blob1 = repo.withGitObject(oid) { Blob($0) }
let blob2 = blob1
expect(blob1).to(equal(blob2))
}
@ -309,8 +309,8 @@ class BlobSpec: QuickSpec {
let oid1 = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let oid2 = OID(string: "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391")!
let blob1 = repo.withGitObject(withIdentity: oid1) { Blob($0) }
let blob2 = repo.withGitObject(withIdentity: oid2) { Blob($0) }
let blob1 = repo.withGitObject(oid1) { Blob($0) }
let blob2 = repo.withGitObject(oid2) { Blob($0) }
expect(blob1).notTo(equal(blob2))
}
}
@ -320,7 +320,7 @@ class BlobSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob1 = repo.withGitObject(withIdentity: oid) { Blob($0) }
let blob1 = repo.withGitObject(oid) { Blob($0) }
let blob2 = blob1
expect(blob1.hashValue).to(equal(blob2.hashValue))
}
@ -335,8 +335,8 @@ class TagSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let tag = repo.withGitObject(withIdentity: oid) { Tag($0) }
let tagger = repo.withGitObject(withIdentity: oid) { Signature(git_tag_tagger($0).pointee) }
let tag = repo.withGitObject(oid) { Tag($0) }
let tagger = repo.withGitObject(oid) { Signature(git_tag_tagger($0).pointee) }
expect(tag.oid).to(equal(oid))
expect(tag.target).to(equal(Pointer.Commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
@ -351,7 +351,7 @@ class TagSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let tag1 = repo.withGitObject(withIdentity: oid) { Tag($0) }
let tag1 = repo.withGitObject(oid) { Tag($0) }
let tag2 = tag1
expect(tag1).to(equal(tag2))
}
@ -361,8 +361,8 @@ class TagSpec: QuickSpec {
let oid1 = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let oid2 = OID(string: "13bda91157f255ab224ff88d0a11a82041c9d0c1")!
let tag1 = repo.withGitObject(withIdentity: oid1) { Tag($0) }
let tag2 = repo.withGitObject(withIdentity: oid2) { Tag($0) }
let tag1 = repo.withGitObject(oid1) { Tag($0) }
let tag2 = repo.withGitObject(oid2) { Tag($0) }
expect(tag1).notTo(equal(tag2))
}
}
@ -372,7 +372,7 @@ class TagSpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let tag1 = repo.withGitObject(withIdentity: oid) { Tag($0) }
let tag1 = repo.withGitObject(oid) { Tag($0) }
let tag2 = tag1
expect(tag1.hashValue).to(equal(tag2.hashValue))
}

View File

@ -115,12 +115,12 @@ class RepositorySpec: QuickSpec {
}
}
describe("Repository.blob(withIdentity:)") {
describe("Repository.blob(_:)") {
it("should return the commit if it exists") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let result = repo.blob(withIdentity: oid)
let result = repo.blob(oid)
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
}
@ -128,7 +128,7 @@ class RepositorySpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.blob(withIdentity: oid)
let result = repo.blob(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
}
@ -137,17 +137,17 @@ class RepositorySpec: QuickSpec {
// This is a tree in the repository
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.blob(withIdentity: oid)
let result = repo.blob(oid)
expect(result).to(haveFailed())
}
}
describe("Repository.commit(withIdentity:)") {
describe("Repository.commit(_:)") {
it("should return the commit if it exists") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.commit(withIdentity: oid)
let result = repo.commit(oid)
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
}
@ -155,7 +155,7 @@ class RepositorySpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.commit(withIdentity: oid)
let result = repo.commit(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
}
@ -164,17 +164,17 @@ class RepositorySpec: QuickSpec {
// This is a tree in the repository
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.commit(withIdentity: oid)
let result = repo.commit(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
}
}
describe("Repository.tag(withIdentity:)") {
describe("Repository.tag(_:)") {
it("should return the tag if it exists") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let result = repo.tag(withIdentity: oid)
let result = repo.tag(oid)
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
}
@ -182,7 +182,7 @@ class RepositorySpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.tag(withIdentity: oid)
let result = repo.tag(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
}
@ -191,17 +191,17 @@ class RepositorySpec: QuickSpec {
// This is a commit in the repository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.tag(withIdentity: oid)
let result = repo.tag(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
}
}
describe("Repository.tree(withIdentity:)") {
describe("Repository.tree(_:)") {
it("should return the tree if it exists") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let result = repo.tree(withIdentity: oid)
let result = repo.tree(oid)
expect(result.map { $0.oid }).to(haveSucceeded(equal(oid)))
}
@ -209,7 +209,7 @@ class RepositorySpec: QuickSpec {
let repo = Fixtures.simpleRepository
let oid = OID(string: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")!
let result = repo.tree(withIdentity: oid)
let result = repo.tree(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
}
@ -218,48 +218,48 @@ class RepositorySpec: QuickSpec {
// This is a commit in the repository
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let result = repo.tree(withIdentity: oid)
let result = repo.tree(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
}
}
describe("Repository.object(withIdentity:)") {
describe("Repository.object(_:)") {
it("should work with a blob") {
let repo = Fixtures.simpleRepository
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let blob = repo.blob(withIdentity: oid).value
let result = repo.object(withIdentity: oid)
let blob = repo.blob(oid).value
let result = repo.object(oid)
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.commit(withIdentity: oid).value
let result = repo.object(withIdentity: oid)
let commit = repo.commit(oid).value
let result = repo.object(oid)
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.tag(withIdentity: oid).value
let result = repo.object(withIdentity: oid)
let tag = repo.tag(oid).value
let result = repo.object(oid)
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.tree(withIdentity: oid).value
let result = repo.object(withIdentity: oid)
let tree = repo.tree(oid).value
let result = repo.object(oid)
expect(result.map { $0 as! Tree }).to(haveSucceeded(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.object(withIdentity: oid)
let result = repo.object(oid)
expect(result).to(haveFailed(beAnError(domain: equal(libGit2ErrorDomain))))
}
}
@ -270,7 +270,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let pointer = PointerTo<Commit>(oid)
let commit = repo.commit(withIdentity: oid).value!
let commit = repo.commit(oid).value!
expect(repo.object(from: pointer)).to(haveSucceeded(equal(commit)))
}
@ -279,7 +279,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let pointer = PointerTo<Tree>(oid)
let tree = repo.tree(withIdentity: oid).value!
let tree = repo.tree(oid).value!
expect(repo.object(from: pointer)).to(haveSucceeded(equal(tree)))
}
@ -288,7 +288,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let pointer = PointerTo<Blob>(oid)
let blob = repo.blob(withIdentity: oid).value!
let blob = repo.blob(oid).value!
expect(repo.object(from: pointer)).to(haveSucceeded(equal(blob)))
}
@ -297,7 +297,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let pointer = PointerTo<Tag>(oid)
let tag = repo.tag(withIdentity: oid).value!
let tag = repo.tag(oid).value!
expect(repo.object(from: pointer)).to(haveSucceeded(equal(tag)))
}
}
@ -308,7 +308,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!
let pointer = Pointer.Commit(oid)
let commit = repo.commit(withIdentity: oid).value!
let commit = repo.commit(oid).value!
let result = repo.object(from: pointer).map { $0 as! Commit }
expect(result).to(haveSucceeded(equal(commit)))
}
@ -318,7 +318,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "f93e3a1a1525fb5b91020da86e44810c87a2d7bc")!
let pointer = Pointer.Tree(oid)
let tree = repo.tree(withIdentity: oid).value!
let tree = repo.tree(oid).value!
let result = repo.object(from: pointer).map { $0 as! Tree }
expect(result).to(haveSucceeded(equal(tree)))
}
@ -328,7 +328,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
let pointer = Pointer.Blob(oid)
let blob = repo.blob(withIdentity: oid).value!
let blob = repo.blob(oid).value!
let result = repo.object(from: pointer).map { $0 as! Blob }
expect(result).to(haveSucceeded(equal(blob)))
}
@ -338,7 +338,7 @@ class RepositorySpec: QuickSpec {
let oid = OID(string: "57943b8ee00348180ceeedc960451562750f6d33")!
let pointer = Pointer.Tag(oid)
let tag = repo.tag(withIdentity: oid).value!
let tag = repo.tag(oid).value!
let result = repo.object(from: pointer).map { $0 as! Tag }
expect(result).to(haveSucceeded(equal(tag)))
}