mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Initial file list stats on history view.
Based on kelan work
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@
|
||||
- (NSString *)parseBlame:(NSString *)txt;
|
||||
+ (NSString *)parseHTML:(NSString *)txt;
|
||||
+ (NSString *)parseDiff:(NSString *)txt;
|
||||
+ (NSString *)parseDiffTree:(NSString *)txt;
|
||||
+ (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats;
|
||||
+(BOOL)isStartDiff:(NSString *)line;
|
||||
+(BOOL)isStartBlock:(NSString *)line;
|
||||
|
||||
|
||||
+28
-5
@@ -98,7 +98,7 @@
|
||||
NSArray *files=[historyController.treeController selectedObjects];
|
||||
if ([files count]>0) {
|
||||
PBGitTree *file=[files objectAtIndex:0];
|
||||
|
||||
|
||||
NSString *fileTxt = @"";
|
||||
if(startFile==@"fileview"){
|
||||
fileTxt=[file textContents:&theError];
|
||||
@@ -223,11 +223,21 @@
|
||||
return txt;
|
||||
}
|
||||
|
||||
+ (NSString *)parseDiffTree:(NSString *)txt
|
||||
+ (NSString *)parseDiffTree:(NSString *)txt withStats:(NSMutableDictionary *)stats
|
||||
{
|
||||
NSInteger granTotal=0;
|
||||
for(NSArray *stat in [stats allValues]){
|
||||
NSInteger add=[[stat objectAtIndex:0] integerValue];
|
||||
NSInteger rem=[[stat objectAtIndex:1] integerValue];
|
||||
NSInteger tot=add+rem;
|
||||
if(tot>granTotal)
|
||||
granTotal=tot;
|
||||
[stats setObject:[NSArray arrayWithObjects:[NSNumber numberWithInteger:add],[NSNumber numberWithInteger:rem],[NSNumber numberWithInteger:tot],nil] forKey:[stat objectAtIndex:2]];
|
||||
}
|
||||
|
||||
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
|
||||
NSMutableString *res=[NSMutableString string];
|
||||
[res appendString:@"<ul>"];
|
||||
[res appendString:@"<table id='filelist'>"];
|
||||
int i;
|
||||
for (i=1; i<[lines count]; i++) {
|
||||
NSString *line=[lines objectAtIndex:i];
|
||||
@@ -241,9 +251,22 @@
|
||||
txt=[NSString stringWithFormat:@"%@ -> %@",file,[fileStatus objectAtIndex:2]];
|
||||
fileName=[fileStatus objectAtIndex:2];
|
||||
}
|
||||
[res appendString:[NSString stringWithFormat:@"<li><a class='%@' href='#%@' representedFile='%@'>%@</a></li>",status,file,fileName,txt]];
|
||||
|
||||
NSArray *stat=[stats objectForKey:fileName];
|
||||
NSInteger add=[[stat objectAtIndex:0] integerValue];
|
||||
NSInteger rem=[[stat objectAtIndex:1] integerValue];
|
||||
NSInteger tot=add+rem;
|
||||
|
||||
[res appendString:@"<tr><td class='name'>"];
|
||||
[res appendString:[NSString stringWithFormat:@"<a class='%@' href='#%@' representedFile='%@'>%@</a>",status,file,fileName,txt]];
|
||||
[res appendString:@"</td><td class='bar'>"];
|
||||
[res appendString:@"<div>"];
|
||||
[res appendString:[NSString stringWithFormat:@"<span class='add' style='width:%d%%'></span>",((add*100)/granTotal)]];
|
||||
[res appendString:[NSString stringWithFormat:@"<span class='rem' style='width:%d%%'></span>",((rem*100)/granTotal)]];
|
||||
[res appendString:@"</div>"];
|
||||
[res appendString:[NSString stringWithFormat:@"</td><td class='add'>+ %d</td><td class='rem'>- %d</td></tr>",add,rem]];
|
||||
}
|
||||
[res appendString:@"</ul>"];
|
||||
[res appendString:@"</table>"];
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
@interface PBWebHistoryController : PBWebController {
|
||||
IBOutlet PBGitHistoryController* historyController;
|
||||
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
|
||||
|
||||
|
||||
PBGitSHA* currentSha;
|
||||
NSString* diff;
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
- (void) changeContentTo: (PBGitCommit *) content;
|
||||
- (void) sendKey: (NSString*) key;
|
||||
- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges;
|
||||
- (NSMutableDictionary *)parseStats:(NSString *)txt;
|
||||
- (NSString *) someMethodThatReturnsSomeHashForSomeString:(NSString*)concat;
|
||||
|
||||
@property (readonly) NSString* diff;
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
// but this caused some funny behaviour because NSTask's and NSThread's don't really
|
||||
// like each other. Instead, just do it async.
|
||||
|
||||
NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--summary", @"--pretty=raw", [currentSha string], nil];
|
||||
NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", [currentSha string], nil];
|
||||
if (![PBGitDefaults showWhitespaceDifferences])
|
||||
[taskArguments insertObject:@"-w" atIndex:1];
|
||||
|
||||
@@ -102,10 +102,13 @@
|
||||
|
||||
// Header
|
||||
NSString *header=[self parseHeader:details withRefs:refs];
|
||||
|
||||
|
||||
// File Stats
|
||||
NSMutableDictionary *stats=[self parseStats:details];
|
||||
|
||||
// File list
|
||||
NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"-r", @"-C90%", @"-M90%", [currentSha string], nil]];
|
||||
NSString *fileList=[GLFileView parseDiffTree:dt];
|
||||
NSString *fileList=[GLFileView parseDiffTree:dt withStats:stats];
|
||||
|
||||
// Diffs list
|
||||
NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--cc", @"-C90%", @"-M90%", [currentSha string], nil]];
|
||||
@@ -122,6 +125,25 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)parseStats:(NSString *)txt
|
||||
{
|
||||
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
|
||||
NSMutableDictionary *stats=[NSMutableDictionary dictionary];
|
||||
int black=0;
|
||||
for(NSString *line in lines){
|
||||
if([line length]==0){
|
||||
black++;
|
||||
}else if(black==2){
|
||||
NSLog(@"l=%@",line);
|
||||
NSArray *file=[line componentsSeparatedByString:@"\t"];
|
||||
if([file count]==3){
|
||||
[stats setObject:file forKey:[file objectAtIndex:2]];
|
||||
}
|
||||
}
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges
|
||||
{
|
||||
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
|
||||
|
||||
@@ -186,38 +186,67 @@ a.showdiff {
|
||||
background-color: #fca64f;
|
||||
}
|
||||
|
||||
#diff ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 10px 0;
|
||||
#filelist {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#diff ul a {
|
||||
#filelist a {
|
||||
margin-left: 10px;
|
||||
padding-left: 20px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#diff ul a:hover {
|
||||
#filelist a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#diff ul a.A {
|
||||
#filelist a.A {
|
||||
background: url(../../images/added.png) no-repeat 0 center;
|
||||
}
|
||||
|
||||
#diff ul a.D {
|
||||
#filelist a.D {
|
||||
background: url(../../images/removed.png) no-repeat 0 center;
|
||||
}
|
||||
|
||||
#diff ul a.M {
|
||||
#filelist a.M {
|
||||
background: url(../../images/modified.png) no-repeat 0 center;
|
||||
}
|
||||
|
||||
#diff ul a.R,#diff ul a.C {
|
||||
#filelist a.R,#filelist a.C {
|
||||
background: url(../../images/renamed.png) no-repeat 0 center;
|
||||
}
|
||||
|
||||
#filelist{
|
||||
white-space: nowrap;
|
||||
width: 100%;
|
||||
}
|
||||
#filelist span.add,#filelist span.rem {
|
||||
display: block;
|
||||
height: 10px;
|
||||
border-top-left-radius: 5px;
|
||||
border-bottom-left-radius: 5px;
|
||||
float: right;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
#filelist span.add{
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
#filelist span.rem {
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
#filelist td.bar {
|
||||
width: 50%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
#filelist td.add,#filelist td.rem {
|
||||
width: 1%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#header {
|
||||
font-size: 13px;
|
||||
background-image: -webkit-gradient(linear,left top,left bottom, color-stop(.7, #EAF2f6), color-stop(1, #e3ebf3));
|
||||
@@ -271,8 +300,6 @@ a.showdiff {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
div.button
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user