mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Add isLocal and isRemote to Branch
This commit is contained in:
parent
910b9b35d2
commit
67d44d96d1
@ -73,6 +73,12 @@ public struct Branch: ReferenceType {
|
|||||||
/// This is the same as `commit.oid`, but is declared here to adhere to `ReferenceType`.
|
/// This is the same as `commit.oid`, but is declared here to adhere to `ReferenceType`.
|
||||||
public var oid: OID { return commit.oid }
|
public var oid: OID { return commit.oid }
|
||||||
|
|
||||||
|
/// Whether the branch is a local branch.
|
||||||
|
public var isLocal: Bool { return longName.hasPrefix("refs/heads/") }
|
||||||
|
|
||||||
|
/// Whether the branch is a remote branch.
|
||||||
|
public var isRemote: Bool { return longName.hasPrefix("refs/remotes/") }
|
||||||
|
|
||||||
/// Create an instance with a libgit2 `git_reference` object.
|
/// Create an instance with a libgit2 `git_reference` object.
|
||||||
///
|
///
|
||||||
/// Returns `nil` if the pointer isn't a branch.
|
/// Returns `nil` if the pointer isn't a branch.
|
||||||
|
|||||||
@ -73,6 +73,8 @@ class BranchSpec: QuickSpec {
|
|||||||
expect(branch.shortName).to(equal(branch.name))
|
expect(branch.shortName).to(equal(branch.name))
|
||||||
expect(branch.commit.oid).to(equal(OID(string: "f797bd4837b61d37847a4833024aab268599a681")!))
|
expect(branch.commit.oid).to(equal(OID(string: "f797bd4837b61d37847a4833024aab268599a681")!))
|
||||||
expect(branch.oid).to(equal(branch.commit.oid))
|
expect(branch.oid).to(equal(branch.commit.oid))
|
||||||
|
expect(branch.isLocal).to(beTrue())
|
||||||
|
expect(branch.isRemote).to(beFalse())
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should work with symoblic refs") {
|
it("should work with symoblic refs") {
|
||||||
@ -83,6 +85,8 @@ class BranchSpec: QuickSpec {
|
|||||||
expect(branch.shortName).to(equal(branch.name))
|
expect(branch.shortName).to(equal(branch.name))
|
||||||
expect(branch.commit.oid).to(equal(OID(string: "f797bd4837b61d37847a4833024aab268599a681")!))
|
expect(branch.commit.oid).to(equal(OID(string: "f797bd4837b61d37847a4833024aab268599a681")!))
|
||||||
expect(branch.oid).to(equal(branch.commit.oid))
|
expect(branch.oid).to(equal(branch.commit.oid))
|
||||||
|
expect(branch.isLocal).to(beFalse())
|
||||||
|
expect(branch.isRemote).to(beTrue())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user