Skip to content

Commit

Permalink
Remove pipe-based PBGitConfig in favour of ObjectiveGit/GTConfiguration
Browse files Browse the repository at this point in the history
Part of ongoing work for issue #2
  • Loading branch information
rowanj committed Apr 25, 2012
1 parent f7bcc76 commit 612efa9
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 124 deletions.
1 change: 1 addition & 0 deletions Classes/Controllers/ApplicationController.m
Expand Up @@ -17,6 +17,7 @@
#import "PBGitDefaults.h"
#import "PBCloneRepositoryPanel.h"
#import "OpenRecentController.h"
#import "PBGitBinary.h"

#import <Sparkle/SUUpdater.h>

Expand Down
9 changes: 6 additions & 3 deletions Classes/Controllers/PBGitCommitController.m
Expand Up @@ -14,6 +14,7 @@
#import "PBNiceSplitView.h"
#import "PBGitRepositoryWatcher.h"

#import <ObjectiveGit/GTConfiguration.h>

#define kCommitSplitViewPositionDefault @"Commit SplitView Position"

Expand Down Expand Up @@ -101,11 +102,13 @@ - (NSResponder *)firstResponder;

- (IBAction)signOff:(id)sender
{
if (![repository.config valueForKeyPath:@"user.name"] || ![repository.config valueForKeyPath:@"user.email"])
NSString* userName = [repository.configuration stringForKey:@"user.name"];
NSString* userEmail = [repository.configuration stringForKey:@"user.email"];
if (!(userName && userEmail))
return [[repository windowController] showMessageSheet:@"User's name not set" infoText:@"Signing off a commit requires setting user.name and user.email in your git config"];
NSString *SOBline = [NSString stringWithFormat:@"Signed-off-by: %@ <%@>",
[repository.config valueForKeyPath:@"user.name"],
[repository.config valueForKeyPath:@"user.email"]];
userName,
userEmail];

