Skip to content

Tweaks #587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add isTag/isBranch/isNote to GTReference
  • Loading branch information
tiennou committed Nov 26, 2017
commit 455973eb2c527b250df12a90cce41e1a4a6966ac
9 changes: 9 additions & 0 deletions ObjectiveGit/GTReference.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) const git_oid *git_oid;
@property (nonatomic, strong, readonly) GTOID * _Nullable OID;

/// Whether this is a tag.
@property (nonatomic, readonly, getter = isTag) BOOL tag;

/// Whether this is a local branch.
@property (nonatomic, readonly, getter = isBranch) BOOL branch;

/// Whether this is a remote-tracking branch.
@property (nonatomic, readonly, getter = isRemote) BOOL remote;

/// Whether this is a note ref.
@property (nonatomic, readonly, getter = isNote) BOOL note;

/// The reflog for the reference.
@property (nonatomic, readonly, strong) GTReflog *reflog;

Expand Down
12 changes: 12 additions & 0 deletions ObjectiveGit/GTReference.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ - (instancetype)initWithGitReference:(git_reference *)ref repository:(GTReposito
return self;
}

- (BOOL)isBranch {
return git_reference_is_branch(self.git_reference) != 0;
}

- (BOOL)isTag {
return git_reference_is_tag(self.git_reference) != 0;
}

- (BOOL)isNote {
return git_reference_is_note(self.git_reference) != 0;
}

- (NSString *)name {
const char *refName = git_reference_name(self.git_reference);
if (refName == NULL) return nil;
Expand Down