Skip to content

Give GTTag Some Love #253

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 13 commits into from
Sep 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
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
22 changes: 14 additions & 8 deletions Classes/GTTag.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,27 @@
// THE SOFTWARE.
//


#import "GTObject.h"

@class GTSignature;
@class GTRepository;


@interface GTTag : GTObject {}

// The author of the tag.
@property (nonatomic, readonly, strong) GTSignature *tagger;

// The underlying `git_object` as a `git_tag` object.
- (git_tag *)git_tag __attribute__((objc_returns_inner_pointer));
// The description given when the tag was created.
@property (nonatomic, readonly, strong) NSString *message;

// The label of the tag. Generally a version number.
@property (nonatomic, readonly, strong) NSString *name;

- (NSString *)message;
- (NSString *)name;
- (GTObject *)target;
- (NSString *)targetType;
// The 'tagged' object.
@property (nonatomic, readonly, strong) GTObject *target;

// The type of the 'tagged' object.
@property (nonatomic, readonly) GTObjectType targetType;

// Recursively peel a tag until a non tag GTObject is found
//
Expand All @@ -54,4 +57,7 @@
// Returns the found object or nil on error.
- (id)objectByPeelingTagError:(NSError **)error;

// The underlying `git_object` as a `git_tag` object.
- (git_tag *)git_tag __attribute__((objc_returns_inner_pointer));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this whitespace is unnecessary.

@end
16 changes: 7 additions & 9 deletions Classes/GTTag.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,28 @@
@implementation GTTag

- (NSString *)description {
return [NSString stringWithFormat:@"<%@: %p> name: %@, message: %@, targetType: %@", NSStringFromClass([self class]), self, [self name], [self message], [self targetType]];
return [NSString stringWithFormat:@"<%@: %p> name: %@, message: %@, targetType: %d", NSStringFromClass([self class]), self,self.name, self.message, self.targetType];
}


#pragma mark API

- (NSString *)message {
return [NSString stringWithUTF8String:git_tag_message(self.git_tag)];
return @(git_tag_message(self.git_tag));
}

- (NSString *)name {
return [NSString stringWithUTF8String:git_tag_name(self.git_tag)];
return @(git_tag_name(self.git_tag));
}

- (GTObject *)target {
git_object *t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we fix the rogue spacing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't see it. :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's a tabs vs spaces issue. Looks like this used to use spaces at some point.

// todo: might want to actually return an error here
int gitError = git_tag_target(&t, self.git_tag);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More weird legacy spacing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure here either.

if(gitError < GIT_OK) return nil;
return [GTObject objectWithObj:(git_object *)t inRepository:self.repository];
if (gitError < GIT_OK) return nil;
return [GTObject objectWithObj:(git_object *)t inRepository:self.repository];
}

