From 31b599b40fea3df9fd11bc4d494ee194224f4de5 Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Wed, 11 Dec 2013 08:55:24 -0800 Subject: [PATCH] Move "refs/..." constants to a RefNames class This class lives in gerrit-reviewdb because "refs/changes/" needs to be referenced from PatchSet in reviewdb/client (and other UI classes). Rename constants to all use REFS_* instead of being inconsistent. Change-Id: I76e6ee7e63a4549b51a43698fb50b54a19dabfc6 --- .../rest/project/CreateProjectIT.java | 4 +- .../rest/project/ProjectLevelConfigIT.java | 12 ++--- .../client/admin/ProjectAccessEditor.java | 3 +- .../client/admin/ProjectBranchesScreen.java | 3 +- .../rpc/project/ProjectAccessFactory.java | 4 +- .../rpc/project/ReviewProjectAccess.java | 4 +- gerrit-pgm/BUCK | 1 + .../gerrit/pgm/init/AllProjectsConfig.java | 4 +- .../gerrit/reviewdb/client/PatchSet.java | 4 +- .../gerrit/reviewdb/client/RefNames.java | 44 +++++++++++++++++++ .../google/gerrit/rules/PrologCompiler.java | 4 +- .../com/google/gerrit/rules/RulesCache.java | 3 +- .../gerrit/server/access/ListAccess.java | 4 +- .../server/change/MergeabilityChecker.java | 10 ++--- .../google/gerrit/server/git/BanCommit.java | 4 +- .../google/gerrit/server/git/ChangeCache.java | 3 +- .../server/git/GitRepositoryManager.java | 21 --------- .../com/google/gerrit/server/git/MergeOp.java | 5 ++- .../gerrit/server/git/ProjectConfig.java | 3 +- .../gerrit/server/git/ProjectLevelConfig.java | 3 +- .../gerrit/server/git/ReceiveCommits.java | 34 +++++++------- .../git/ReceiveCommitsAdvertiseRefsHook.java | 5 ++- .../gerrit/server/git/VisibleRefFilter.java | 8 ++-- .../git/validators/CommitValidators.java | 4 +- .../git/validators/MergeValidators.java | 4 +- .../gerrit/server/patch/PatchListLoader.java | 3 +- .../server/project/DashboardsCollection.java | 2 +- .../gerrit/server/project/GetDashboard.java | 2 +- .../gerrit/server/project/ListBranches.java | 3 +- .../gerrit/server/project/ListDashboards.java | 2 +- .../gerrit/server/project/ListProjects.java | 3 +- .../server/project/PerformCreateProject.java | 3 +- .../gerrit/server/project/ProjectState.java | 3 +- .../gerrit/server/project/RefControl.java | 10 ++--- .../server/schema/AllProjectsCreator.java | 5 ++- .../gerrit/server/schema/Schema_53.java | 3 +- .../gerrit/server/schema/Schema_56.java | 9 ++-- .../gerrit/server/git/ProjectConfigTest.java | 5 ++- plugins/download-commands | 2 +- plugins/replication | 2 +- 40 files changed, 150 insertions(+), 105 deletions(-) create mode 100644 gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/RefNames.java diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/CreateProjectIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/CreateProjectIT.java index 68d04cb674..0643d7a854 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/CreateProjectIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/CreateProjectIT.java @@ -16,7 +16,6 @@ package com.google.gerrit.acceptance.rest.project; import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo; import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectOwners; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -30,6 +29,7 @@ import com.google.gerrit.acceptance.RestSession; import com.google.gerrit.acceptance.TestAccount; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.Project.InheritableBoolean; import com.google.gerrit.reviewdb.client.Project.SubmitType; import com.google.gerrit.server.account.GroupCache; @@ -180,7 +180,7 @@ public class CreateProjectIT extends AbstractDaemonTest { ProjectInput in = new ProjectInput(); in.permissions_only = true; session.put("/projects/" + newProjectName, in); - assertHead(newProjectName, GitRepositoryManager.REF_CONFIG); + assertHead(newProjectName, RefNames.REFS_CONFIG); } @Test diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectLevelConfigIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectLevelConfigIT.java index 9fd7568c64..a93a23a9d0 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectLevelConfigIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectLevelConfigIT.java @@ -27,9 +27,9 @@ import com.google.gerrit.acceptance.SshSession; import com.google.gerrit.acceptance.TestAccount; import com.google.gerrit.acceptance.git.PushOneCommit; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.config.AllProjectsNameProvider; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; import com.google.gwtorm.server.SchemaFactory; @@ -73,7 +73,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest { project = "p"; createProject(sshSession, project, null, true); git = cloneProject(sshSession.getUrl() + "/" + project); - fetch(git, GitRepositoryManager.REF_CONFIG + ":refs/heads/config"); + fetch(git, RefNames.REFS_CONFIG + ":refs/heads/config"); checkout(git, "refs/heads/config"); db = reviewDbProvider.open(); @@ -93,7 +93,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest { PushOneCommit push = new PushOneCommit(db, admin.getIdent(), "Create Project Level Config", configName, cfg.toText()); - push.to(git, GitRepositoryManager.REF_CONFIG); + push.to(git, RefNames.REFS_CONFIG); ProjectState state = projectCache.get(new Project.NameKey(project)); assertEquals(cfg.toText(), state.getConfig(configName).get().toText()); @@ -117,19 +117,19 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest { Git parentGit = cloneProject(sshSession.getUrl() + "/" + allProjects.get().get(), false); - fetch(parentGit, GitRepositoryManager.REF_CONFIG + ":refs/heads/config"); + fetch(parentGit, RefNames.REFS_CONFIG + ":refs/heads/config"); checkout(parentGit, "refs/heads/config"); PushOneCommit push = new PushOneCommit(db, admin.getIdent(), "Create Project Level Config", configName, parentCfg.toText()); - push.to(parentGit, GitRepositoryManager.REF_CONFIG); + push.to(parentGit, RefNames.REFS_CONFIG); Config cfg = new Config(); cfg.setString("s1", null, "k1", "childValue1"); cfg.setString("s2", "ss", "k3", "childValue2"); push = new PushOneCommit(db, admin.getIdent(), "Create Project Level Config", configName, cfg.toText()); - push.to(git, GitRepositoryManager.REF_CONFIG); + push.to(git, RefNames.REFS_CONFIG); ProjectState state = projectCache.get(new Project.NameKey(project)); diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectAccessEditor.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectAccessEditor.java index 02a19dc87d..1d7b960068 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectAccessEditor.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectAccessEditor.java @@ -23,6 +23,7 @@ import com.google.gerrit.common.data.AccessSection; import com.google.gerrit.common.data.ProjectAccess; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Style.Display; @@ -125,7 +126,7 @@ public class ProjectAccessEditor extends Composite implements history.getStyle().setDisplay(Display.BLOCK); gitweb.setText(c.getLinkName()); gitweb.setHref(c.toFileHistory(new Branch.NameKey(value.getProjectName(), - "refs/meta/config"), "project.config")); + RefNames.REFS_CONFIG), "project.config")); } else { history.getStyle().setDisplay(Display.NONE); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java index b7c82fbc3a..d84f9314c7 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/ProjectBranchesScreen.java @@ -34,6 +34,7 @@ import com.google.gerrit.client.ui.OnEditEnabler; import com.google.gerrit.common.PageLinks; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; @@ -394,7 +395,7 @@ public class ProjectBranchesScreen extends ProjectScreen { final FlexCellFormatter fmt = table.getFlexCellFormatter(); String iconCellStyle = Gerrit.RESOURCES.css().iconCell(); String dataCellStyle = Gerrit.RESOURCES.css().dataCell(); - if ("refs/meta/config".equals(k.getShortName()) + if (RefNames.REFS_CONFIG.equals(k.getShortName()) || "HEAD".equals(k.getShortName())) { iconCellStyle = Gerrit.RESOURCES.css().specialBranchIconCell(); dataCellStyle = Gerrit.RESOURCES.css().specialBranchDataCell(); diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ProjectAccessFactory.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ProjectAccessFactory.java index 8973132727..ee4439f49b 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ProjectAccessFactory.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ProjectAccessFactory.java @@ -27,10 +27,10 @@ import com.google.gerrit.common.errors.NoSuchGroupException; import com.google.gerrit.httpd.rpc.Handler; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.account.GroupBackend; import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.config.AllProjectsName; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.MetaDataUpdate; import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.project.NoSuchProjectException; @@ -113,7 +113,7 @@ class ProjectAccessFactory extends Handler { md.close(); } - final RefControl metaConfigControl = pc.controlForRef(GitRepositoryManager.REF_CONFIG); + final RefControl metaConfigControl = pc.controlForRef(RefNames.REFS_CONFIG); List local = new ArrayList(); Set ownerOf = new HashSet(); Map visibleGroups = new HashMap<>(); diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ReviewProjectAccess.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ReviewProjectAccess.java index 3b1f7f23c7..18af5a2e8a 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ReviewProjectAccess.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ReviewProjectAccess.java @@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSetAncestor; import com.google.gerrit.reviewdb.client.PatchSetInfo; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.RevId; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.ChangeUtil; @@ -35,7 +36,6 @@ import com.google.gerrit.server.change.ChangeResource; import com.google.gerrit.server.change.MergeabilityChecker; import com.google.gerrit.server.change.PostReviewers; import com.google.gerrit.server.config.AllProjectsNameProvider; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.MetaDataUpdate; import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.group.SystemGroupBackend; @@ -134,7 +134,7 @@ public class ReviewProjectAccess extends ProjectAccessHandler { user.getAccountId(), new Branch.NameKey( config.getProject().getNameKey(), - GitRepositoryManager.REF_CONFIG), + RefNames.REFS_CONFIG), TimeUtil.nowTs()); ps.setCreatedOn(change.getCreatedOn()); diff --git a/gerrit-pgm/BUCK b/gerrit-pgm/BUCK index ffa9cf46f0..9f397fceb2 100644 --- a/gerrit-pgm/BUCK +++ b/gerrit-pgm/BUCK @@ -18,6 +18,7 @@ java_library( deps = [ '//gerrit-common:annotations', '//gerrit-common:server', + '//gerrit-reviewdb:server', '//gerrit-server:server', '//lib:guava', '//lib/guice:guice', diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/AllProjectsConfig.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/AllProjectsConfig.java index 45ca87bb0c..b5f0768339 100644 --- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/AllProjectsConfig.java +++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/AllProjectsConfig.java @@ -14,8 +14,8 @@ package com.google.gerrit.pgm.init; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.config.SitePaths; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.git.VersionedMetaData; import com.google.inject.Inject; @@ -59,7 +59,7 @@ public class AllProjectsConfig extends VersionedMetaData { @Override protected String getRefName() { - return GitRepositoryManager.REF_CONFIG; + return RefNames.REFS_CONFIG; } public Config load() throws IOException, ConfigInvalidException { diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/PatchSet.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/PatchSet.java index 54c556dc7f..613978acb0 100644 --- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/PatchSet.java +++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/PatchSet.java @@ -14,6 +14,8 @@ package com.google.gerrit.reviewdb.client; +import static com.google.gerrit.reviewdb.client.RefNames.REFS_CHANGES; + import com.google.gwtorm.client.Column; import com.google.gwtorm.client.IntKey; @@ -21,8 +23,6 @@ import java.sql.Timestamp; /** A single revision of a {@link Change}. */ public final class PatchSet { - private static final String REFS_CHANGES = "refs/changes/"; - /** Is the reference name a change reference? */ public static boolean isRef(final String name) { if (name == null || !name.startsWith(REFS_CHANGES)) { diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/RefNames.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/RefNames.java new file mode 100644 index 0000000000..ede5c26c5d --- /dev/null +++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/RefNames.java @@ -0,0 +1,44 @@ +// Copyright (C) 2013 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.reviewdb.client; + +/** Constants and utilities for Gerrit-specific ref names. */ +public class RefNames { + public static final String REFS_CHANGES = "refs/changes/"; + + /** Note tree listing commits we refuse {@code refs/meta/reject-commits} */ + public static final String REFS_REJECT_COMMITS = "refs/meta/reject-commits"; + + /** Configuration settings for a project {@code refs/meta/config} */ + public static final String REFS_CONFIG = "refs/meta/config"; + + /** Configurations of project-specific dashboards (canned search queries). */ + public static final String REFS_DASHBOARDS = "refs/meta/dashboards/"; + + /** + * Prefix applied to merge commit base nodes. + *

+ * References in this directory should take the form + * {@code refs/cache-automerge/xx/yyyy...} where xx is + * the first two digits of the merge commit's object + * name, and yyyyy... is the remaining 38. The reference + * should point to a treeish that is the automatic merge + * result of the merge commit's parents. + */ + public static final String REFS_CACHE_AUTOMERGE = "refs/cache-automerge/"; + + private RefNames() { + } +} diff --git a/gerrit-server/src/main/java/com/google/gerrit/rules/PrologCompiler.java b/gerrit-server/src/main/java/com/google/gerrit/rules/PrologCompiler.java index 4ab3442519..ab57059815 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/rules/PrologCompiler.java +++ b/gerrit-server/src/main/java/com/google/gerrit/rules/PrologCompiler.java @@ -15,9 +15,9 @@ package com.google.gerrit.rules; import com.google.gerrit.common.Version; +import com.google.gerrit.reviewdb.client.RefNames; 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.util.TimeUtil; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; @@ -79,7 +79,7 @@ public class PrologCompiler implements Callable { } public Status call() throws IOException, CompileException { - ObjectId metaConfig = git.resolve(GitRepositoryManager.REF_CONFIG); + ObjectId metaConfig = git.resolve(RefNames.REFS_CONFIG); if (metaConfig == null) { return Status.NO_RULES; } diff --git a/gerrit-server/src/main/java/com/google/gerrit/rules/RulesCache.java b/gerrit-server/src/main/java/com/google/gerrit/rules/RulesCache.java index dad53b9f4c..4a3cd9a7ad 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/rules/RulesCache.java +++ b/gerrit-server/src/main/java/com/google/gerrit/rules/RulesCache.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.SitePaths; import com.google.gerrit.server.git.GitRepositoryManager; @@ -66,7 +67,7 @@ import java.util.Map; *

* Rules are loaded from the {@code site_path/cache/rules/rules-SHA1.jar}, where * {@code SHA1} is the SHA1 of the Prolog {@code rules.pl} in a project's - * {@link GitRepositoryManager#REF_CONFIG} branch. + * {@link RefNames#REFS_CONFIG} branch. */ @Singleton public class RulesCache { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/access/ListAccess.java b/gerrit-server/src/main/java/com/google/gerrit/server/access/ListAccess.java index 4002c1a73b..3a0a27d2d0 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/access/ListAccess.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/access/ListAccess.java @@ -29,11 +29,11 @@ import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.extensions.restapi.TopLevelResource; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.account.GroupBackend; import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.config.AllProjectsName; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.MetaDataUpdate; import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.group.GroupJson; @@ -154,7 +154,7 @@ public class ListAccess implements RestReadView { public ProjectAccessInfo(ProjectControl pc, ProjectConfig config) { final RefControl metaConfigControl = - pc.controlForRef(GitRepositoryManager.REF_CONFIG); + pc.controlForRef(RefNames.REFS_CONFIG); local = Maps.newHashMap(); ownerOf = Sets.newHashSet(); Map visibleGroups = diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/MergeabilityChecker.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/MergeabilityChecker.java index 53c6e7906d..c1f8598482 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/change/MergeabilityChecker.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/MergeabilityChecker.java @@ -28,11 +28,11 @@ import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.change.Mergeable.MergeableInfo; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.MetaDataUpdate; import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.git.WorkQueue.Executor; @@ -110,11 +110,11 @@ public class MergeabilityChecker implements GitReferenceUpdatedListener { @Override public void onGitReferenceUpdated(GitReferenceUpdatedListener.Event event) { String ref = event.getRefName(); - if (ref.startsWith(Constants.R_HEADS) || ref.equals(GitRepositoryManager.REF_CONFIG)) { + if (ref.startsWith(Constants.R_HEADS) || ref.equals(RefNames.REFS_CONFIG)) { executor.submit(new BranchUpdateTask(schemaFactory, new Project.NameKey(event.getProjectName()), ref)); } - if (ref.equals(GitRepositoryManager.REF_CONFIG)) { + if (ref.equals(RefNames.REFS_CONFIG)) { Project.NameKey p = new Project.NameKey(event.getProjectName()); try { ProjectConfig oldCfg = parseConfig(p, event.getOldObjectId()); @@ -124,7 +124,7 @@ public class MergeabilityChecker implements GitReferenceUpdatedListener { new ProjectUpdateTask(schemaFactory, p).call(); } catch (Exception e) { String msg = "Failed to update mergeability flags for project " + p.get() - + " on update of " + GitRepositoryManager.REF_CONFIG; + + " on update of " + RefNames.REFS_CONFIG; log.error(msg, e); Throwables.propagateIfPossible(e); throw new RuntimeException(msg, e); @@ -132,7 +132,7 @@ public class MergeabilityChecker implements GitReferenceUpdatedListener { } } catch (ConfigInvalidException | IOException e) { String msg = "Failed to update mergeability flags for project " + p.get() - + " on update of " + GitRepositoryManager.REF_CONFIG; + + " on update of " + RefNames.REFS_CONFIG; log.error(msg, e); throw new RuntimeException(msg, e); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/BanCommit.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/BanCommit.java index 6859262332..7a6415516a 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/BanCommit.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/BanCommit.java @@ -14,7 +14,7 @@ package com.google.gerrit.server.git; -import static com.google.gerrit.server.git.GitRepositoryManager.REF_REJECT_COMMITS; +import static com.google.gerrit.reviewdb.client.RefNames.REFS_REJECT_COMMITS; import com.google.gerrit.common.errors.PermissionDeniedException; import com.google.gerrit.reviewdb.client.Project; @@ -96,7 +96,7 @@ public class BanCommit { NotesBranchUtil notesBranchUtil = notesBranchUtilFactory.create(project, repo, inserter); NoteMap newlyCreated = - notesBranchUtil.commitNewNotes(banCommitNotes, REF_REJECT_COMMITS, + notesBranchUtil.commitNewNotes(banCommitNotes, REFS_REJECT_COMMITS, createPersonIdent(), buildCommitMessage(commitsToBan, reason)); for (Note n : banCommitNotes) { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ChangeCache.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ChangeCache.java index 32dc3032aa..eb4acfc59e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ChangeCache.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ChangeCache.java @@ -19,6 +19,7 @@ import com.google.common.cache.LoadingCache; import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.cache.CacheModule; import com.google.gwtorm.server.SchemaFactory; @@ -72,7 +73,7 @@ public class ChangeCache implements GitReferenceUpdatedListener { @Override public void onGitReferenceUpdated(GitReferenceUpdatedListener.Event event) { - if (event.getRefName().startsWith("refs/changes/")) { + if (event.getRefName().startsWith(RefNames.REFS_CHANGES)) { cache.invalidate(new Project.NameKey(event.getProjectName())); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/GitRepositoryManager.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/GitRepositoryManager.java index 0118404cce..ffb91cebf7 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/GitRepositoryManager.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/GitRepositoryManager.java @@ -31,27 +31,6 @@ import java.util.SortedSet; * environment. */ public interface GitRepositoryManager { - /** Note tree listing commits we refuse {@code refs/meta/reject-commits} */ - public static final String REF_REJECT_COMMITS = "refs/meta/reject-commits"; - - /** Configuration settings for a project {@code refs/meta/config} */ - public static final String REF_CONFIG = "refs/meta/config"; - - /** Configurations of project-specific dashboards (canned search queries). */ - public static String REFS_DASHBOARDS = "refs/meta/dashboards/"; - - /** - * Prefix applied to merge commit base nodes. - *

- * References in this directory should take the form - * {@code refs/cache-automerge/xx/yyyy...} where xx is - * the first two digits of the merge commit's object - * name, and yyyyy... is the remaining 38. The reference - * should point to a treeish that is the automatic merge - * result of the merge commit's parents. - */ - public static final String REFS_CACHE_AUTOMERGE = "refs/cache-automerge/"; - /** * Get (or open) a repository by name. * diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java index ee610fc2a5..16f8ee2b60 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java @@ -39,6 +39,7 @@ import com.google.gerrit.reviewdb.client.ChangeMessage; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.Project.SubmitType; import com.google.gerrit.reviewdb.client.RevId; import com.google.gerrit.reviewdb.server.ReviewDb; @@ -579,7 +580,7 @@ public class MergeOp { } if (mergeTip != null && (branchTip == null || branchTip != mergeTip)) { - if (GitRepositoryManager.REF_CONFIG.equals(branchUpdate.getName())) { + if (RefNames.REFS_CONFIG.equals(branchUpdate.getName())) { try { ProjectConfig cfg = new ProjectConfig(destProject.getProject().getNameKey()); @@ -606,7 +607,7 @@ public class MergeOp { mergeTip); } - if (GitRepositoryManager.REF_CONFIG.equals(branchUpdate.getName())) { + if (RefNames.REFS_CONFIG.equals(branchUpdate.getName())) { projectCache.evict(destProject.getProject()); destProject = projectCache.get(destProject.getProject().getNameKey()); repoManager.setProjectDescription( diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java index 3a29587bfb..97ae74697b 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectConfig.java @@ -40,6 +40,7 @@ import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.common.data.PermissionRule.Action; import com.google.gerrit.common.data.RefConfigSection; import com.google.gerrit.reviewdb.client.AccountGroup; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.AccountProjectWatch.NotifyType; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project.State; @@ -370,7 +371,7 @@ public class ProjectConfig extends VersionedMetaData { @Override protected String getRefName() { - return GitRepositoryManager.REF_CONFIG; + return RefNames.REFS_CONFIG; } @Override diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectLevelConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectLevelConfig.java index fc95608e2e..476ccae21b 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectLevelConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ProjectLevelConfig.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.git; import com.google.common.collect.Iterables; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.project.ProjectState; import org.eclipse.jgit.errors.ConfigInvalidException; @@ -38,7 +39,7 @@ public class ProjectLevelConfig extends VersionedMetaData { @Override protected String getRefName() { - return GitRepositoryManager.REF_CONFIG; + return RefNames.REFS_CONFIG; } @Override diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java index 611ce52552..be4b0ce9a6 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.git; +import static com.google.gerrit.reviewdb.client.RefNames.REFS_CHANGES; import static com.google.gerrit.server.git.MultiProgressMonitor.UNKNOWN; import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromApprovals; import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters; @@ -58,6 +59,7 @@ import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.PatchSetInfo; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.RevId; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.ApprovalsUtil; @@ -156,8 +158,8 @@ public class ReceiveCommits { private static final Logger log = LoggerFactory.getLogger(ReceiveCommits.class); - public static final Pattern NEW_PATCHSET = - Pattern.compile("^refs/changes/(?:[0-9][0-9]/)?([1-9][0-9]*)(?:/new)?$"); + public static final Pattern NEW_PATCHSET = Pattern.compile( + "^" + REFS_CHANGES + "(?:[0-9][0-9]/)?([1-9][0-9]*)(?:/new)?$"); private static final FooterKey CHANGE_ID = new FooterKey("Change-Id"); @@ -168,12 +170,12 @@ public class ReceiveCommits { private enum Error { CONFIG_UPDATE("You are not allowed to perform this operation.\n" + "Configuration changes can only be pushed by project owners\n" - + "who also have 'Push' rights on " + GitRepositoryManager.REF_CONFIG), + + "who also have 'Push' rights on " + RefNames.REFS_CONFIG), UPDATE("You are not allowed to perform this operation.\n" + "To push into this reference you need 'Push' rights."), DELETE("You need 'Push' rights with the 'Force Push'\n" + "flag set to delete references."), - DELETE_CHANGES("Cannot delete from 'refs/changes'"), + DELETE_CHANGES("Cannot delete from '" + REFS_CHANGES + "'"), CODE_REVIEW("You need 'Push' rights to upload code review requests.\n" + "Verify that you are pushing to the right branch."); @@ -397,8 +399,8 @@ public class ReceiveCommits { Map filteredRefs = Maps.newHashMapWithExpectedSize(refs.size()); for (Map.Entry e : refs.entrySet()) { String name = e.getKey(); - if (!name.startsWith("refs/changes/") - && !name.startsWith(GitRepositoryManager.REFS_CACHE_AUTOMERGE)) { + if (!name.startsWith(REFS_CHANGES) + && !name.startsWith(RefNames.REFS_CACHE_AUTOMERGE)) { filteredRefs.put(name, e.getValue()); } } @@ -914,8 +916,8 @@ public class ReceiveCommits { validateNewCommits(ctl, cmd); batch.addCommand(cmd); } else { - if (GitRepositoryManager.REF_CONFIG.equals(ctl.getRefName())) { - errors.put(Error.CONFIG_UPDATE, GitRepositoryManager.REF_CONFIG); + if (RefNames.REFS_CONFIG.equals(ctl.getRefName())) { + errors.put(Error.CONFIG_UPDATE, RefNames.REFS_CONFIG); } else { errors.put(Error.UPDATE, ctl.getRefName()); } @@ -944,13 +946,13 @@ public class ReceiveCommits { private void parseDelete(final ReceiveCommand cmd) { RefControl ctl = projectControl.controlForRef(cmd.getRefName()); - if (ctl.getRefName().startsWith("refs/changes/")) { + if (ctl.getRefName().startsWith(REFS_CHANGES)) { errors.put(Error.DELETE_CHANGES, ctl.getRefName()); reject(cmd, "cannot delete changes"); } else if (ctl.canDelete()) { batch.addCommand(cmd); } else { - if (GitRepositoryManager.REF_CONFIG.equals(ctl.getRefName())) { + if (RefNames.REFS_CONFIG.equals(ctl.getRefName())) { reject(cmd, "cannot delete project configuration"); } else { errors.put(Error.DELETE, ctl.getRefName()); @@ -1222,7 +1224,7 @@ public class ReceiveCommits { */ private NoteMap loadRejectCommitsMap() throws IOException { try { - Ref ref = repo.getRef(GitRepositoryManager.REF_REJECT_COMMITS); + Ref ref = repo.getRef(RefNames.REFS_REJECT_COMMITS); if (ref == null) { return NoteMap.newEmptyMap(); } @@ -1232,7 +1234,7 @@ public class ReceiveCommits { return NoteMap.read(rw.getObjectReader(), map); } catch (IOException badMap) { throw new IOException("Cannot load " - + GitRepositoryManager.REF_REJECT_COMMITS, badMap); + + RefNames.REFS_REJECT_COMMITS, badMap); } } @@ -1424,7 +1426,7 @@ public class ReceiveCommits { for (Ref ref : allRefs.values()) { if (ref.getObjectId() == null) { continue; - } else if (ref.getName().startsWith("refs/changes/")) { + } else if (ref.getName().startsWith(REFS_CHANGES)) { existing.add(ref.getObjectId()); } else if (ref.getName().startsWith(R_HEADS) || (forRef != null && forRef.equals(ref.getName()))) { @@ -2057,7 +2059,7 @@ public class ReceiveCommits { && ctl.canUploadMerges() && !projectControl.getProjectState().isUseSignedOffBy() && Iterables.isEmpty(rejectCommits) - && !GitRepositoryManager.REF_CONFIG.equals(ctl.getRefName()) + && !RefNames.REFS_CONFIG.equals(ctl.getRefName()) && !(MagicBranch.isMagicBranch(cmd.getRefName()) || NEW_PATCHSET.matcher(cmd.getRefName()).matches())) { return; @@ -2233,7 +2235,7 @@ public class ReceiveCommits { private SetMultimap changeRefsById() throws IOException { if (refsById == null) { refsById = HashMultimap.create(); - for (Ref r : repo.getRefDatabase().getRefs("refs/changes/").values()) { + for (Ref r : repo.getRefDatabase().getRefs(REFS_CHANGES).values()) { if (PatchSet.isRef(r.getName())) { refsById.put(r.getObjectId(), r); } @@ -2340,6 +2342,6 @@ public class ReceiveCommits { } private static boolean isConfig(final ReceiveCommand cmd) { - return cmd.getRefName().equals(GitRepositoryManager.REF_CONFIG); + return cmd.getRefName().equals(RefNames.REFS_CONFIG); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommitsAdvertiseRefsHook.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommitsAdvertiseRefsHook.java index f34ce8bbfe..7ae8271db7 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommitsAdvertiseRefsHook.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommitsAdvertiseRefsHook.java @@ -21,6 +21,7 @@ import com.google.common.collect.Sets; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.util.MagicBranch; import com.google.gwtorm.server.OrmException; @@ -164,8 +165,8 @@ public class ReceiveCommitsAdvertiseRefsHook implements AdvertiseRefsHook { } private static boolean skip(String name) { - return name.startsWith("refs/changes/") - || name.startsWith(GitRepositoryManager.REFS_CACHE_AUTOMERGE) + return name.startsWith(RefNames.REFS_CHANGES) + || name.startsWith(RefNames.REFS_CACHE_AUTOMERGE) || MagicBranch.isMagicBranch(name); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/VisibleRefFilter.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/VisibleRefFilter.java index 14aae947a2..343b49c23a 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/VisibleRefFilter.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/VisibleRefFilter.java @@ -19,9 +19,11 @@ import com.google.common.collect.Maps; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.project.ProjectControl; import com.google.gwtorm.server.OrmException; + import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.RefDatabase; @@ -68,9 +70,9 @@ public class VisibleRefFilter extends AbstractAdvertiseRefsHook { public Map filter(Map refs, boolean filterTagsSeperately) { if (projectCtl.allRefsAreVisibleExcept( - ImmutableSet.of(GitRepositoryManager.REF_CONFIG))) { + ImmutableSet.of(RefNames.REFS_CONFIG))) { Map r = Maps.newHashMap(refs); - r.remove(GitRepositoryManager.REF_CONFIG); + r.remove(RefNames.REFS_CONFIG); return r; } @@ -79,7 +81,7 @@ public class VisibleRefFilter extends AbstractAdvertiseRefsHook { final List deferredTags = new ArrayList(); for (Ref ref : refs.values()) { - if (ref.getName().startsWith(GitRepositoryManager.REFS_CACHE_AUTOMERGE)) { + if (ref.getName().startsWith(RefNames.REFS_CACHE_AUTOMERGE)) { continue; } else if (PatchSet.isRef(ref.getName())) { // Reference to a patch set is visible if the change is visible. diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java index 05dbf0e2f2..3c6c9ea252 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java @@ -18,12 +18,12 @@ import com.google.common.base.CharMatcher; import com.google.gerrit.common.Nullable; import com.google.gerrit.common.PageLinks; import com.google.gerrit.extensions.registration.DynamicSet; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.config.CanonicalWebUrl; import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.events.CommitReceivedEvent; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.git.ReceiveCommits; import com.google.gerrit.server.git.ValidationError; @@ -311,7 +311,7 @@ public class CommitValidators { CommitReceivedEvent receiveEvent) throws CommitValidationException { IdentifiedUser currentUser = (IdentifiedUser) refControl.getCurrentUser(); - if (GitRepositoryManager.REF_CONFIG.equals(refControl.getRefName())) { + if (RefNames.REFS_CONFIG.equals(refControl.getRefName())) { List messages = new LinkedList(); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/MergeValidators.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/MergeValidators.java index 6eed909ee0..0370d36c5a 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/MergeValidators.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/MergeValidators.java @@ -22,12 +22,12 @@ import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.PatchSet; import com.google.gerrit.reviewdb.client.PatchSetApproval; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.config.AllProjectsName; import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.CommitMergeStatus; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.ProjectConfig; import com.google.gerrit.server.project.ProjectCache; import com.google.gerrit.server.project.ProjectState; @@ -96,7 +96,7 @@ public class MergeValidators { final Branch.NameKey destBranch, final PatchSet.Id patchSetId) throws MergeValidationException { - if (GitRepositoryManager.REF_CONFIG.equals(destBranch.get())) { + if (RefNames.REFS_CONFIG.equals(destBranch.get())) { final Project.NameKey newParent; try { ProjectConfig cfg = diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java index 7d521f2a05..2cda3346ca 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java @@ -18,6 +18,7 @@ package com.google.gerrit.server.patch; import com.google.common.cache.CacheLoader; import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace; import com.google.gerrit.reviewdb.client.Patch; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.inject.Inject; @@ -249,7 +250,7 @@ public class PatchListLoader extends CacheLoader { public static RevTree automerge(Repository repo, RevWalk rw, RevCommit b, boolean save) throws IOException { String hash = b.name(); - String refName = GitRepositoryManager.REFS_CACHE_AUTOMERGE + String refName = RefNames.REFS_CACHE_AUTOMERGE + hash.substring(0, 2) + "/" + hash.substring(2); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/DashboardsCollection.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/DashboardsCollection.java index 6e5ef65464..3df8e2feb4 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/DashboardsCollection.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/DashboardsCollection.java @@ -14,7 +14,7 @@ package com.google.gerrit.server.project; -import static com.google.gerrit.server.git.GitRepositoryManager.REFS_DASHBOARDS; +import static com.google.gerrit.reviewdb.client.RefNames.REFS_DASHBOARDS; import com.google.common.base.Joiner; import com.google.common.base.Objects; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/GetDashboard.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/GetDashboard.java index fcd2284b66..8acc29e608 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/GetDashboard.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/GetDashboard.java @@ -14,7 +14,7 @@ package com.google.gerrit.server.project; -import static com.google.gerrit.server.git.GitRepositoryManager.REFS_DASHBOARDS; +import static com.google.gerrit.reviewdb.client.RefNames.REFS_DASHBOARDS; import com.google.common.base.Splitter; import com.google.common.base.Strings; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ListBranches.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ListBranches.java index 7ed5b5fd3c..92f71e5bfd 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ListBranches.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ListBranches.java @@ -18,6 +18,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.RestReadView; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.inject.Inject; @@ -115,7 +116,7 @@ public class ListBranches implements RestReadView { if (refControl.isVisible()) { if (ref.getName().startsWith(Constants.R_HEADS)) { branches.add(createBranchInfo(ref, refControl, targets)); - } else if (GitRepositoryManager.REF_CONFIG.equals(ref.getName())) { + } else if (RefNames.REFS_CONFIG.equals(ref.getName())) { configBranch = createBranchInfo(ref, refControl, targets); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ListDashboards.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ListDashboards.java index e3247fcf54..fbfcc8f604 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ListDashboards.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ListDashboards.java @@ -14,7 +14,7 @@ package com.google.gerrit.server.project; -import static com.google.gerrit.server.git.GitRepositoryManager.REFS_DASHBOARDS; +import static com.google.gerrit.reviewdb.client.RefNames.REFS_DASHBOARDS; import com.google.common.collect.Lists; import com.google.gerrit.extensions.restapi.ResourceNotFoundException; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ListProjects.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ListProjects.java index 3d3943c829..6cfc7b45c2 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ListProjects.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ListProjects.java @@ -26,6 +26,7 @@ import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.extensions.restapi.TopLevelResource; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.OutputFormat; import com.google.gerrit.server.StringUtil; @@ -85,7 +86,7 @@ public class ListProjects implements RestReadView { Ref head = git.getRef(Constants.HEAD); return head != null && head.isSymbolic() - && GitRepositoryManager.REF_CONFIG.equals(head.getLeaf().getName()); + && RefNames.REFS_CONFIG.equals(head.getLeaf().getName()); } }, ALL { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/PerformCreateProject.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/PerformCreateProject.java index 8a6303f14a..ca006de93c 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/PerformCreateProject.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/PerformCreateProject.java @@ -26,6 +26,7 @@ import com.google.gerrit.extensions.events.NewProjectCreatedListener; import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.Project.SubmitType; import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.IdentifiedUser; @@ -109,7 +110,7 @@ public class PerformCreateProject { final Project.NameKey nameKey = createProjectArgs.getProject(); try { final String head = - createProjectArgs.permissionsOnly ? GitRepositoryManager.REF_CONFIG + createProjectArgs.permissionsOnly ? RefNames.REFS_CONFIG : createProjectArgs.branch.get(0); final Repository repo = repoManager.createRepository(nameKey); try { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectState.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectState.java index 2e79e2f8c4..eceb509a99 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectState.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectState.java @@ -30,6 +30,7 @@ import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.Project.InheritableBoolean; import com.google.gerrit.rules.PrologEnvironment; import com.google.gerrit.rules.RulesCache; @@ -164,7 +165,7 @@ public class ProjectState { try { Repository git = gitMgr.openRepository(getProject().getNameKey()); try { - Ref ref = git.getRef(GitRepositoryManager.REF_CONFIG); + Ref ref = git.getRef(RefNames.REFS_CONFIG); if (ref == null || ref.getObjectId() == null) { return true; } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java index 03977484e2..5b215328cb 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java @@ -23,10 +23,10 @@ import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.common.data.RefConfigSection; import com.google.gerrit.common.errors.InvalidNameException; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.InternalUser; -import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.group.SystemGroupBackend; import dk.brics.automaton.RegExp; @@ -161,7 +161,7 @@ public class RefControl { /** @return true if this user can submit patch sets to this ref */ public boolean canSubmit() { - if (GitRepositoryManager.REF_CONFIG.equals(refName)) { + if (RefNames.REFS_CONFIG.equals(refName)) { // Always allow project owners to submit configuration changes. // Submitting configuration changes modifies the access control // rules. Allowing this to be done by a non-project-owner opens @@ -175,7 +175,7 @@ public class RefControl { /** @return true if the user can update the reference as a fast-forward. */ public boolean canUpdate() { - if (GitRepositoryManager.REF_CONFIG.equals(refName) + if (RefNames.REFS_CONFIG.equals(refName) && !projectControl.isOwner()) { // Pushing requires being at least project owner, in addition to push. // Pushing configuration changes modifies the access control @@ -211,7 +211,7 @@ public class RefControl { } private boolean canPushWithForce() { - if (!canWrite() || (GitRepositoryManager.REF_CONFIG.equals(refName) + if (!canWrite() || (RefNames.REFS_CONFIG.equals(refName) && !projectControl.isOwner())) { // Pushing requires being at least project owner, in addition to push. // Pushing configuration changes modifies the access control @@ -294,7 +294,7 @@ public class RefControl { * @return {@code true} if the user specified can delete a Git ref. */ public boolean canDelete() { - if (!canWrite() || (GitRepositoryManager.REF_CONFIG.equals(refName))) { + if (!canWrite() || (RefNames.REFS_CONFIG.equals(refName))) { // Never allow removal of the refs/meta/config branch. // Deleting the branch would destroy all Gerrit specific // metadata about the project, including its access rules. diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/AllProjectsCreator.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/AllProjectsCreator.java index 6c4569b3e3..99ed71f265 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/AllProjectsCreator.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/AllProjectsCreator.java @@ -29,6 +29,7 @@ import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.common.data.PermissionRule.Action; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.Project.InheritableBoolean; import com.google.gerrit.server.GerritPersonIdent; import com.google.gerrit.server.config.AllProjectsName; @@ -97,7 +98,7 @@ public class AllProjectsCreator { initAllProjects(git); RefUpdate u = git.updateRef(Constants.HEAD); - u.link(GitRepositoryManager.REF_CONFIG); + u.link(RefNames.REFS_CONFIG); } catch (RepositoryNotFoundException err) { String name = allProjectsName.get(); throw new IOException("Cannot create repository " + name, err); @@ -131,7 +132,7 @@ public class AllProjectsCreator { AccessSection all = config.getAccessSection(AccessSection.ALL, true); AccessSection heads = config.getAccessSection(AccessSection.HEADS, true); AccessSection tags = config.getAccessSection("refs/tags/*", true); - AccessSection meta = config.getAccessSection(GitRepositoryManager.REF_CONFIG, true); + AccessSection meta = config.getAccessSection(RefNames.REFS_CONFIG, true); AccessSection magic = config.getAccessSection("refs/for/" + AccessSection.ALL, true); grant(config, cap, GlobalCapability.ADMINISTRATE_SERVER, admin); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_53.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_53.java index e5f6992ab5..cbcda9f4bc 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_53.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_53.java @@ -32,6 +32,7 @@ import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.reviewdb.client.AccountGroup; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.client.PatchSetApproval.LabelId; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.Project.InheritableBoolean; @@ -186,7 +187,7 @@ class Schema_53 extends SchemaVersion { // Grant out read on the config branch by default. // if (config.getProject().getNameKey().equals(systemConfig.wildProjectName)) { - AccessSection meta = config.getAccessSection(GitRepositoryManager.REF_CONFIG, true); + AccessSection meta = config.getAccessSection(RefNames.REFS_CONFIG, true); Permission read = meta.getPermission(READ, true); read.getRule(config.resolve(projectOwners), true); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_56.java b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_56.java index 3ba77ec7d5..bcd5f40289 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_56.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_56.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.schema; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.inject.Inject; @@ -44,8 +45,8 @@ public class Schema_56 extends SchemaVersion { keysOne = new HashSet(); keysTwo = new HashSet(); - keysOne.add(GitRepositoryManager.REF_CONFIG); - keysTwo.add(GitRepositoryManager.REF_CONFIG); + keysOne.add(RefNames.REFS_CONFIG); + keysTwo.add(RefNames.REFS_CONFIG); keysTwo.add(Constants.HEAD); } @@ -73,10 +74,10 @@ public class Schema_56 extends SchemaVersion { try { RefUpdate update = git.updateRef(Constants.HEAD); update.disableRefLog(); - update.link(GitRepositoryManager.REF_CONFIG); + update.link(RefNames.REFS_CONFIG); } catch (IOException err) { ui.message("warning: " + name.get() + ": Cannot update HEAD to " - + GitRepositoryManager.REF_CONFIG + ": " + err.getMessage()); + + RefNames.REFS_CONFIG + ": " + err.getMessage()); } } } finally { diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/git/ProjectConfigTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/git/ProjectConfigTest.java index 0d5207aec2..1a9f74bc79 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/git/ProjectConfigTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/git/ProjectConfigTest.java @@ -28,6 +28,7 @@ import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RefNames; import com.google.gerrit.server.extensions.events.GitReferenceUpdated; import org.eclipse.jgit.errors.ConfigInvalidException; @@ -208,12 +209,12 @@ public class ProjectConfigTest extends LocalDiskRepositoryTestCase { md.setMessage("Edit\n"); cfg.commit(md); - Ref ref = db.getRef(GitRepositoryManager.REF_CONFIG); + Ref ref = db.getRef(RefNames.REFS_CONFIG); return util.getRevWalk().parseCommit(ref.getObjectId()); } private void update(RevCommit rev) throws Exception { - RefUpdate u = db.updateRef(GitRepositoryManager.REF_CONFIG); + RefUpdate u = db.updateRef(RefNames.REFS_CONFIG); u.disableRefLog(); u.setNewObjectId(rev); switch (u.forceUpdate()) { diff --git a/plugins/download-commands b/plugins/download-commands index 7eb3360a89..6287d6a894 160000 --- a/plugins/download-commands +++ b/plugins/download-commands @@ -1 +1 @@ -Subproject commit 7eb3360a89282ceaa404bcade5137cc5eb62945f +Subproject commit 6287d6a8941f68ba8a3a8c27f2a979c02ede489a diff --git a/plugins/replication b/plugins/replication index 400f47b991..330228ed74 160000 --- a/plugins/replication +++ b/plugins/replication @@ -1 +1 @@ -Subproject commit 400f47b99183a9141a192956bac6863f1c2fc14d +Subproject commit 330228ed74629db4ed43e48d2d10925c0d7d2ff8