mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Use Int32 for tree entry attributes
This commit is contained in:
parent
51b34f9ad0
commit
2a9f0aefa0
@ -148,7 +148,7 @@ public struct Tree: Object {
|
||||
/// An entry in a `Tree`.
|
||||
public struct Entry {
|
||||
/// The entry's UNIX file attributes.
|
||||
public let attributes: Int
|
||||
public let attributes: Int32
|
||||
|
||||
/// The type of object pointed to by the entry.
|
||||
public let type: ObjectType
|
||||
@ -161,14 +161,14 @@ public struct Tree: Object {
|
||||
|
||||
/// Create an instance with a libgit2 `git_tree_entry`.
|
||||
public init(_ pointer: COpaquePointer) {
|
||||
attributes = Int(git_tree_entry_filemode(pointer).value)
|
||||
attributes = Int32(git_tree_entry_filemode(pointer).value)
|
||||
type = ObjectType.fromLibgit2Type(git_tree_entry_type(pointer))!
|
||||
oid = OID(git_tree_entry_id(pointer).memory)
|
||||
name = String.fromCString(git_tree_entry_name(pointer))!
|
||||
}
|
||||
|
||||
/// Create an instance with the individual values.
|
||||
public init(attributes: Int, type: ObjectType, oid: OID, name: String) {
|
||||
public init(attributes: Int32, type: ObjectType, oid: OID, name: String) {
|
||||
self.attributes = attributes
|
||||
self.type = type
|
||||
self.oid = oid
|
||||
@ -197,7 +197,7 @@ public struct Tree: Object {
|
||||
|
||||
extension Tree.Entry: Hashable {
|
||||
public var hashValue: Int {
|
||||
return attributes ^ oid.hashValue ^ name.hashValue
|
||||
return Int(attributes) ^ oid.hashValue ^ name.hashValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -171,7 +171,7 @@ class TreeEntrySpec: QuickSpec {
|
||||
override func spec() {
|
||||
describe("init(attributes:type:oid:name:)") {
|
||||
it("should set its properties") {
|
||||
let attributes = Int(GIT_FILEMODE_BLOB.value)
|
||||
let attributes = Int32(GIT_FILEMODE_BLOB.value)
|
||||
let type = ObjectType.Blob
|
||||
let oid = OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!
|
||||
let name = "README.md"
|
||||
@ -190,7 +190,7 @@ class TreeEntrySpec: QuickSpec {
|
||||
let oid = OID(string: "219e9f39c2fb59ed1dfb3e78ed75055a57528f31")!
|
||||
|
||||
let entry = from_git_object(repo, oid) { Tree.Entry(git_tree_entry_byindex($0, 0)) }
|
||||
expect(entry.attributes).to(equal(Int(GIT_FILEMODE_BLOB.value)))
|
||||
expect(entry.attributes).to(equal(Int32(GIT_FILEMODE_BLOB.value)))
|
||||
expect(entry.type).to(equal(ObjectType.Blob))
|
||||
expect(entry.oid).to(equal(OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")))
|
||||
expect(entry.name).to(equal("README.md"))
|
||||
@ -240,7 +240,7 @@ class TreeSpec: QuickSpec {
|
||||
|
||||
let tree = from_git_object(repo, oid) { Tree($0) }
|
||||
let entries = [
|
||||
"README.md": Tree.Entry(attributes: Int(GIT_FILEMODE_BLOB.value), type: .Blob, oid: OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!, name: "README.md"),
|
||||
"README.md": Tree.Entry(attributes: Int32(GIT_FILEMODE_BLOB.value), type: .Blob, oid: OID(string: "41078396f5187daed5f673e4a13b185bbad71fba")!, name: "README.md"),
|
||||
]
|
||||
expect(tree.entries).to(equal(entries))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user