mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Rename Object to Pointer
This commit is contained in:
parent
f7e910fd36
commit
1df50f196c
@ -8,8 +8,8 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// The types of git objects.
|
||||
public enum Object {
|
||||
/// A pointer to a git object.
|
||||
public enum Pointer {
|
||||
case Commit(OID)
|
||||
case Tree(OID)
|
||||
case Blob(OID)
|
||||
@ -44,13 +44,13 @@ public enum Object {
|
||||
}
|
||||
}
|
||||
|
||||
extension Object: Hashable {
|
||||
extension Pointer: Hashable {
|
||||
public var hashValue: Int {
|
||||
return oid.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
extension Object: Printable {
|
||||
extension Pointer: Printable {
|
||||
public var description: String {
|
||||
switch self {
|
||||
case Commit:
|
||||
@ -65,7 +65,7 @@ extension Object: Printable {
|
||||
}
|
||||
}
|
||||
|
||||
public func == (lhs: Object, rhs: Object) -> Bool {
|
||||
public func == (lhs: Pointer, rhs: Pointer) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (.Commit, .Commit), (.Tree, .Tree), (.Blob, .Blob), (.Tag, .Tag):
|
||||
return lhs.oid == rhs.oid
|
||||
@ -167,7 +167,7 @@ public struct Tree: ObjectType {
|
||||
public let attributes: Int32
|
||||
|
||||
/// The object pointed to by the entry.
|
||||
public let object: Object
|
||||
public let object: Pointer
|
||||
|
||||
/// The file name of the entry.
|
||||
public let name: String
|
||||
@ -176,12 +176,12 @@ public struct Tree: ObjectType {
|
||||
public init(_ pointer: COpaquePointer) {
|
||||
let oid = OID(git_tree_entry_id(pointer).memory)
|
||||
attributes = Int32(git_tree_entry_filemode(pointer).value)
|
||||
object = Object(oid: oid, type: git_tree_entry_type(pointer))!
|
||||
object = Pointer(oid: oid, type: git_tree_entry_type(pointer))!
|
||||
name = String.fromCString(git_tree_entry_name(pointer))!
|
||||
}
|
||||
|
||||
/// Create an instance with the individual values.
|
||||
public init(attributes: Int32, object: Object, name: String) {
|
||||
public init(attributes: Int32, object: Pointer, name: String) {
|
||||
self.attributes = attributes
|
||||
self.object = object
|
||||
self.name = name
|
||||
@ -261,7 +261,7 @@ public struct Tag: ObjectType {
|
||||
public let oid: OID
|
||||
|
||||
/// The tagged object.
|
||||
public let target: Object
|
||||
public let target: Pointer
|
||||
|
||||
/// The name of the tag.
|
||||
public let name: String
|
||||
@ -276,7 +276,7 @@ public struct Tag: ObjectType {
|
||||
public init(_ pointer: COpaquePointer) {
|
||||
oid = OID(git_object_id(pointer).memory)
|
||||
let targetOID = OID(git_tag_target_id(pointer).memory)
|
||||
target = Object(oid: targetOID, type: git_tag_target_type(pointer))!
|
||||
target = Pointer(oid: targetOID, type: git_tag_target_type(pointer))!
|
||||
name = String.fromCString(git_tag_name(pointer))!
|
||||
tagger = Signature(git_tag_tagger(pointer).memory)
|
||||
message = String.fromCString(git_tag_message(pointer))!
|
||||
|
||||
@ -172,7 +172,7 @@ class TreeEntrySpec: QuickSpec {
|
||||
describe("init(attributes:object:name:)") {
|
||||
it("should set its properties") {
|
||||
let attributes = Int32(GIT_FILEMODE_BLOB.value)
|
||||
let object = Object.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
|
||||
let object = Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)
|
||||
let name = "README.md"
|
||||
|
||||
let entry = Tree.Entry(attributes: attributes, object: object, name: name)
|
||||
@ -189,7 +189,7 @@ class TreeEntrySpec: QuickSpec {
|
||||
|
||||
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)))
|
||||
expect(entry.object).to(equal(Object.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
|
||||
expect(entry.object).to(equal(Pointer.Blob(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!)))
|
||||
expect(entry.name).to(equal("README.md"))
|
||||
}
|
||||
}
|
||||
@ -337,7 +337,7 @@ class TagSpec: QuickSpec {
|
||||
let tagger = from_git_object(repo, oid) { Signature(git_tag_tagger($0).memory) }
|
||||
|
||||
expect(tag.oid).to(equal(oid))
|
||||
expect(tag.target).to(equal(Object.Commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
|
||||
expect(tag.target).to(equal(Pointer.Commit(OID(string: "dc220a3f0c22920dab86d4a8d3a3cb7e69d6205a")!)))
|
||||
expect(tag.name).to(equal("tag-1"))
|
||||
expect(tag.tagger).to(equal(tagger))
|
||||
expect(tag.message).to(equal("tag-1\n"))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user