diff options
author | James Moger <james.moger@gitblit.com> | 2013-07-02 16:46:52 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-07-02 16:46:52 -0400 |
commit | d1dc77b4b1599f7089e3184eb622f51035728da4 (patch) | |
tree | 52ebc94ebf02cfe5da7b70e3f5870593e1cb6770 /src/main | |
parent | 4f404712c8ebcff78a5702cf0192568c7b9ee226 (diff) | |
download | gitblit-d1dc77b4b1599f7089e3184eb622f51035728da4.tar.gz gitblit-d1dc77b4b1599f7089e3184eb622f51035728da4.zip |
Fixed committer verification with merge commits (issue-264)
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/gitblit/git/ReceiveHook.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/com/gitblit/git/ReceiveHook.java b/src/main/java/com/gitblit/git/ReceiveHook.java index e3435ffb..e0b77987 100644 --- a/src/main/java/com/gitblit/git/ReceiveHook.java +++ b/src/main/java/com/gitblit/git/ReceiveHook.java @@ -137,18 +137,36 @@ public class ReceiveHook implements PreReceiveHook, PostReceiveHook { // identity of the merging user.
boolean allRejected = false;
for (ReceiveCommand cmd : commands) {
+ String linearParent = null;
try {
List<RevCommit> commits = JGitUtils.getRevLog(rp.getRepository(), cmd.getOldId().name(), cmd.getNewId().name());
for (RevCommit commit : commits) {
+
+ if (linearParent != null) {
+ if (!commit.getName().equals(linearParent)) {
+ // ignore: commit is right-descendant of a merge
+ continue;
+ }
+ }
+
+ // update expected next commit id
+ if (commit.getParentCount() == 0) {
+ linearParent = null;
+ } else {
+ linearParent = commit.getParents()[0].getId().getName();
+ }
+
PersonIdent committer = commit.getCommitterIdent();
if (!user.is(committer.getName(), committer.getEmailAddress())) {
String reason;
if (StringUtils.isEmpty(user.emailAddress)) {
- // account does not have en email address
- reason = MessageFormat.format("{0} by {1} <{2}> was not committed by {3} ({4})", commit.getId().name(), committer.getName(), StringUtils.isEmpty(committer.getEmailAddress()) ? "?":committer.getEmailAddress(), user.getDisplayName(), user.username);
+ // account does not have an email address
+ reason = MessageFormat.format("{0} by {1} <{2}> was not committed by {3} ({4})",
+ commit.getId().name(), committer.getName(), StringUtils.isEmpty(committer.getEmailAddress()) ? "?":committer.getEmailAddress(), user.getDisplayName(), user.username);
} else {
// account has an email address
- reason = MessageFormat.format("{0} by {1} <{2}> was not committed by {3} ({4}) <{5}>", commit.getId().name(), committer.getName(), StringUtils.isEmpty(committer.getEmailAddress()) ? "?":committer.getEmailAddress(), user.getDisplayName(), user.username, user.emailAddress);
+ reason = MessageFormat.format("{0} by {1} <{2}> was not committed by {3} ({4}) <{5}>",
+ commit.getId().name(), committer.getName(), StringUtils.isEmpty(committer.getEmailAddress()) ? "?":committer.getEmailAddress(), user.getDisplayName(), user.username, user.emailAddress);
}
logger.warn(reason);
cmd.setResult(Result.REJECTED_OTHER_REASON, reason);
|