@@ -32,8 +32,14 @@ @implementation PBWebCommitController
32
32
33
33
@synthesize diff;
34
34
35
+ - (void ) showLongDiff
36
+ {
37
+ showLongDiffs = TRUE ;
38
+ }
39
+
35
40
- (void ) awakeFromNib
36
41
{
42
+ showLongDiffs = FALSE ;
37
43
startFile = @" history" ;
38
44
[super awakeFromNib ];
39
45
}
@@ -118,10 +124,16 @@ - (void)commitDetailsLoaded:(NSNotification *)notification
118
124
[args addObjectsFromArray: parents];
119
125
[args addObject: currentSha];
120
126
NSString *d = [repository outputInWorkdirForArguments: args];
121
- NSString *diffs = [GLFileView parseDiff: d];
122
-
123
- NSString *html = [NSString stringWithFormat: @" %@%@ <div id='diffs'>%@ </div>" ,header,fileList,diffs];
124
-
127
+ NSString *html;
128
+ if (showLongDiffs || [d length ] < 200000 )
129
+ {
130
+ showLongDiffs = FALSE ;
131
+ NSString *diffs = [GLFileView parseDiff: d];
132
+ html = [NSString stringWithFormat: @" %@%@ <div id='diffs'>%@ </div>" ,header,fileList,diffs];
133
+ } else {
134
+ html = [NSString stringWithFormat: @" %@%@ <div id='diffs'><p>This is a very large commit. It may take a long time to load the diff. Click <a href='' onclick='showFullDiff(); return false;'>here</a> to show anyway.</p></div>" ,header,fileList,currentSha];
135
+ }
136
+
125
137
html = [html stringByReplacingOccurrencesOfString: @" {SHA_PREV}" withString: [NSString stringWithFormat: @" %@ ^" ,currentSha]];
126
138
html = [html stringByReplacingOccurrencesOfString: @" {SHA}" withString: currentSha];
127
139
@@ -216,13 +228,20 @@ - (NSArray *)parseHeader:(NSString *)text
216
228
- (NSString *)htmlForHeader : (NSArray *)header withRefs : (NSString *)badges
217
229
{
218
230
NSString *last_mail = @" " ;
231
+ NSMutableString *subjectFirst = [NSMutableString string ];
219
232
NSMutableString *auths=[NSMutableString string ];
220
233
NSMutableString *refs=[NSMutableString string ];
221
234
NSMutableString *subject=[NSMutableString string ];
235
+ NSMutableString *all=[NSMutableString string ];
222
236
223
237
for (NSDictionary *item in header) {
224
238
if ([[item objectForKey: kHeaderKeyName ] isEqualToString: @" subject" ]) {
225
- [subject appendString: [NSString stringWithFormat: @" %@ <br/>" ,[GLFileView escapeHTML: [item objectForKey: kHeaderKeyContent ]]]];
239
+ if ([subjectFirst isEqualToString: @" " ]) {
240
+ [subjectFirst appendString: [NSString stringWithFormat: @" %@ " ,[GLFileView escapeHTML: [item objectForKey: kHeaderKeyContent ]]]];
241
+ } else {
242
+ [subject appendString: [NSString stringWithFormat: @" %@ <br/>" ,[GLFileView escapeHTML: [item objectForKey: kHeaderKeyContent ]]]];
243
+ }
244
+
226
245
}else {
227
246
if ([[item objectForKey: kHeaderKeyContent ] isKindOfClass: [NSString class ]]){
228
247
[refs appendString: [NSString stringWithFormat: @" <tr><td>%@ </td><td><a href='' onclick='selectCommit(this.innerHTML); return false;'>%@ </a></td></tr>" ,[item objectForKey: kHeaderKeyName ],[item objectForKey: kHeaderKeyContent ]]];
@@ -251,7 +270,17 @@ - (NSString *)htmlForHeader:(NSArray *)header withRefs:(NSString *)badges
251
270
}
252
271
}
253
272
254
- return [NSString stringWithFormat: @" <div id='header' class='clearfix'><table class='references'>%@ </table><p class='subject'>%@ </p>%@ <div id='badges'>%@ </div></div>" ,refs,subject,auths,badges];
273
+ [all appendString: [NSString stringWithFormat: @" <div id='header' class='clearfix'><table class='references'>%@ </table><p class='subject'>%@ </p>%@ " ,refs,subjectFirst,auths]];
274
+
275
+ if (![badges isEqualToString: @" " ])
276
+ [all appendString: [NSString stringWithFormat: @" <div id='badges'>%@ </div>" ,badges]];
277
+
278
+ [all appendString: @" </div>" ];
279
+
280
+ if (![subject isEqualToString: @" " ])
281
+ [all appendString: [NSString stringWithFormat: @" <p class='subjectDetail'>%@ </p>" ,subject]];
282
+
283
+ return all;
255
284
}
256
285
257
286
- (NSString *) arbitraryHashForString : (NSString *)concat {
0 commit comments