mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
PBGitRepository: Display branch-name in window title
This returns not only the name of the git-dir but also the current branch (or detached HEAD if no local branch is checked out). When reloading the refs (which also happens when checking-out using GitX), the displayName-method is called, updating the window-title. Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
This commit is contained in:
committed by
Pieter de Bie
parent
6912add00e
commit
e9d45261bd
+14
-3
@@ -149,9 +149,17 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
// useless for display in the window title bar, so we show the directory above
|
||||
- (NSString*)displayName
|
||||
{
|
||||
NSString* displayName = self.fileURL.path.lastPathComponent;
|
||||
if ([displayName isEqualToString:@".git"])
|
||||
displayName = [self.fileURL.path stringByDeletingLastPathComponent].lastPathComponent;
|
||||
NSString* dirName = self.fileURL.path.lastPathComponent;
|
||||
if ([dirName isEqualToString:@".git"])
|
||||
dirName = [self.fileURL.path stringByDeletingLastPathComponent].lastPathComponent;
|
||||
NSString* displayName;
|
||||
if (![[PBGitRef refFromString:[[self headRef] simpleRef]] type]) {
|
||||
displayName = [NSString stringWithFormat:@"%@ (detached HEAD)", dirName];
|
||||
} else {
|
||||
displayName = [NSString stringWithFormat:@"%@ (branch: %@)", dirName,
|
||||
[[self headRef] description]];
|
||||
}
|
||||
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@@ -236,6 +244,9 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
|
||||
// Add an "All branches" option in the branches list
|
||||
[self addBranch:[PBGitRevSpecifier allBranchesRevSpec]];
|
||||
[self addBranch:[PBGitRevSpecifier localBranchesRevSpec]];
|
||||
|
||||
[[[self windowController] window] setTitle:[self displayName]];
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user