Permalink
Browse files

commitsViewController works now

  • Loading branch information...
1 parent 973c0a8 commit 74b390e467587845a81a351e69721dff3ee7e932 @schacon committed Dec 15, 2009
Showing with 38 additions and 6 deletions.
  1. +2 −0 CocoaGit/GITRepo.h
  2. +29 −0 CocoaGit/GITRepo.m
  3. +7 −6 Controllers/CommitsViewController.m
View
@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#import "GITObject.h"
+#import "GITGraph.h"
@class GITObjectStore, GITRefStore;
@class GITObject, GITCommit, GITTree, GITTag, GITBlob;
@@ -220,6 +221,7 @@
- (BOOL) updateRef:(NSString *)refName toSha:(NSString *)toSha;
- (BOOL) updateRef:(NSString *)refName toSha:(NSString *)toSha error:(NSError **)error;
+- (NSArray*) getCommitsFromCommit:(NSString *)targetString withLimit:(int)limit;
- (BOOL) writeObject:(NSData *)objectData withType:(NSString *)type;
View
@@ -325,6 +325,35 @@ - (NSDictionary *) dictionaryWithRefName:(NSString *) aName sha:(NSString *) sha
shaString, @"sha", nil];
}
+- (NSArray*) getCommitsFromCommit:(NSString *)targetString withLimit:(int)limit
+{
+ NSLog(@"FU");
+
+ NSError *commitError = nil;
+ GITCommit *commit;
+ if ( isSha1StringValid(targetString) ) {
+ commit = [self commitWithSha1:targetString error:&commitError];
+ } else {
+ if ( [targetString isEqual:@"HEAD"] ) {
+ commit = [self head];
+ } else {
+ GITRef *ref = [self branchWithName:targetString];
+ if ( ref )
+ commit = [self commitWithSha1:[ref sha1] error:&commitError];
+ }
+ }
+
+ NSLog(@"Commit Gathered");
+
+ GITGraph *g = [[GITGraph alloc] init];
+ [g buildGraphWithStartingCommit:commit];
+
+ NSArray *sorted;
+ sorted = [g nodesSortedByTopology:1];
+
+ return sorted;
+}
+
- (BOOL) updateRef:(NSString *)refName toSha:(NSString *)toSha
{
return [self updateRef:refName toSha:toSha error:nil];
@@ -27,8 +27,9 @@ - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// load data
- NSLog(@"Data load");
- self.commitList = [gitRepo getCommitsFromSha:gitSha withLimit:30];
+ NSLog(@"Data load from [%@]", gitSha);
+ self.commitList = [gitRepo getCommitsFromCommit:gitSha withLimit:30];
+ NSLog(@"Data [%@]", self.commitList);
// Scroll the table view to the top before it appears
[self.tableView reloadData];
@@ -75,19 +76,19 @@ - (void)configureCell:(UITableViewCell *)cell forIndexPath:(NSIndexPath *)indexP
[dateFormatter setDateFormat:@"MMM dd YY, kk:ss"]; // Sept 5 08:30
}
- ObjGitCommit *commit = [self.commitList objectAtIndex:indexPath.row];
+ GITCommit *commit = [[self.commitList objectAtIndex:indexPath.row] object];
UILabel *label;
// Get the time zone wrapper for the row
label = (UILabel *)[cell viewWithTag:ONE_TAG];
- label.text = [[commit sha] substringToIndex:6];
+ label.text = [[commit sha1] substringToIndex:6];
label = (UILabel *)[cell viewWithTag:TWO_TAG];
- label.text = [commit author];
+ label.text = [[commit author] name];
label = (UILabel *)[cell viewWithTag:THR_TAG];
- label.text = [dateFormatter stringFromDate:[commit authored_date]];
+ label.text = [dateFormatter stringFromDate:[[commit authored] date]];
label = (UILabel *)[cell viewWithTag:FOUR_TAG];
label.text = [commit message];

0 comments on commit 74b390e

Please sign in to comment.