From 046d67ed970914569bae9eea70ea9d7bdcfbdf22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jake=20Van=20Alstyne=20=F0=9F=8E=A9?= Date: Fri, 1 Sep 2017 17:16:25 -0600 Subject: [PATCH] use the DiffFlag struct instead of a UInt32 --- SwiftGit2/Diffs.swift | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/SwiftGit2/Diffs.swift b/SwiftGit2/Diffs.swift index f5ad967..d5e46d0 100644 --- a/SwiftGit2/Diffs.swift +++ b/SwiftGit2/Diffs.swift @@ -44,9 +44,23 @@ public struct Status: OptionSet { static let conflicted = Status(rawValue: 1 << 12) } +public struct DiffFlag: OptionSet { + // This appears to be necessary due to bug in Swift + // https://bugs.swift.org/browse/SR-3003 + public init(rawValue: UInt32) { + self.rawValue = rawValue + } + public let rawValue: UInt32 + + static let binary = DiffFlag(rawValue: 0) + static let notBinary = DiffFlag(rawValue: 1 << 0) + static let validId = DiffFlag(rawValue: 1 << 1) + static let exists = DiffFlag(rawValue: 1 << 2) +} + public struct DiffDelta { public var status: Status? - public var flags: UInt32? + public var flags: DiffFlag? public var oldFile: DiffFile? public var newFile: DiffFile? @@ -64,7 +78,7 @@ public struct DiffDelta { } else { self.status = DiffDelta.convertStatus(diffDelta.status.rawValue) } - self.flags = diffDelta.flags + self.flags = DiffFlag(rawValue: diffDelta.flags) self.oldFile = self.convertDiffFile(diffDelta.old_file) self.newFile = self.convertDiffFile(diffDelta.new_file) } @@ -110,17 +124,3 @@ public struct DiffDelta { return newFile } } - -public struct DiffFlag: OptionSet { - // This appears to be necessary due to bug in Swift - // https://bugs.swift.org/browse/SR-3003 - public init(rawValue: UInt32) { - self.rawValue = rawValue - } - public let rawValue: UInt32 - - static let binary = DiffFlag(rawValue: 0) - static let notBinary = DiffFlag(rawValue: 1 << 0) - static let validId = DiffFlag(rawValue: 1 << 1) - static let exists = DiffFlag(rawValue: 1 << 2) -}