Skip to content

Commit 455973e

Browse files
committed
Add isTag/isBranch/isNote to GTReference
1 parent 6cf61d0 commit 455973e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

ObjectiveGit/GTReference.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@ NS_ASSUME_NONNULL_BEGIN
5454
@property (nonatomic, readonly) const git_oid *git_oid;
5555
@property (nonatomic, strong, readonly) GTOID * _Nullable OID;
5656

57+
/// Whether this is a tag.
58+
@property (nonatomic, readonly, getter = isTag) BOOL tag;
59+
60+
/// Whether this is a local branch.
61+
@property (nonatomic, readonly, getter = isBranch) BOOL branch;
62+
5763
/// Whether this is a remote-tracking branch.
5864
@property (nonatomic, readonly, getter = isRemote) BOOL remote;
5965

66+
/// Whether this is a note ref.
67+
@property (nonatomic, readonly, getter = isNote) BOOL note;
68+
6069
/// The reflog for the reference.
6170
@property (nonatomic, readonly, strong) GTReflog *reflog;
6271

ObjectiveGit/GTReference.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ - (instancetype)initWithGitReference:(git_reference *)ref repository:(GTReposito
105105
return self;
106106
}
107107

108+
- (BOOL)isBranch {
109+
return git_reference_is_branch(self.git_reference) != 0;
110+
}
111+
112+
- (BOOL)isTag {
113+
return git_reference_is_tag(self.git_reference) != 0;
114+
}
115+
116+
- (BOOL)isNote {
117+
return git_reference_is_note(self.git_reference) != 0;
118+
}
119+
108120
- (NSString *)name {
109121
const char *refName = git_reference_name(self.git_reference);
110122
if (refName == NULL) return nil;

0 commit comments

Comments
 (0)