- (NSString *)targetType {
return [NSString stringWithUTF8String:git_object_type2string(git_tag_target_type(self.git_tag))];
- (GTObjectType)targetType {
return (GTObjectType)git_tag_target_type(self.git_tag);
}

- (GTSignature *)tagger {
Expand Down
8 changes: 4 additions & 4 deletions ObjectiveGitFramework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
04DB466E133AB5EB00D9C624 /* GTReference.m in Sources */ = {isa = PBXBuildFile; fileRef = BD441E07131ED0C300187010 /* GTReference.m */; };
04DB466F133AB5EB00D9C624 /* GTBranch.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F50F57132054D800584FBE /* GTBranch.m */; };
04DB4672133AB5FE00D9C624 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 04DB4671133AB5FE00D9C624 /* libz.dylib */; };
2089E43C17D9A58000F451DA /* GTTagSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 2089E43B17D9A58000F451DA /* GTTagSpec.m */; };
3011D86B1668E48500CE3409 /* GTDiffFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 3011D8691668E48500CE3409 /* GTDiffFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
3011D86C1668E48500CE3409 /* GTDiffFile.h in Headers */ = {isa = PBXBuildFile; fileRef = 3011D8691668E48500CE3409 /* GTDiffFile.h */; settings = {ATTRIBUTES = (Public, ); }; };
3011D86D1668E48500CE3409 /* GTDiffFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 3011D86A1668E48500CE3409 /* GTDiffFile.m */; };
Expand Down Expand Up @@ -161,7 +162,6 @@
88F05ABA16011FFD00B7AD1D /* GTReferenceTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F05AA916011FFD00B7AD1D /* GTReferenceTest.m */; };
88F05ABB16011FFD00B7AD1D /* GTRepositoryPackTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F05AAA16011FFD00B7AD1D /* GTRepositoryPackTest.m */; };
88F05ABC16011FFD00B7AD1D /* GTRepositoryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F05AAB16011FFD00B7AD1D /* GTRepositoryTest.m */; };
88F05ABD16011FFD00B7AD1D /* GTTagTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F05AAC16011FFD00B7AD1D /* GTTagTest.m */; };
88F05AC41601204200B7AD1D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 88F05A7816011E5400B7AD1D /* InfoPlist.strings */; };
88F05AC61601209A00B7AD1D /* ObjectiveGit.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F05AC51601209A00B7AD1D /* ObjectiveGit.m */; };
88F05AC716012CE500B7AD1D /* NSString+Git.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C8057313874CDF004DCB0F /* NSString+Git.m */; };
Expand Down Expand Up @@ -342,6 +342,7 @@
0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
2089E43B17D9A58000F451DA /* GTTagSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTTagSpec.m; sourceTree = "<group>"; };
3011D8691668E48500CE3409 /* GTDiffFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTDiffFile.h; sourceTree = "<group>"; };
3011D86A1668E48500CE3409 /* GTDiffFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTDiffFile.m; sourceTree = "<group>"; };
3011D86F1668E78500CE3409 /* GTDiffHunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTDiffHunk.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -407,7 +408,6 @@
88F05AA916011FFD00B7AD1D /* GTReferenceTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTReferenceTest.m; sourceTree = "<group>"; };
88F05AAA16011FFD00B7AD1D /* GTRepositoryPackTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTRepositoryPackTest.m; sourceTree = "<group>"; };
88F05AAB16011FFD00B7AD1D /* GTRepositoryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTRepositoryTest.m; sourceTree = "<group>"; };
88F05AAC16011FFD00B7AD1D /* GTTagTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTTagTest.m; sourceTree = "<group>"; };
88F05AAF16011FFD00B7AD1D /* ObjectiveGitTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ObjectiveGitTests-Info.plist"; sourceTree = "<group>"; };
88F05AC51601209A00B7AD1D /* ObjectiveGit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ObjectiveGit.m; path = Classes/ObjectiveGit.m; sourceTree = "<group>"; };
88F05AC91601335C00B7AD1D /* Specta.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Specta.xcodeproj; path = specta/Specta.xcodeproj; sourceTree = "<group>"; };
Expand Down Expand Up @@ -640,7 +640,7 @@
D0AC906B172F941F00347DC4 /* GTRepositorySpec.m */,
88F05AAB16011FFD00B7AD1D /* GTRepositoryTest.m */,
D03B7C401756AB370034A610 /* GTSubmoduleSpec.m */,
88F05AAC16011FFD00B7AD1D /* GTTagTest.m */,
2089E43B17D9A58000F451DA /* GTTagSpec.m */,
88A994C916FCED1D00402C7B /* GTTestCase.h */,
88A994CA16FCED1D00402C7B /* GTTestCase.m */,
30B1E7FF1703871900D0814D /* GTTimeAdditionsSpec.m */,
Expand Down Expand Up @@ -1217,9 +1217,9 @@
88F05ABA16011FFD00B7AD1D /* GTReferenceTest.m in Sources */,
88F05ABB16011FFD00B7AD1D /* GTRepositoryPackTest.m in Sources */,
88F05ABC16011FFD00B7AD1D /* GTRepositoryTest.m in Sources */,
88F05ABD16011FFD00B7AD1D /* GTTagTest.m in Sources */,
30865A91167F503400B1AB6E /* GTDiffSpec.m in Sources */,
88A994BA16FCE7D400402C7B /* GTBranchSpec.m in Sources */,
2089E43C17D9A58000F451DA /* GTTagSpec.m in Sources */,
88A994CB16FCED1D00402C7B /* GTTestCase.m in Sources */,
30B1E8001703871900D0814D /* GTTimeAdditionsSpec.m in Sources */,
88C0BC5917038CF3009E99AA /* GTConfigurationSpec.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion ObjectiveGitTests/GTRepositorySpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
expect(tag.message).to.equal(@"my tag\n");
expect(tag.name).to.equal(@"a_new_tag");
expect(tag.target.SHA).to.equal(@"5b5b025afb0b4c913b4c338a42934a3863bf3644");
expect(tag.targetType).to.equal(@"commit");
expect(tag.targetType).to.equal(GTObjectTypeCommit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍


rm_loose(self.class, newOID.SHA);
NSFileManager *m = [[NSFileManager alloc] init];
Expand Down
38 changes: 38 additions & 0 deletions ObjectiveGitTests/GTTagSpec.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// GTOIDSpec.m
// ObjectiveGitFramework
//
// Created by Ezekiel Pierson on 2013-09-06.
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import "GTTag.h"

SpecBegin(GTTag)

__block GTTag *tag;

beforeEach(^{
NSError *error = nil;
GTRepository *repo = [GTRepository repositoryWithURL:[NSURL fileURLWithPath:TEST_REPO_PATH(self.class)] error:&error];
NSString *tagSHA = @"0c37a5391bbff43c37f0d0371823a5509eed5b1d";
tag = (GTTag *)[repo lookupObjectBySHA:tagSHA error:&error];
expect(error).to.beFalsy;
expect(tag).to.beTruthy;
expect(tagSHA).to.equal(tag.SHA);
});

it(@"can read tag data", ^{
expect(tag.type).to.equal(@"tag");
expect(tag.name).to.equal(@"v1.0");
expect(tag.message).to.equal(@"test tag message\n");
expect(tag.target.SHA).to.equal(@"5b5b025afb0b4c913b4c338a42934a3863bf3644");
expect(GTObjectTypeCommit).to.equal(tag.targetType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the above comparisons are the wrong way round.


GTSignature *signature = tag.tagger;
expect(signature.name).to.equal(@"Scott Chacon");
expect((int)[signature.time timeIntervalSince1970]).to.equal(1288114383);
expect(signature.email).to.equal(@"[email protected]");
});

SpecEnd
57 changes: 0 additions & 57 deletions ObjectiveGitTests/GTTagTest.m

This file was deleted.