Merge "Allow admins to disable magic ref check on upload"
This commit is contained in:
@@ -23,5 +23,6 @@ public class GitModule extends FactoryModule {
|
||||
factory(RenameGroupOp.Factory.class);
|
||||
factory(MetaDataUpdate.InternalFactory.class);
|
||||
bind(MetaDataUpdate.Server.class);
|
||||
bind(ReceiveConfig.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountResolver;
|
||||
import com.google.gerrit.server.config.AllProjectsName;
|
||||
import com.google.gerrit.server.config.CanonicalWebUrl;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.TrackingFooters;
|
||||
import com.google.gerrit.server.events.CommitReceivedEvent;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
@@ -91,7 +90,6 @@ import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.BatchRefUpdate;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectReader;
|
||||
@@ -252,6 +250,7 @@ public class ReceiveCommits {
|
||||
private final RequestScopePropagator requestScopePropagator;
|
||||
private final SshInfo sshInfo;
|
||||
private final AllProjectsName allProjectsName;
|
||||
private final ReceiveConfig receiveConfig;
|
||||
|
||||
private final ProjectControl projectControl;
|
||||
private final Project project;
|
||||
@@ -304,7 +303,7 @@ public class ReceiveCommits {
|
||||
final RequestScopePropagator requestScopePropagator,
|
||||
final SshInfo sshInfo,
|
||||
final AllProjectsName allProjectsName,
|
||||
final @GerritServerConfig Config config,
|
||||
ReceiveConfig config,
|
||||
@Assisted final ProjectControl projectControl,
|
||||
@Assisted final Repository repo,
|
||||
final SubmoduleOp.Factory subOpFactory) throws IOException {
|
||||
@@ -330,6 +329,7 @@ public class ReceiveCommits {
|
||||
this.requestScopePropagator = requestScopePropagator;
|
||||
this.sshInfo = sshInfo;
|
||||
this.allProjectsName = allProjectsName;
|
||||
this.receiveConfig = config;
|
||||
|
||||
this.projectControl = projectControl;
|
||||
this.project = projectControl.getProject();
|
||||
@@ -347,8 +347,7 @@ public class ReceiveCommits {
|
||||
rp.setCheckReceivedObjects(true);
|
||||
|
||||
if (!projectControl.allRefsAreVisible()) {
|
||||
rp.setCheckReferencedObjectsAreReachable(config.getBoolean("receive",
|
||||
null, "checkReferencedObjectsAreReachable", true));
|
||||
rp.setCheckReferencedObjectsAreReachable(config.checkReferencedObjectsAreReachable);
|
||||
rp.setAdvertiseRefsHook(new VisibleRefFilter(tagCache, changeCache, repo, projectControl, db, false));
|
||||
}
|
||||
List<AdvertiseRefsHook> advHooks = new ArrayList<AdvertiseRefsHook>(3);
|
||||
@@ -482,8 +481,10 @@ public class ReceiveCommits {
|
||||
if (result != Capable.OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return MagicBranch.checkMagicBranchRefs(repo, project);
|
||||
if (receiveConfig.checkMagicRefs) {
|
||||
result = MagicBranch.checkMagicBranchRefs(repo, project);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addMessage(String message) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// 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.server.git;
|
||||
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
|
||||
@Singleton
|
||||
class ReceiveConfig {
|
||||
final boolean checkMagicRefs;
|
||||
final boolean checkReferencedObjectsAreReachable;
|
||||
|
||||
@Inject
|
||||
ReceiveConfig(@GerritServerConfig Config config) {
|
||||
checkMagicRefs = config.getBoolean(
|
||||
"receive", null, "checkMagicRefs",
|
||||
true);
|
||||
checkReferencedObjectsAreReachable = config.getBoolean(
|
||||
"receive", null, "checkReferencedObjectsAreReachable",
|
||||
true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user