From da34e56994d06e0df77902bb1fa7dfee11d3e9bf Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Sun, 14 Jul 2013 12:05:19 -0400
Subject: [PATCH] Reset build identifiers for next development cycle
---
src/main/java/com/gitblit/git/ReceiveHook.java | 28 +++++++++++++++++++++++-----
1 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/gitblit/git/ReceiveHook.java b/src/main/java/com/gitblit/git/ReceiveHook.java
index 3e00b38..e0b7798 100644
--- a/src/main/java/com/gitblit/git/ReceiveHook.java
+++ b/src/main/java/com/gitblit/git/ReceiveHook.java
@@ -45,7 +45,7 @@
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ClientLogger;
import com.gitblit.utils.JGitUtils;
-import com.gitblit.utils.PushLogUtils;
+import com.gitblit.utils.RefLogUtils;
import com.gitblit.utils.StringUtils;
/**
@@ -137,18 +137,36 @@
// 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);
@@ -256,7 +274,7 @@
// update push log
try {
- PushLogUtils.updatePushLog(user, rp.getRepository(), commands);
+ RefLogUtils.updateRefLog(user, rp.getRepository(), commands);
logger.debug(MessageFormat.format("{0} push log updated", repository.name));
} catch (Exception e) {
logger.error(MessageFormat.format("Failed to update {0} pushlog", repository.name), e);
--
Gitblit v1.9.1