// 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.googlesource.gerrit.plugins.download.command;

import static com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadCommand.REPO_DOWNLOAD;

import com.google.gerrit.extensions.config.DownloadCommand;
import com.google.gerrit.extensions.config.DownloadScheme;
import com.google.gerrit.server.config.DownloadConfig;
import com.google.inject.Inject;

import com.googlesource.gerrit.plugins.download.scheme.RepoScheme;

public class RepoCommand extends DownloadCommand {
  private final boolean commandAllowed;

  @Inject
  RepoCommand(DownloadConfig downloadConfig) {
    this.commandAllowed = downloadConfig.getDownloadCommands().contains(REPO_DOWNLOAD);
  }

  @Override
  public String getCommand(DownloadScheme scheme, String project, String ref) {
    if (!commandAllowed || !(scheme instanceof RepoScheme)) {
      return null;
    }

    return scheme.getUrl(project) + " " + ref;
  }
}

@@ -1385,17 +1385,16 @@
     if (
-!
 commandA
@@ -1404,13 +1404,11 @@
 wed 
-%7C%7C !(
+&& 
 sche
@@ -1436,38 +1436,13 @@
 eme)
-)
  %7B%0A  
-    return null;%0A    %7D%0A%0A
     
@@ -1484,14 +1484,37 @@
  + ref;%0A
+    %7D%0A    return null;%0A
   %7D%0A%7D%0A

Simplify logic in RepoCommand