Allow callers of AllProjectsCreator to control the commit message

Callers may want to use a shorter fixed message that does not
include the version number. Allow the caller to control the
text as they see fit, falling back to the default standard
message if not specified.

Change-Id: I25648ea24fd46c54e2c1ca28553ee1c393ebde8c
This commit is contained in:
Shawn Pearce
2014-09-02 14:59:34 -07:00
parent 1378c6c8a4
commit 44bdf188c9

View File

@@ -18,6 +18,8 @@ import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
import static com.google.gerrit.server.group.SystemGroupBackend.PROJECT_OWNERS;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.gerrit.common.Version;
import com.google.gerrit.common.data.AccessSection;
@@ -54,6 +56,7 @@ public class AllProjectsCreator {
private final GitRepositoryManager mgr;
private final AllProjectsName allProjectsName;
private final PersonIdent serverUser;
private String message;
private GroupReference admin;
private GroupReference batch;
@@ -85,6 +88,11 @@ public class AllProjectsCreator {
return this;
}
public AllProjectsCreator setCommitMessage(String message) {
this.message = message;
return this;
}
public void create() throws IOException, ConfigInvalidException {
Repository git = null;
try {
@@ -118,7 +126,9 @@ public class AllProjectsCreator {
git);
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);
md.setMessage("Initialized Gerrit Code Review " + Version.getVersion());
md.setMessage(Objects.firstNonNull(
Strings.emptyToNull(message),
"Initialized Gerrit Code Review " + Version.getVersion()));
ProjectConfig config = ProjectConfig.read(md);
Project p = config.getProject();