if([commitMessageView.string rangeOfString:SOBline].location == NSNotFound) {
NSArray *selectedRanges = [commitMessageView selectedRanges];
Expand Down
3 changes: 3 additions & 0 deletions Classes/Controllers/PBHistorySearchController.m
Expand Up @@ -11,6 +11,9 @@
#import "PBGitRepository.h"
#import "PBGitDefaults.h"
#import "PBCommitList.h"
#import "PBEasyPipe.h"
#import "PBGitBinary.h"

#import <QuartzCore/CoreAnimation.h>


Expand Down
2 changes: 2 additions & 0 deletions Classes/Controllers/PBRepositoryDocumentController.m
Expand Up @@ -9,6 +9,8 @@
#import "PBRepositoryDocumentController.h"
#import "PBGitRepository.h"
#import "PBGitRevList.h"
#import "PBEasyPipe.h"
#import "PBGitBinary.h"

@implementation PBRepositoryDocumentController
// This method is overridden to configure the open panel to only allow
Expand Down
19 changes: 0 additions & 19 deletions Classes/git/PBGitConfig.h

This file was deleted.

91 changes: 0 additions & 91 deletions Classes/git/PBGitConfig.m

This file was deleted.

4 changes: 2 additions & 2 deletions Classes/git/PBGitRepository.h
Expand Up @@ -9,10 +9,10 @@
#import <Cocoa/Cocoa.h>
#import "PBGitHistoryList.h"
#import "PBGitRevSpecifier.h"
#import "PBGitConfig.h"
#import "PBGitRefish.h"

@class GTRepository;
@class GTConfiguration;

extern NSString* PBGitRepositoryErrorDomain;
typedef enum branchFilterTypes {
Expand Down Expand Up @@ -56,7 +56,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) {

@property (readonly, strong) PBGitWindowController *windowController;
@property (readonly, getter = getIndexURL) NSURL* indexURL;
@property (readonly, strong) PBGitConfig *config;
@property (readonly, nonatomic) GTConfiguration* configuration;

@property (nonatomic, strong) PBGitHistoryList *revisionList;
@property (nonatomic, strong) NSMutableArray* branches;
Expand Down
7 changes: 4 additions & 3 deletions Classes/git/PBGitRepository.m
Expand Up @@ -25,10 +25,11 @@

#import <ObjectiveGit/GTRepository.h>
#import <ObjectiveGit/GTIndex.h>
#import <ObjectiveGit/GTConfiguration.h>

@implementation PBGitRepository

@synthesize revisionList, branches, currentBranch, refs, hasChanged, config;
@synthesize revisionList, branches, currentBranch, refs, hasChanged, configuration;
@synthesize currentBranchFilter;

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
Expand Down Expand Up @@ -124,7 +125,7 @@ - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSEr

- (void) setup
{
config = [[PBGitConfig alloc] initWithRepositoryPath:[[self fileURL] path]];
self->configuration = self.gtRepo.configuration;
self.branches = [NSMutableArray array];
[self reloadRefs];
currentBranchFilter = [PBGitDefaults branchFilter];
Expand Down Expand Up @@ -542,7 +543,7 @@ - (PBGitRef *) remoteRefForBranch:(PBGitRef *)branch error:(NSError **)error

NSString *branchName = [branch branchName];
if (branchName) {
NSString *remoteName = [[self config] valueForKeyPath:[NSString stringWithFormat:@"branch.%@.remote", branchName]];
NSString *remoteName = [self.configuration stringForKey:[NSString stringWithFormat:@"branch.%@.remote", branchName]];
if (remoteName && ([remoteName isKindOfClass:[NSString class]] && ![remoteName isEqualToString:@""])) {
PBGitRef *remoteRef = [PBGitRef refFromString:[kGitXRemoteRefPrefix stringByAppendingString:remoteName]];
// check that the remote is a valid ref and exists
Expand Down
2 changes: 2 additions & 0 deletions Classes/git/PBGitRevList.mm
Expand Up @@ -11,6 +11,8 @@
#import "PBGitCommit.h"
#import "PBGitGrapher.h"
#import "PBGitRevSpecifier.h"
#import "PBEasyPipe.h"
#import "PBGitBinary.h"

#include <ext/stdio_filebuf.h>
#include <iostream>
Expand Down
6 changes: 0 additions & 6 deletions GitX.xcodeproj/project.pbxproj
Expand Up @@ -103,7 +103,6 @@
4A5D76F314A9A9CC00DF6C68 /* PBWebHistoryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D764B14A9A9CC00DF6C68 /* PBWebHistoryController.m */; };
4A5D76F414A9A9CC00DF6C68 /* PBGitBinary.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D764F14A9A9CC00DF6C68 /* PBGitBinary.m */; };
4A5D76F514A9A9CC00DF6C68 /* PBGitCommit.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D765114A9A9CC00DF6C68 /* PBGitCommit.m */; };
4A5D76F614A9A9CC00DF6C68 /* PBGitConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D765314A9A9CC00DF6C68 /* PBGitConfig.m */; };
4A5D76F714A9A9CC00DF6C68 /* PBGitDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D765514A9A9CC00DF6C68 /* PBGitDefaults.m */; };
4A5D76F814A9A9CC00DF6C68 /* PBGitGrapher.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D765714A9A9CC00DF6C68 /* PBGitGrapher.mm */; };
4A5D76F914A9A9CC00DF6C68 /* PBGitGraphLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A5D765914A9A9CC00DF6C68 /* PBGitGraphLine.m */; };
Expand Down Expand Up @@ -457,8 +456,6 @@
4A5D764F14A9A9CC00DF6C68 /* PBGitBinary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitBinary.m; sourceTree = "<group>"; };
4A5D765014A9A9CC00DF6C68 /* PBGitCommit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitCommit.h; sourceTree = "<group>"; };
4A5D765114A9A9CC00DF6C68 /* PBGitCommit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitCommit.m; sourceTree = "<group>"; };
4A5D765214A9A9CC00DF6C68 /* PBGitConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitConfig.h; sourceTree = "<group>"; };
4A5D765314A9A9CC00DF6C68 /* PBGitConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitConfig.m; sourceTree = "<group>"; };
4A5D765414A9A9CC00DF6C68 /* PBGitDefaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitDefaults.h; sourceTree = "<group>"; };
4A5D765514A9A9CC00DF6C68 /* PBGitDefaults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitDefaults.m; sourceTree = "<group>"; };
4A5D765614A9A9CC00DF6C68 /* PBGitGrapher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitGrapher.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -922,8 +919,6 @@
4A5D764F14A9A9CC00DF6C68 /* PBGitBinary.m */,
4A5D765014A9A9CC00DF6C68 /* PBGitCommit.h */,
4A5D765114A9A9CC00DF6C68 /* PBGitCommit.m */,
4A5D765214A9A9CC00DF6C68 /* PBGitConfig.h */,
4A5D765314A9A9CC00DF6C68 /* PBGitConfig.m */,
4A5D765414A9A9CC00DF6C68 /* PBGitDefaults.h */,
4A5D765514A9A9CC00DF6C68 /* PBGitDefaults.m */,
4A5D765614A9A9CC00DF6C68 /* PBGitGrapher.h */,
Expand Down Expand Up @@ -1431,7 +1426,6 @@
4A5D76F314A9A9CC00DF6C68 /* PBWebHistoryController.m in Sources */,
4A5D76F414A9A9CC00DF6C68 /* PBGitBinary.m in Sources */,
4A5D76F514A9A9CC00DF6C68 /* PBGitCommit.m in Sources */,
4A5D76F614A9A9CC00DF6C68 /* PBGitConfig.m in Sources */,
4A5D76F714A9A9CC00DF6C68 /* PBGitDefaults.m in Sources */,
4A5D76F814A9A9CC00DF6C68 /* PBGitGrapher.mm in Sources */,
4A5D76F914A9A9CC00DF6C68 /* PBGitGraphLine.m in Sources */,
Expand Down

0 comments on commit 612efa9

Please sign in to comment.