From a93740a3a7b5de91032b82e1df1cf3fd874241ef Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Sun, 24 May 2009 16:43:39 -0400 Subject: [PATCH] Enable arguments to be passed to executeHook. Some hooks, such as commit-msg and prepare-commit-msg require at least one argument. This allows executeHook to take an array of arguments to be passed on to the hook. --- PBGitRepository.h | 1 + PBGitRepository.m | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/PBGitRepository.h b/PBGitRepository.h index d6404be..af20aa8 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -36,6 +36,7 @@ extern NSString* PBGitRepositoryErrorDomain; - (NSString *)outputInWorkdirForArguments:(NSArray*) arguments; - (NSString *)outputInWorkdirForArguments:(NSArray*) arguments retValue:(int *)ret; - (BOOL)executeHook:(NSString *)name output:(NSString **)output; +- (BOOL)executeHook:(NSString *)name withArgs:(NSArray*) arguments output:(NSString **)output; - (NSString *)workingDirectory; - (NSString *)gitIgnoreFilename; diff --git a/PBGitRepository.m b/PBGitRepository.m index b0de172..de99138 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -377,15 +377,20 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; } - (BOOL)executeHook:(NSString *)name output:(NSString **)output +{ + return [self executeHook:name withArgs:[NSArray array] output:output]; +} + +- (BOOL)executeHook:(NSString *)name withArgs:(NSArray *)arguments output:(NSString **)output { NSString* hookPath = [[[[self fileURL] path] stringByAppendingPathComponent:@"hooks"] stringByAppendingPathComponent:name]; if (![[NSFileManager defaultManager] isExecutableFileAtPath:hookPath]) return TRUE; int ret = 1; if (output) - *output = [PBEasyPipe outputForCommand:hookPath withArgs:[NSArray array] inDir:[self workingDirectory] retValue:&ret]; + *output = [PBEasyPipe outputForCommand:hookPath withArgs:arguments inDir:[self workingDirectory] retValue:&ret]; else - [PBEasyPipe outputForCommand:hookPath withArgs:[NSArray array] inDir:[self workingDirectory] retValue:&ret]; + [PBEasyPipe outputForCommand:hookPath withArgs:arguments inDir:[self workingDirectory] retValue:&ret]; return ret == 0; }