mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
FileMerge.app on FileView diffs
This commit is contained in:
@@ -42,6 +42,8 @@
|
||||
+(BOOL)isImage:(NSString*)file;
|
||||
+(BOOL)isDiffHeader:(NSString*)line;
|
||||
|
||||
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2;
|
||||
|
||||
@property(retain) NSMutableArray *groups;
|
||||
@property(retain) NSString *logFormat;
|
||||
|
||||
|
||||
+20
-5
@@ -120,6 +120,12 @@
|
||||
if(!theError){
|
||||
NSString *filePath = [file fullPath];
|
||||
fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"\t" withString:@" "];
|
||||
fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA}" withString:file.sha];
|
||||
if(diffType==@"h") {
|
||||
fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA2}" withString:@"HEAD"];
|
||||
}else {
|
||||
fileTxt=[fileTxt stringByReplacingOccurrencesOfString:@"{SHA2}" withString:@"--"];
|
||||
}
|
||||
[script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObjects:fileTxt, filePath, nil]];
|
||||
}else{
|
||||
[script callWebScriptMethod:@"setMessage" withArguments:[NSArray arrayWithObjects:[theError localizedDescription], nil]];
|
||||
@@ -140,6 +146,13 @@
|
||||
[historyController selectCommit:[PBGitSHA shaWithString:c]];
|
||||
}
|
||||
|
||||
// TODO: need to be refactoring
|
||||
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2;
|
||||
{
|
||||
NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,file,nil];
|
||||
[historyController.repository handleInWorkDirForArguments:args];
|
||||
}
|
||||
|
||||
#pragma mark MGScopeBarDelegate methods
|
||||
|
||||
- (int)numberOfGroupsInScopeBar:(MGScopeBar *)theScopeBar
|
||||
@@ -275,10 +288,10 @@
|
||||
NSArray *lines = [txt componentsSeparatedByString:@"\n"];
|
||||
NSString *line;
|
||||
NSMutableString *res=[NSMutableString string];
|
||||
|
||||
|
||||
int l_line,l_end;
|
||||
int r_line,r_end;
|
||||
|
||||
|
||||
int i=0;
|
||||
do {
|
||||
line=[lines objectAtIndex:i];
|
||||
@@ -291,10 +304,10 @@
|
||||
}while([GLFileView isDiffHeader:line]);
|
||||
[res appendString:@"</div>"];
|
||||
if(![self isBinaryFile:line]){
|
||||
[res appendString:[NSString stringWithFormat:@"<div class='filemerge'><a href='' onclick='openFileMerge(\"%@\",\"{SHA}\"); return false;'><img src='GitX://app:/filemerge' width='32' height='32'/><br/>open in<br/>FileMerge</a></div>",fileName]];
|
||||
[res appendString:[NSString stringWithFormat:@"<div class='filemerge'><a href='' onclick='openFileMerge(\"%@\",\"{SHA}\",\"{SHA2}\"); return false;'><img src='GitX://app:/filemerge' width='32' height='32'/><br/>open in<br/>FileMerge</a></div>",fileName]];
|
||||
}
|
||||
[res appendString:@"</td></tr></thead><tbody>"];
|
||||
|
||||
|
||||
if([self isBinaryFile:line]){
|
||||
NSArray *files=[self getFilesNames:line];
|
||||
if(![[files objectAtIndex:0] isAbsolutePath]){
|
||||
@@ -340,7 +353,9 @@
|
||||
}else if([s isEqualToString:@"+"]){
|
||||
[res appendString:[NSString stringWithFormat:@"<tr class='r'><td class='l'></td><td class='r'>%d</td>",r_line++]];
|
||||
}
|
||||
[res appendString:[NSString stringWithFormat:@"<td class='code'>%@</td></tr>",[line substringFromIndex:1]]];
|
||||
if(![s isEqualToString:@"\\"]){
|
||||
[res appendString:[NSString stringWithFormat:@"<td class='code'>%@</td></tr>",[line substringFromIndex:1]]];
|
||||
}
|
||||
}while((l_line<l_end) || (r_line<r_end));
|
||||
if(i<([lines count]-1)){
|
||||
line=[lines objectAtIndex:++i];
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
- (NSString *)parseHeader:(NSString *)txt withRefs:(NSString *)badges;
|
||||
- (NSMutableDictionary *)parseStats:(NSString *)txt;
|
||||
- (NSString *) someMethodThatReturnsSomeHashForSomeString:(NSString*)concat;
|
||||
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha;
|
||||
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2;
|
||||
|
||||
@property (readonly) NSString* diff;
|
||||
@end
|
||||
|
||||
@@ -116,7 +116,8 @@
|
||||
|
||||
NSString *html=[NSString stringWithFormat:@"%@%@<div id='diffs'>%@</div>",header,fileList,diffs];
|
||||
|
||||
html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:[currentSha string]];
|
||||
html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:[NSString stringWithFormat:@"%@^",[currentSha string]]];
|
||||
html=[html stringByReplacingOccurrencesOfString:@"{SHA2}" withString:[currentSha string]];
|
||||
|
||||
[[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]];
|
||||
|
||||
@@ -224,10 +225,11 @@
|
||||
[historyController selectCommit:[PBGitSHA shaWithString:sha]];
|
||||
}
|
||||
|
||||
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha
|
||||
// TODO: need to be refactoring
|
||||
- (void) openFileMerge:(NSString*)file sha:(NSString *)sha sha2:(NSString *)sha2
|
||||
{
|
||||
NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",[NSString stringWithFormat:@"%@^",sha],sha,@"--",file,nil];
|
||||
[historyController.repository handleForArguments:args];
|
||||
NSArray *args=[NSArray arrayWithObjects:@"difftool",@"--no-prompt",@"--tool=opendiff",sha,sha2,@"--",file,nil];
|
||||
[historyController.repository handleInWorkDirForArguments:args];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,3 +9,11 @@ var showFile = function(txt) {
|
||||
$("diff").innerHTML = txt;
|
||||
$("message").style.display = "none";
|
||||
}
|
||||
|
||||
// TODO: need to be refactoring
|
||||
var openFileMerge = function(file,sha,sha2) {
|
||||
alert(file);
|
||||
alert(sha);
|
||||
alert(sha2);
|
||||
Controller.openFileMerge_sha_sha2_(file,sha,sha2);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// TODO: need to be refactoring
|
||||
var selectCommit = function(a) {
|
||||
Controller.selectCommit_(a);
|
||||
}
|
||||
|
||||
var openFileMerge = function(file,sha) {
|
||||
// TODO: need to be refactoring
|
||||
var openFileMerge = function(file,sha,sha2) {
|
||||
alert(file);
|
||||
alert(sha);
|
||||
Controller.openFileMerge_sha_(file,sha);
|
||||
alert(sha2);
|
||||
Controller.openFileMerge_sha_sha2_(file,sha,sha2);
|
||||
}
|
||||
|
||||
var showImage = function(element, filename)
|
||||
|
||||
Reference in New Issue
Block a user