Move "projects" table into Git
Project settings are now saved in the project.config file of the refs/meta/config branch within each Git repository. This offers us free version control over the lifespan of the project, and will help reduce schema version issues as the configuration file is more free-form. Project owners can edit the configuration of their project by hand and push the results back up, possibly even going through code review, if the proper access rules are assigned in the project's access panel. Project users can inspect the history of the configuration by reading the history of the refs/meta/config branch with their favorite history browser. Change-Id: Id63414d86dbfb9033021f76e1d5e782373525a77 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -286,9 +286,10 @@ public class RefControlTest extends TestCase {
|
||||
ProjectCache projectCache = null;
|
||||
Project.NameKey wildProject = new Project.NameKey("-- All Projects --");
|
||||
ProjectControl.AssistedFactory projectControlFactory = null;
|
||||
Project project = new Project(parent);
|
||||
ProjectState ps =
|
||||
new ProjectState(anonymousUser, projectCache, wildProject,
|
||||
projectControlFactory, new Project(parent), localRights);
|
||||
projectControlFactory, project, localRights);
|
||||
ps.setInheritedRights(inheritedRights);
|
||||
return ps;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.google.gerrit.server.schema;
|
||||
import com.google.gerrit.reviewdb.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.ApprovalCategory;
|
||||
import com.google.gerrit.reviewdb.ApprovalCategoryValue;
|
||||
import com.google.gerrit.reviewdb.Project;
|
||||
import com.google.gerrit.reviewdb.RefRight;
|
||||
import com.google.gerrit.reviewdb.ReviewDb;
|
||||
import com.google.gerrit.reviewdb.SystemConfig;
|
||||
@@ -151,24 +150,6 @@ public class SchemaCreatorTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateSchema_WildCardProject() throws OrmException {
|
||||
final ReviewDb c = db.create().open();
|
||||
try {
|
||||
final SystemConfig cfg;
|
||||
final Project all;
|
||||
|
||||
cfg = c.systemConfig().get(new SystemConfig.Key());
|
||||
all = c.projects().get(cfg.wildProjectName);
|
||||
assertNotNull(all);
|
||||
assertEquals("-- All Projects --", all.getName());
|
||||
assertFalse(all.isUseContributorAgreements());
|
||||
assertFalse(all.isUseSignedOffBy());
|
||||
assertFalse(all.isRequireChangeID());
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateSchema_ApprovalCategory_CodeReview()
|
||||
throws OrmException {
|
||||
final ReviewDb c = db.create().open();
|
||||
@@ -347,18 +328,16 @@ public class SchemaCreatorTest extends TestCase {
|
||||
final ReviewDb c = db.open();
|
||||
try {
|
||||
final SystemConfig cfg;
|
||||
final Project all;
|
||||
final RefRight right;
|
||||
|
||||
cfg = c.systemConfig().get(new SystemConfig.Key());
|
||||
all = c.projects().get(cfg.wildProjectName);
|
||||
right =
|
||||
c.refRights().get(
|
||||
new RefRight.Key(all.getNameKey(), new RefRight.RefPattern(
|
||||
new RefRight.Key(cfg.wildProjectName, new RefRight.RefPattern(
|
||||
pattern), category, group));
|
||||
|
||||
assertNotNull(right);
|
||||
assertEquals(all.getNameKey(), right.getProjectNameKey());
|
||||
assertEquals(cfg.wildProjectName, right.getProjectNameKey());
|
||||
assertEquals(group, right.getAccountGroupId());
|
||||
assertEquals(category, right.getApprovalCategoryId());
|
||||
assertEquals(min, right.getMinValue());
|
||||
|
||||
@@ -16,7 +16,12 @@ package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.gerrit.reviewdb.ReviewDb;
|
||||
import com.google.gerrit.reviewdb.SystemConfig;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.GerritPersonIdentProvider;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.LocalDiskRepositoryManager;
|
||||
import com.google.gerrit.testutil.InMemoryDatabase;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.SchemaFactory;
|
||||
@@ -27,6 +32,9 @@ import com.google.inject.TypeLiteral;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.List;
|
||||
@@ -58,6 +66,22 @@ public class SchemaUpdaterTest extends TestCase {
|
||||
bind(new TypeLiteral<SchemaFactory<ReviewDb>>() {}).toInstance(db);
|
||||
bind(SitePaths.class).toInstance(paths);
|
||||
install(new SchemaVersion.Module());
|
||||
|
||||
Config cfg = new Config();
|
||||
cfg.setString("gerrit", null, "basePath", "git");
|
||||
cfg.setString("user", null, "name", "Gerrit Code Review");
|
||||
cfg.setString("user", null, "email", "gerrit@localhost");
|
||||
|
||||
bind(Config.class) //
|
||||
.annotatedWith(GerritServerConfig.class) //
|
||||
.toInstance(cfg);
|
||||
|
||||
bind(PersonIdent.class) //
|
||||
.annotatedWith(GerritPersonIdent.class) //
|
||||
.toProvider(GerritPersonIdentProvider.class);
|
||||
|
||||
bind(GitRepositoryManager.class) //
|
||||
.to(LocalDiskRepositoryManager.class);
|
||||
}
|
||||
}).getInstance(SchemaUpdater.class);
|
||||
|
||||
|
||||
@@ -17,7 +17,13 @@ package com.google.gerrit.testutil;
|
||||
import com.google.gerrit.reviewdb.CurrentSchemaVersion;
|
||||
import com.google.gerrit.reviewdb.ReviewDb;
|
||||
import com.google.gerrit.reviewdb.SystemConfig;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.GerritPersonIdentProvider;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.SitePath;
|
||||
import com.google.gerrit.server.config.SystemConfigProvider;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.LocalDiskRepositoryManager;
|
||||
import com.google.gerrit.server.schema.Current;
|
||||
import com.google.gerrit.server.schema.SchemaCreator;
|
||||
import com.google.gerrit.server.schema.SchemaVersion;
|
||||
@@ -25,13 +31,19 @@ import com.google.gwtorm.client.OrmException;
|
||||
import com.google.gwtorm.client.SchemaFactory;
|
||||
import com.google.gwtorm.jdbc.Database;
|
||||
import com.google.gwtorm.jdbc.SimpleDataSource;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
@@ -84,8 +96,33 @@ public class InMemoryDatabase implements SchemaFactory<ReviewDb> {
|
||||
database = new Database<ReviewDb>(dataSource, ReviewDb.class);
|
||||
|
||||
schemaVersion =
|
||||
Guice.createInjector(new SchemaVersion.Module()).getBinding(
|
||||
Key.get(SchemaVersion.class, Current.class)).getProvider().get();
|
||||
Guice.createInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
install(new SchemaVersion.Module());
|
||||
|
||||
bind(File.class) //
|
||||
.annotatedWith(SitePath.class) //
|
||||
.toInstance(new File("."));
|
||||
|
||||
Config cfg = new Config();
|
||||
cfg.setString("gerrit", null, "basePath", "git");
|
||||
cfg.setString("user", null, "name", "Gerrit Code Review");
|
||||
cfg.setString("user", null, "email", "gerrit@localhost");
|
||||
|
||||
bind(Config.class) //
|
||||
.annotatedWith(GerritServerConfig.class) //
|
||||
.toInstance(cfg);
|
||||
|
||||
bind(PersonIdent.class) //
|
||||
.annotatedWith(GerritPersonIdent.class) //
|
||||
.toProvider(GerritPersonIdentProvider.class);
|
||||
|
||||
bind(GitRepositoryManager.class) //
|
||||
.to(LocalDiskRepositoryManager.class);
|
||||
}
|
||||
}).getBinding(Key.get(SchemaVersion.class, Current.class))
|
||||
.getProvider().get();
|
||||
} catch (SQLException e) {
|
||||
throw new OrmException(e);
|
||||
}
|
||||
@@ -106,7 +143,14 @@ public class InMemoryDatabase implements SchemaFactory<ReviewDb> {
|
||||
created = true;
|
||||
final ReviewDb c = open();
|
||||
try {
|
||||
new SchemaCreator(new File("."), schemaVersion).create(c);
|
||||
try {
|
||||
new SchemaCreator(new File("."), schemaVersion, null,
|
||||
new PersonIdent("name", "email@site")).create(c);
|
||||
} catch (IOException e) {
|
||||
throw new OrmException("Cannot create in-memory database", e);
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new OrmException("Cannot create in-memory database", e);
|
||||
}
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user