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.
This commit is contained in:
Joe Fiorini
2009-05-24 16:43:39 -04:00
committed by Pieter de Bie
parent 897c80f8a7
commit a93740a3a7
2 changed files with 8 additions and 2 deletions
+1
View File
@@ -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;
+7 -2
View File
@@ -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;
}