From 4f7e155ec01fd584df255ae5caf6407857f48aff Mon Sep 17 00:00:00 2001 From: Steven Michalske Date: Mon, 13 Jul 2009 12:53:32 +0800 Subject: [PATCH 1/7] Adding relitive dates to history view This is not all that sortable as 1 year will sort before 2 minutes. To fix this the sorter on the table would neet to learn about units of time. --- PBGitCommit.m | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/PBGitCommit.m b/PBGitCommit.m index 9ebe3b5..1143be9 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -34,11 +34,65 @@ return [NSDate dateWithTimeIntervalSince1970:timestamp]; } +#ifdef NormalDate - (NSString *) dateString { NSDateFormatter* formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO]; return [formatter stringFromDate: self.date]; } +#else + +// Code modified from Gilean ( http://stackoverflow.com/users/6305/gilean ). +// Copied from stackoverflow's accepted answer for Objective C relative dates. +// http://stackoverflow.com/questions/902950/iphone-convert-date-string-to-a-relative-time-stamp +// Modified the seconds constants with compile time math to aid in ease of adjustment of "Majic" numbers. +// +-(NSString *)dateString { + NSDate *todayDate = [NSDate date]; + double ti = [self.date timeIntervalSinceDate:todayDate]; + ti = ti * -1; + if(ti < 1) { + return @"In the future!"; + } else if ( ti < 60 ) { + return @"less than a minute ago"; + } else if ( ti < (60 * 60) ) { + int diff = round(ti / 60); + if ( diff < 2 ) { + return @"1 minute ago"; + } else { + return [NSString stringWithFormat:@"%d minutes ago", diff]; + } + } else if ( ti < ( 60 * 60 * 24 ) ) { + int diff = round(ti / 60 / 60); + if ( diff < 2 ) { + return @"1 hour ago"; + } else { + return[NSString stringWithFormat:@"%d hours ago", diff]; + } + } else if ( ti < ( 60 * 60 * 24 * 31.5 ) ) { + int diff = round(ti / 60 / 60 / 24); + if ( diff < 2 ) { + return @"1 day ago"; + } else { + return[NSString stringWithFormat:@"%d days ago", diff]; + } + } else if ( ti < ( 60 * 60 * 24 * 365 ) ) { + int diff = round(ti / 60 / 60 / 24 / 30); + if ( diff < 2 ) { + return @"1 month ago"; + } else { + return[NSString stringWithFormat:@"%d months ago", diff]; + } + } else { + float diff = round(ti / 60 / 60 / 24 / 365 * 4) / 4.0; + if ( diff < 1.25 ) { + return @"1 year ago"; + } else { + return[NSString stringWithFormat:@"%g years ago", diff]; + } + } +} +#endif - (NSArray*) treeContents { From 93f1ea011b2cb58d2fd49b18575b339ac7662594 Mon Sep 17 00:00:00 2001 From: Bernard Leach Date: Fri, 25 Sep 2009 10:27:45 +0800 Subject: [PATCH 2/7] Unescape the filename to ensure that filenames containing '&' are displayed correctly --- html/views/history/history.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/views/history/history.js b/html/views/history/history.js index 6cd7540..ffe74c8 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -244,7 +244,7 @@ var showDiff = function() { p.insertBefore(document.createTextNode(name1 + " -> "), link); } - link.appendChild(document.createTextNode(finalFile)); + link.appendChild(document.createTextNode(finalFile.unEscapeHTML())); button.setAttribute("representedFile", finalFile); link.setAttribute("representedFile", finalFile); From c13474e7a337ad1c3711ec7ce6ff5511184e4469 Mon Sep 17 00:00:00 2001 From: Steven Michalske Date: Mon, 13 Jul 2009 15:04:41 +0800 Subject: [PATCH 3/7] Added weeks to the strings of time. --- PBGitCommit.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/PBGitCommit.m b/PBGitCommit.m index 1143be9..3944e4f 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -69,13 +69,20 @@ } else { return[NSString stringWithFormat:@"%d hours ago", diff]; } - } else if ( ti < ( 60 * 60 * 24 * 31.5 ) ) { + } else if ( ti < ( 60 * 60 * 24 * 7 ) ) { int diff = round(ti / 60 / 60 / 24); if ( diff < 2 ) { return @"1 day ago"; } else { return[NSString stringWithFormat:@"%d days ago", diff]; } + } else if ( ti < ( 60 * 60 * 24 * 31.5 ) ) { + int diff = round(ti / 60 / 60 / 24 / 7); + if ( diff < 2 ) { + return @"1 week ago"; + } else { + return[NSString stringWithFormat:@"%d weeks ago", diff]; + } } else if ( ti < ( 60 * 60 * 24 * 365 ) ) { int diff = round(ti / 60 / 60 / 24 / 30); if ( diff < 2 ) { From 003977dad9359a373cb277b427956655d63da90c Mon Sep 17 00:00:00 2001 From: Yoshimasa Niwa Date: Wed, 9 Sep 2009 16:41:56 +0800 Subject: [PATCH 4/7] FIX: memory leak(delete will not be called) and graph glitch * When we are using subtree merge on git repository, GitX may show the slipped graph line. * Behind this glitch, GitX may leak the PBGitLane object. --- PBGitGrapher.h | 2 +- PBGitGrapher.mm | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PBGitGrapher.h b/PBGitGrapher.h index d17f3bd..f8945d0 100644 --- a/PBGitGrapher.h +++ b/PBGitGrapher.h @@ -14,7 +14,7 @@ @interface PBGitGrapher : NSObject { PBGraphCellInfo *previous; void *pl; - int curLane; + void *endLane; } - (id) initWithRepository:(PBGitRepository *)repo; diff --git a/PBGitGrapher.mm b/PBGitGrapher.mm index f9daf84..790f383 100644 --- a/PBGitGrapher.mm +++ b/PBGitGrapher.mm @@ -53,6 +53,10 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in std::list::iterator it = previousLanes->begin(); for (; it != previousLanes->end(); ++it) { i++; + if(*it == (PBGitLane *)endLane) { + delete *it; + continue; + } // This is our commit! We should do a "merge": move the line from // our upperMapping to their lowerMapping if ((*it)->isCommit([commit sha])) { @@ -141,7 +145,8 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in if (currentLane && commit.nParents > 0) currentLane->setSha(commit.parentShas[0]); else - currentLanes->remove(currentLane); + endLane = currentLane; + // currentLanes->remove(currentLane); // must be leaked without this changes delete previousLanes; From 73fcb78cb4c2610e32d44ea84f6e9b68c7780b3b Mon Sep 17 00:00:00 2001 From: Yoshimasa Niwa Date: Wed, 9 Sep 2009 17:37:41 +0800 Subject: [PATCH 5/7] FIX: bug --- PBGitGrapher.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/PBGitGrapher.mm b/PBGitGrapher.mm index 790f383..b71b60d 100644 --- a/PBGitGrapher.mm +++ b/PBGitGrapher.mm @@ -55,6 +55,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in i++; if(*it == (PBGitLane *)endLane) { delete *it; + endLane = NULL; continue; } // This is our commit! We should do a "merge": move the line from From 11cc30bc369901cb1e94543fc4204ce0054e1c7e Mon Sep 17 00:00:00 2001 From: Aron Cedercrantz Date: Sat, 18 Jul 2009 04:14:59 +0800 Subject: [PATCH 6/7] Add on window selection refresh. The changes in PBViewController is only there to supress a compiler warning. --- PBGitWindowController.m | 7 +++++++ PBViewController.h | 1 + PBViewController.m | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 232b76c..ae2f361 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -9,6 +9,7 @@ #import "PBGitWindowController.h" #import "PBGitHistoryController.h" #import "PBGitCommitController.h" +#import "PBGitDefaults.h" @implementation PBGitWindowController @@ -137,6 +138,12 @@ [[NSAlert alertWithError:error] beginSheetModalForWindow: [self window] modalDelegate:self didEndSelector:nil contextInfo:nil]; } +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + if (self.viewController && [PBGitDefaults refreshAutomatically]) { + [(PBViewController *)self.viewController refresh:nil]; + } +} #pragma mark - #pragma mark Toolbar Delegates diff --git a/PBViewController.h b/PBViewController.h index 4715c61..6055ace 100644 --- a/PBViewController.h +++ b/PBViewController.h @@ -25,4 +25,5 @@ - (void) updateView; - (NSResponder *)firstResponder; +- (IBAction) refresh:(id)sender; @end diff --git a/PBViewController.m b/PBViewController.m index 510b7a7..3368d16 100644 --- a/PBViewController.m +++ b/PBViewController.m @@ -45,4 +45,9 @@ { return nil; } + +- (IBAction) refresh:(id)sender +{ + return; +} @end From fcbe01b091594e6c2eb20c0d892f740f526726b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Berg?= Date: Sat, 24 Oct 2009 08:59:57 +0200 Subject: [PATCH 7/7] Xcode build name again. Just ignore it. --- GitX.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 83032e2..45591e4 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -801,7 +801,7 @@ /* Begin PBXProject section */ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; - buildConfigurationList = 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "gitx" */; + buildConfigurationList = 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "GitX" */; compatibilityVersion = "Xcode 3.1"; hasScannedForEncodings = 1; mainGroup = 29B97314FDCFA39411CA2CEA /* GitTest */; @@ -1507,7 +1507,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "gitx" */ = { + 26FC0A880875C7B200E6366F /* Build configuration list for PBXProject "GitX" */ = { isa = XCConfigurationList; buildConfigurations = ( 26FC0A890875C7B200E6366F /* Debug */,