mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Define equality generically for all ReferenceTypes
This commit is contained in:
parent
a0f76f6c26
commit
4368756bbb
@ -18,6 +18,11 @@ public protocol ReferenceType {
|
||||
var oid: OID { get }
|
||||
}
|
||||
|
||||
public func ==<T: ReferenceType>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs.longName == rhs.longName
|
||||
&& lhs.oid == rhs.oid
|
||||
}
|
||||
|
||||
/// A generic reference to a git object.
|
||||
public struct Reference: ReferenceType {
|
||||
/// The full name of the reference (e.g., `refs/heads/master`).
|
||||
@ -44,11 +49,6 @@ extension Reference: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
public func == (lhs: Reference, rhs: Reference) -> Bool {
|
||||
return lhs.longName == rhs.longName
|
||||
&& lhs.oid == rhs.oid
|
||||
}
|
||||
|
||||
/// A git branch.
|
||||
public struct Branch: ReferenceType {
|
||||
/// The full name of the reference (e.g., `refs/heads/master`).
|
||||
@ -97,11 +97,6 @@ extension Branch: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
public func == (lhs: Branch, rhs: Branch) -> Bool {
|
||||
return lhs.longName == rhs.longName
|
||||
&& lhs.oid == rhs.oid
|
||||
}
|
||||
|
||||
/// A git tag reference, which can be either a lightweight tag or a Tag object.
|
||||
public enum TagReference: ReferenceType {
|
||||
/// A lightweight tag, which is just a name and an OID.
|
||||
@ -175,8 +170,3 @@ extension TagReference: Hashable {
|
||||
}
|
||||
}
|
||||
|
||||
public func == (lhs: TagReference, rhs: TagReference) -> Bool {
|
||||
return lhs.longName == rhs.longName
|
||||
&& lhs.oid == rhs.oid
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user