mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Avoid showing .git dirs in the recent documents menu.
Instead (for non-bare repos) add the directory above the .git dir.
This commit is contained in:
committed by
Pieter de Bie
parent
d320a4bc43
commit
12faa4a8f0
@@ -29,6 +29,8 @@ extern NSString* PBGitRepositoryErrorDomain;
|
||||
- (NSString*) parseReference:(NSString*) ref;
|
||||
|
||||
+ (NSURL*)gitDirForURL:(NSURL*)repositoryURL;
|
||||
+ (NSURL*)baseDirForURL:(NSURL*)repositoryURL;
|
||||
|
||||
@property (readonly) PBGitRevList* revisionList;
|
||||
@property (assign) NSArray* branches;
|
||||
@property (assign) NSString* currentBranch;
|
||||
|
||||
@@ -76,6 +76,20 @@ static NSString* gitPath;
|
||||
return gitDirURL;
|
||||
}
|
||||
|
||||
// For a given path inside a repository, return either the .git dir
|
||||
// (for a bare repo) or the directory above the .git dir otherwise
|
||||
+ (NSURL*)baseDirForURL:(NSURL*)repositoryURL;
|
||||
{
|
||||
NSURL* gitDirURL = [self gitDirForURL:repositoryURL];
|
||||
NSString* repositoryPath = [gitDirURL path];
|
||||
|
||||
if (![[PBEasyPipe outputForCommand:gitPath withArgs:[NSArray arrayWithObjects:@"rev-parse", @"--is-bare-repository", nil] inDir:repositoryPath] isEqualToString:@"true"]) {
|
||||
repositoryURL = [NSURL fileURLWithPath:[[repositoryURL path] stringByDeletingLastPathComponent]];
|
||||
}
|
||||
|
||||
return repositoryURL;
|
||||
}
|
||||
|
||||
- (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)typeName error:(NSError **)outError
|
||||
{
|
||||
BOOL success = NO;
|
||||
|
||||
@@ -24,4 +24,9 @@
|
||||
{
|
||||
return [super documentForURL:[PBGitRepository gitDirForURL:URL]];
|
||||
}
|
||||
|
||||
- (void)noteNewRecentDocumentURL:(NSURL*)url
|
||||
{
|
||||
[super noteNewRecentDocumentURL:[PBGitRepository baseDirForURL:url]];
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user