forked from geoffgarside/cocoagit
-
Notifications
You must be signed in to change notification settings - Fork 2
/
GITBranch.m
42 lines (36 loc) · 968 Bytes
/
GITBranch.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// GITBranch.m
// CocoaGit
//
// Created by Geoffrey Garside on 05/08/2008.
// Copyright 2008 ManicPanda.com. All rights reserved.
//
#import "GITBranch.h"
#import "GITRepo.h"
#import "GITCommit.h"
/*! \cond
Make properties readwrite so we can use
them within the class.
*/
@interface GITBranch ()
@property(readwrite,retain) GITRepo * repo;
@property(readwrite,copy) NSString * name;
@end
/*! \endcond */
@implementation GITBranch
@synthesize repo;
@synthesize name;
- (void) dealloc
{
[repo release], repo = nil;
[name release], name = nil;
[super dealloc];
}
- (GITCommit*)head
{
NSString * heads = [self.repo.root stringByAppendingPathComponent:@"refs/heads"];
NSString * file = [heads stringByAppendingPathComponent:self.name];
NSString * ref = [[NSString stringWithContentsOfFile:file] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
return [self.repo commitWithSha1:ref];
}
@end