Skip to content

Commit 4391c45

Browse files
committed
Merge commit 'dd0822d5cd52dd8a2e1ac1ee318f8fa685c2e420'
* commit 'dd0822d5cd52dd8a2e1ac1ee318f8fa685c2e420': PBGitCommitController: Don't allow duplicate Sign-Offs
2 parents 83a1453 + dd0822d commit 4391c45

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)