Always do Change-Id checks on receiving commits

The check for multiple Change-Ids and the check of
the Change-Id validity were only done if the
project for which the push was done requires a
Change-Id in the commit message.

With this change both the checks are now always
executed. Otherwise it would be inconsistent that
e.g. pushing a commit with multiple Change-Ids
succeeds if the project does not require a
Change-Id but it fails if the project requires a
Change-Id.

Signed-off-by: Edwin Kempin <edwin.kempin@gmail.com>
Change-Id: I127d9c21f249e98a44d71d584cc9ef6f7fe0d1a5
This commit is contained in:
Edwin Kempin
2010-12-27 14:35:49 +01:00
parent 4b706ff6cf
commit 98417c312b

View File

@@ -1500,18 +1500,16 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
}
}
if (project.isRequireChangeID()) {
final List<String> idList = c.getFooterLines(CHANGE_ID);
if (idList.isEmpty()) {
reject(cmd, "missing Change-Id in commit message ");
final List<String> idList = c.getFooterLines(CHANGE_ID);
if (idList.isEmpty()) {
if (project.isRequireChangeID()) {
reject(cmd, "missing Change-Id in commit message");
return false;
}
if (idList.size() > 1) {
reject(cmd, "multiple Change-Id lines in commit message ");
return false;
}
} else if (idList.size() > 1) {
reject(cmd, "multiple Change-Id lines in commit message");
return false;
} else {
final String v = idList.get(idList.size() - 1).trim();
if (!v.matches("^I[0-9a-f]{8,}.*$")) {
reject(cmd, "invalid Change-Id line format in commit message ");