mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add a Tree displayer
This displays the tree of a specific commit in an NSBrowser.
This commit is contained in:
+970
-883
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
@@ -15,6 +15,7 @@
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||
F561727F0E056A11001DCD79 /* diff_style.css in Resources */ = {isa = PBXBuildFile; fileRef = F561727C0E056A11001DCD79 /* diff_style.css */; };
|
||||
F56173280E056ED2001DCD79 /* diffHighlighter.js in Resources */ = {isa = PBXBuildFile; fileRef = F56173270E056ED2001DCD79 /* diffHighlighter.js */; };
|
||||
F56174570E058893001DCD79 /* PBGitTree.m in Sources */ = {isa = PBXBuildFile; fileRef = F56174560E058893001DCD79 /* PBGitTree.m */; };
|
||||
F56524BB0E02D22D00F03B52 /* NSFileHandleExt.m in Sources */ = {isa = PBXBuildFile; fileRef = F56524B90E02D22D00F03B52 /* NSFileHandleExt.m */; };
|
||||
F56524F00E02D45200F03B52 /* PBGitCommit.m in Sources */ = {isa = PBXBuildFile; fileRef = F56524EF0E02D45200F03B52 /* PBGitCommit.m */; };
|
||||
F56526240E03D85900F03B52 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F56526230E03D85900F03B52 /* WebKit.framework */; };
|
||||
@@ -42,6 +43,8 @@
|
||||
8D1107320486CEB800E47090 /* GitTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GitTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F561727C0E056A11001DCD79 /* diff_style.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; name = diff_style.css; path = html/diff_style.css; sourceTree = "<group>"; };
|
||||
F56173270E056ED2001DCD79 /* diffHighlighter.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = diffHighlighter.js; path = html/diffHighlighter.js; sourceTree = "<group>"; };
|
||||
F56174550E058893001DCD79 /* PBGitTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitTree.h; sourceTree = "<group>"; };
|
||||
F56174560E058893001DCD79 /* PBGitTree.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitTree.m; sourceTree = "<group>"; };
|
||||
F56524B90E02D22D00F03B52 /* NSFileHandleExt.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSFileHandleExt.m; sourceTree = "<group>"; };
|
||||
F56524BA0E02D22D00F03B52 /* NSFileHandleExt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSFileHandleExt.h; sourceTree = "<group>"; };
|
||||
F56524EE0E02D45200F03B52 /* PBGitCommit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitCommit.h; sourceTree = "<group>"; };
|
||||
@@ -79,10 +82,6 @@
|
||||
F56524BA0E02D22D00F03B52 /* NSFileHandleExt.h */,
|
||||
77C8280B06725ACE000B614F /* GitTest_AppDelegate.h */,
|
||||
77C8280C06725ACE000B614F /* GitTest_AppDelegate.m */,
|
||||
F5945E150E02B0C200706420 /* PBGitRepository.h */,
|
||||
F5945E160E02B0C200706420 /* PBGitRepository.m */,
|
||||
F56524EE0E02D45200F03B52 /* PBGitCommit.h */,
|
||||
F56524EF0E02D45200F03B52 /* PBGitCommit.m */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
@@ -117,6 +116,7 @@
|
||||
29B97314FDCFA39411CA2CEA /* GitTest */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F56174540E05887E001DCD79 /* Git */,
|
||||
F58A8F250E04368A007E3FC0 /* HTML */,
|
||||
7756732906782D8800D1FEB8 /* Models */,
|
||||
080E96DDFE201D6D7F000001 /* Classes */,
|
||||
@@ -164,6 +164,19 @@
|
||||
name = Models;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F56174540E05887E001DCD79 /* Git */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F5945E150E02B0C200706420 /* PBGitRepository.h */,
|
||||
F5945E160E02B0C200706420 /* PBGitRepository.m */,
|
||||
F56524EE0E02D45200F03B52 /* PBGitCommit.h */,
|
||||
F56524EF0E02D45200F03B52 /* PBGitCommit.m */,
|
||||
F56174550E058893001DCD79 /* PBGitTree.h */,
|
||||
F56174560E058893001DCD79 /* PBGitTree.m */,
|
||||
);
|
||||
name = Git;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
F58A8F250E04368A007E3FC0 /* HTML */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -245,6 +258,7 @@
|
||||
F56524BB0E02D22D00F03B52 /* NSFileHandleExt.m in Sources */,
|
||||
F56524F00E02D45200F03B52 /* PBGitCommit.m in Sources */,
|
||||
F565262B0E03D89B00F03B52 /* PBWebGitController.m in Sources */,
|
||||
F56174570E058893001DCD79 /* PBGitTree.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PBGitRepository.h"
|
||||
#import "PBGitTree.h"
|
||||
|
||||
@interface PBGitCommit : NSObject {
|
||||
NSString* sha;
|
||||
@@ -23,6 +24,6 @@
|
||||
@property (copy) NSString* author;
|
||||
|
||||
@property (readonly) NSString* details;
|
||||
|
||||
@property (readonly) PBGitTree* tree;
|
||||
@property (retain) PBGitRepository* repository;
|
||||
@end
|
||||
|
||||
@@ -27,6 +27,18 @@
|
||||
return details;
|
||||
}
|
||||
|
||||
- (PBGitTree*) tree
|
||||
{
|
||||
NSLog(@"Tree called!");
|
||||
return [PBGitTree rootForCommit: self];
|
||||
}
|
||||
|
||||
- (NSArray *) children
|
||||
{
|
||||
NSLog(@"Children aangeroepen");
|
||||
return [NSArray arrayWithObjects:self, self, nil];
|
||||
}
|
||||
|
||||
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
|
||||
{
|
||||
return NO;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
- (PBGitRepository*) initWithPath:(NSString*) path;
|
||||
|
||||
- (NSFileHandle*) handleForCommand:(NSString*) cmd;
|
||||
- (NSFileHandle*) handleForArguments:(NSArray*) args;
|
||||
- (void) initializeCommits;
|
||||
- (void) addCommit: (id)obj;
|
||||
|
||||
|
||||
+9
-3
@@ -96,11 +96,11 @@ static NSString* gitPath = @"/usr/bin/env";
|
||||
[NSThread exit];
|
||||
}
|
||||
|
||||
- (NSFileHandle*) handleForCommand:(NSString *)cmd
|
||||
- (NSFileHandle*) handleForArguments:(NSArray *)args
|
||||
{
|
||||
NSString* gitDirArg = [@"--git-dir=" stringByAppendingString:path];
|
||||
NSArray* arguments = [NSArray arrayWithObjects: gitDirArg, nil];
|
||||
arguments = [arguments arrayByAddingObjectsFromArray: [cmd componentsSeparatedByString:@" "]];
|
||||
NSArray* arguments = [NSArray arrayWithObject: gitDirArg];
|
||||
arguments = [arguments arrayByAddingObjectsFromArray: args];
|
||||
|
||||
NSTask* task = [[NSTask alloc] init];
|
||||
task.launchPath = gitPath;
|
||||
@@ -117,4 +117,10 @@ static NSString* gitPath = @"/usr/bin/env";
|
||||
return handle;
|
||||
}
|
||||
|
||||
- (NSFileHandle*) handleForCommand:(NSString *)cmd
|
||||
{
|
||||
NSArray* arguments = [cmd componentsSeparatedByString:@" "];
|
||||
return [self handleForArguments:arguments];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// PBGitTree.h
|
||||
// GitTest
|
||||
//
|
||||
// Created by Pieter de Bie on 15-06-08.
|
||||
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PBGitRepository.h"
|
||||
|
||||
@interface PBGitTree : NSObject {
|
||||
NSString* sha;
|
||||
NSString* path;
|
||||
PBGitRepository* repository;
|
||||
PBGitTree* parent;
|
||||
NSArray* children;
|
||||
BOOL leaf;
|
||||
}
|
||||
|
||||
+ (PBGitTree*) rootForCommit: (id) commit;
|
||||
+ (PBGitTree*) treeForTree: (PBGitTree*) tree andPath: (NSString*) path;
|
||||
|
||||
@property(copy) NSString* sha;
|
||||
@property(copy) NSString* path;
|
||||
@property(assign) BOOL leaf;
|
||||
@property(retain) PBGitRepository* repository;
|
||||
@property(assign) PBGitTree* parent;
|
||||
@property(readonly) NSString* fullPath;
|
||||
@end
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// PBGitTree.m
|
||||
// GitTest
|
||||
//
|
||||
// Created by Pieter de Bie on 15-06-08.
|
||||
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PBGitTree.h"
|
||||
#import "PBGitCommit.h"
|
||||
#import "NSFileHandleExt.h"
|
||||
|
||||
@implementation PBGitTree
|
||||
|
||||
@synthesize sha, path, repository, leaf, parent;
|
||||
|
||||
+ (PBGitTree*) rootForCommit:(id) commit
|
||||
{
|
||||
NSLog(@"Making root");
|
||||
PBGitCommit* c = commit;
|
||||
PBGitTree* tree = [[self alloc] init];
|
||||
tree.parent = nil;
|
||||
tree.leaf = NO;
|
||||
tree.sha = c.sha;
|
||||
tree.repository = c.repository;
|
||||
tree.path = @"";
|
||||
return tree;
|
||||
}
|
||||
|
||||
+ (PBGitTree*) treeForTree: (PBGitTree*) prev andPath: (NSString*) path;
|
||||
{
|
||||
PBGitTree* tree = [[self alloc] init];
|
||||
tree.parent = prev;
|
||||
tree.sha = prev.sha;
|
||||
tree.repository = prev.repository;
|
||||
tree.path = path;
|
||||
return tree;
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
children = nil;
|
||||
leaf = YES;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSArray*) children
|
||||
{
|
||||
if (children)
|
||||
return children;
|
||||
|
||||
NSString* ref = [NSString stringWithFormat:@"%@:%@", self.sha, self.fullPath];
|
||||
NSLog(@"Starting get for %@", ref);
|
||||
|
||||
NSFileHandle* handle = [repository handleForArguments:[NSArray arrayWithObjects:@"show", ref, nil]];
|
||||
[handle readLine];
|
||||
[handle readLine];
|
||||
|
||||
NSMutableArray* c = [NSMutableArray array];
|
||||
|
||||
NSString* p = [handle readLine];
|
||||
while (p.length > 0) {
|
||||
NSLog(@"Read line: %@", p);
|
||||
BOOL isLeaf = ([p characterAtIndex:p.length - 1] != '/');
|
||||
if (!isLeaf)
|
||||
p = [p substringToIndex:p.length -1];
|
||||
|
||||
PBGitTree* child = [PBGitTree treeForTree:self andPath:p];
|
||||
child.leaf = isLeaf;
|
||||
[c addObject: child];
|
||||
|
||||
p = [handle readLine];
|
||||
}
|
||||
children = c;
|
||||
return c;
|
||||
}
|
||||
|
||||
- (NSString*) fullPath
|
||||
{
|
||||
if (!parent)
|
||||
return @"";
|
||||
|
||||
if ([parent.fullPath isEqualToString:@""])
|
||||
return self.path;
|
||||
|
||||
return [parent.fullPath stringByAppendingPathComponent: self.path];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user