Skip to content

Commit dd0822d

Browse files
committed
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 <[email protected]>
1 parent 9312438 commit dd0822d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

PBGitCommitController.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ - (IBAction)signOff:(id)sender
5252
{
5353
if (![repository.config valueForKeyPath:@"user.name"] || ![repository.config valueForKeyPath:@"user.email"])
5454
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"];
55+
NSString *SOBline = [NSString stringWithFormat:@"Signed-off-by: %@ <%@>",
56+
[repository.config valueForKeyPath:@"user.name"],
57+
[repository.config valueForKeyPath:@"user.email"]];
5558

56-
commitMessageView.string = [NSString stringWithFormat:@"%@\n\nSigned-off-by: %@ <%@>",
57-
commitMessageView.string,
58-
[repository.config valueForKeyPath:@"user.name"],
59-
[repository.config valueForKeyPath:@"user.email"]];
59+
if([commitMessageView.string rangeOfString:SOBline].location == NSNotFound) {
60+
commitMessageView.string = [NSString stringWithFormat:@"%@\n\n%@",
61+
commitMessageView.string, SOBline];
62+
}
6063
}
6164

6265
- (void) setAmend:(BOOL)newAmend

0 commit comments

Comments
 (0)