Rename "-- All Projects --" to "All-Projects"
The name "-- All Projects --" is awkard to work with on the command line due to starting with leading hypens, and containing spaces. In prior versions of Gerrit Code Review this did not really matter, the project was stored only in the database and did not need to be accessed by command line tools. Now that the access controls are in Git and are stored in a Git repository, this directory exists and needs to be managed. Bug: issue 994 Change-Id: I19b0967c6cf2720dcd2fd72a354e3566def15fdb Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
parent
d12c47672c
commit
99071dd232
|
@ -57,7 +57,7 @@ import java.util.Collections;
|
|||
/** Creates the current database schema and populates initial code rows. */
|
||||
public class SchemaCreator {
|
||||
private static final Project.NameKey DEFAULT_WILD_NAME =
|
||||
new Project.NameKey("-- All Projects --");
|
||||
new Project.NameKey("All-Projects");
|
||||
|
||||
private final @SitePath
|
||||
File site_path;
|
||||
|
@ -216,7 +216,7 @@ public class SchemaCreator {
|
|||
git = mgr.openRepository(DEFAULT_WILD_NAME);
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
// A repository may be missing if this project existed only to store
|
||||
// inheritable permissions. For example '-- All Projects --'.
|
||||
// inheritable permissions. For example 'All-Projects'.
|
||||
try {
|
||||
git = mgr.createRepository(DEFAULT_WILD_NAME);
|
||||
} catch (RepositoryNotFoundException err) {
|
||||
|
|
|
@ -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_54.class;
|
||||
private static final Class<? extends SchemaVersion> C = Schema_55.class;
|
||||
|
||||
public static class Module extends AbstractModule {
|
||||
@Override
|
||||
|
|
|
@ -155,7 +155,7 @@ class Schema_53 extends SchemaVersion {
|
|||
git = mgr.openRepository(nameKey);
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
// A repository may be missing if this project existed only to store
|
||||
// inheritable permissions. For example '-- All Projects --'.
|
||||
// inheritable permissions. For example 'All-Projects'.
|
||||
try {
|
||||
git = mgr.createRepository(nameKey);
|
||||
} catch (RepositoryNotFoundException err) {
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (C) 2011 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.gerrit.reviewdb.Project;
|
||||
import com.google.gerrit.reviewdb.ReviewDb;
|
||||
import com.google.gerrit.reviewdb.SystemConfig;
|
||||
import com.google.gerrit.server.git.LocalDiskRepositoryManager;
|
||||
import com.google.gwtorm.client.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.RepositoryCache.FileKey;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
public class Schema_55 extends SchemaVersion {
|
||||
private final LocalDiskRepositoryManager mgr;
|
||||
|
||||
@Inject
|
||||
Schema_55(Provider<Schema_54> prior, LocalDiskRepositoryManager mgr) {
|
||||
super(prior);
|
||||
this.mgr = mgr;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
|
||||
SystemConfig sc = db.systemConfig().get(new SystemConfig.Key());
|
||||
String oldName = sc.wildProjectName.get();
|
||||
String newName = "All-Projects";
|
||||
if ("-- All Projects --".equals(oldName)) {
|
||||
ui.message("Renaming \"" + oldName + "\" to \"" + newName + "\"");
|
||||
|
||||
File base = mgr.getBasePath();
|
||||
File oldDir = FileKey.resolve(new File(base, oldName), FS.DETECTED);
|
||||
File newDir = new File(base, newName + Constants.DOT_GIT_EXT);
|
||||
if (!oldDir.renameTo(newDir)) {
|
||||
throw new OrmException("Cannot rename " + oldDir.getAbsolutePath()
|
||||
+ " to " + newDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
sc.wildProjectName = new Project.NameKey(newName);
|
||||
db.systemConfig().update(Collections.singleton(sc));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -318,7 +318,7 @@ public class RefControlTest extends TestCase {
|
|||
};
|
||||
|
||||
GitRepositoryManager mgr = null;
|
||||
Project.NameKey wildProject = new Project.NameKey("-- All Projects --");
|
||||
Project.NameKey wildProject = new Project.NameKey("All-Projects");
|
||||
ProjectControl.AssistedFactory projectControlFactory = null;
|
||||
all.put(local.getProject().getNameKey(), new ProjectState(anonymousUser,
|
||||
projectCache, wildProject, projectControlFactory, mgr, local));
|
||||
|
|
Loading…
Reference in New Issue