Allow rejection of changes without Change-Id line.
Bug: issue 557 Change-Id: I8bb545d19d4ab04278cd1f185401f4dc3cefbcc4
This commit is contained in:
committed by
Shawn O. Pearce
parent
f9b89eedc1
commit
d8235793c9
@@ -102,6 +102,7 @@ public class GitProjectImporter {
|
||||
p.setSubmitType(SubmitType.MERGE_IF_NECESSARY);
|
||||
p.setUseContributorAgreements(false);
|
||||
p.setUseSignedOffBy(false);
|
||||
p.setRequireChangeID(false);
|
||||
db.projects().insert(Collections.singleton(p));
|
||||
|
||||
} else if (f.isDirectory()) {
|
||||
|
||||
@@ -1460,6 +1460,25 @@ 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 ");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (idList.size() > 1) {
|
||||
reject(cmd, "multiple Change-Id lines in commit message ");
|
||||
return false;
|
||||
}
|
||||
|
||||
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 ");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.List;
|
||||
/** A version of the database schema. */
|
||||
public abstract class SchemaVersion {
|
||||
/** The current schema version. */
|
||||
private static final Class<? extends SchemaVersion> C = Schema_42.class;
|
||||
private static final Class<? extends SchemaVersion> C = Schema_43.class;
|
||||
|
||||
public static class Module extends AbstractModule {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2010 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
public class Schema_43 extends SchemaVersion {
|
||||
@Inject
|
||||
Schema_43(Provider<Schema_42> prior) {
|
||||
super(prior);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user