From dd0822d5cd52dd8a2e1ac1ee318f8fa685c2e420 Mon Sep 17 00:00:00 2001 From: Johannes Gilger Date: Sat, 13 Jun 2009 14:13:33 +0200 Subject: [PATCH] PBGitCommitController: Don't allow duplicate Sign-Offs This prevents signing off a commit-message twice by the same person, just like git-gui does. Signed-off-by: Johannes Gilger --- PBGitCommitController.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 01b0d14..def7238 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -52,11 +52,14 @@ { if (![repository.config valueForKeyPath:@"user.name"] || ![repository.config valueForKeyPath:@"user.email"]) 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"]]; - commitMessageView.string = [NSString stringWithFormat:@"%@\n\nSigned-off-by: %@ <%@>", - commitMessageView.string, - [repository.config valueForKeyPath:@"user.name"], - [repository.config valueForKeyPath:@"user.email"]]; + if([commitMessageView.string rangeOfString:SOBline].location == NSNotFound) { + commitMessageView.string = [NSString stringWithFormat:@"%@\n\n%@", + commitMessageView.string, SOBline]; + } } - (void) setAmend:(BOOL)newAmend