Revert "Add the ability to access different SCM repositories"

Revert submission 452805

Reason for revert: This change broke UpdateGitMetricsTaskTest

Reverted changes: /q/submissionid:452805

Change-Id: I9ee325dbff6de70730139cc96cce6d3e75a33304
diff --git a/BUILD b/BUILD
index 319fe9f..7370013 100644
--- a/BUILD
+++ b/BUILD
@@ -21,8 +21,7 @@
     ],
     resources = glob(
         ["src/main/resources/**/*"],
-    ),
-    deps = ["@commons-codec//jar"],
+    )
 )
 
 java_library(
diff --git a/README.md b/README.md
index 987d373..da92331 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,6 @@
 # Plugin to collect Git repository metrics
 
-This plugin allows a systematic collection of repository metrics. It's primary use-case is
-with Gerrit, however it's possible for it to work with multiple Git SCM systems, including bare
-Git repositories.
-
+This plugin allows a systematic collection of repository metrics.
 Metrics are updated upon a `ref-update` receive.
 
 ## How to build
@@ -26,26 +23,11 @@
 bazel-genfiles/plugins/git-repo-metrics/git-repo-metrics.jar
 ```
 
-## How to install with Gerrit
+## How to install
 
 Copy the git-repo-metrics.jar into the Gerrit's /plugins directory and wait for the plugin to be automatically
 loaded.
 
-## How to install with a different SCM
-
-This plugin can also work with Git repositories hosted by other Git based SCM tools,
-however the metrics are still expose via Gerrit, so a dedicated Gerrit instance running alongside
-the current SCM tool is still required.
-So to make this plugin work with other Git SCM tools, a Gerrit installation needs to be set-up and
-the `basePath` needs to be set to the git data directory of the tool of choice.
-You will also need to set `gracePeriod` and `forceCollection`, as when using a different SCM tool
-than Gerrit the usual hooks aren't triggered.
-Finally, a configuration option will need to be specified to indicate which Backend is being used.
-Currently supported backend, other than GERRIT are:
-- GITLAB
-
-Find more in the configuration section below.
-
 ## Configuration
 
 More information about the plugin configuration can be found in the [config.md](src/resources/Documentation/config.md)
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/GitBackend.java b/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/GitBackend.java
deleted file mode 100644
index 9c98e41..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/GitBackend.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (C) 2022 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.gitrepometrics;
-
-import org.apache.commons.codec.digest.DigestUtils;
-
-public enum GitBackend {
-  GERRIT {
-    @Override
-    public String repoPath(String projectName) {
-      return projectName;
-    }
-  },
-
-  GITLAB {
-    @Override
-    public String repoPath(String projectName) {
-      String sha256OfProjectName = DigestUtils.sha256Hex(projectName);
-      return String.format("%s/%s/%s.git",
-          sha256OfProjectName.substring(0, 2),
-          sha256OfProjectName.substring(2, 4),
-          sha256OfProjectName);
-    }
-  };
-
-  abstract String repoPath(String projectName);
-
-}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/GitRepoMetricsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/GitRepoMetricsConfig.java
index bd80489..83719a3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/GitRepoMetricsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/GitRepoMetricsConfig.java
@@ -51,8 +51,4 @@
   public int getPoolSize() {
     return config.getInt("git-repo-metrics", null, "poolSize", 1);
   }
-
-  public GitBackend getGitBackend() {
-    return config.getEnum("git-repo-metrics", null, "gitBackend", GitBackend.GERRIT);
-  }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/UpdateGitMetricsTask.java b/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/UpdateGitMetricsTask.java
index 14ab53e..838429e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/UpdateGitMetricsTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/UpdateGitMetricsTask.java
@@ -39,23 +39,20 @@
   private final String projectName;
   private GitRepoMetricsCache gitRepoMetricsCache;
   private GitRepositoryManager repoManager;
-  private GitBackend gitBackend;
 
   @Inject
   UpdateGitMetricsTask(
       GitRepoMetricsCache gitRepoMetricsCache,
       GitRepositoryManager repoManager,
-      GitRepoMetricsConfig config,
       @Assisted String projectName) {
     this.projectName = projectName;
     this.gitRepoMetricsCache = gitRepoMetricsCache;
     this.repoManager = repoManager;
-    this.gitBackend = config.getGitBackend();
   }
 
   @Override
   public void run() {
-    Project.NameKey projectNameKey = Project.nameKey(gitBackend.repoPath(projectName));
+    Project.NameKey projectNameKey = Project.nameKey(projectName);
     try (Repository repository = repoManager.openRepository(projectNameKey)) {
       logger.atInfo().log(
           "Running task to collect stats: repo %s, project %s",
diff --git a/src/resources/Documentation/config.md b/src/resources/Documentation/config.md
index 28e2aa7..2c0f39c 100644
--- a/src/resources/Documentation/config.md
+++ b/src/resources/Documentation/config.md
@@ -38,7 +38,6 @@
   project = test-project
   project = another-repo
   gracePeriod = 5m
-  backend = GERRIT
 ```
 _git-repo-metrics.forcedCollection_: Force the repositories' metric collection update every
 _gracePeriod_ interval. By default, disabled.
@@ -49,11 +48,4 @@
 _git-repo-metrics.gracePeriod_: Grace period between samples collection. Used to avoid aggressive
 metrics collection. By default, 0.
 
-_git-repo-metrics.poolSize_: Number of threads available to collect metrics. By default, 1.
-_git-repo-metrics.gitBackend_: Name of the Git SCM tool managing the Git data, for which this tools will expose
-metrics.
-
-Currently supported values:
-- GERRIT (default)
-- GITLAB
-
+_git-repo-metrics.poolSize_: Number of threads available to collect metrics. By default, 1.
\ No newline at end of file
diff --git a/src/test/java/com/googlesource/gerrit/plugins/gitrepometrics/GitRepoMetricsCacheIT.java b/src/test/java/com/googlesource/gerrit/plugins/gitrepometrics/GitRepoMetricsCacheIT.java
index 087899a..4eee736 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/gitrepometrics/GitRepoMetricsCacheIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/gitrepometrics/GitRepoMetricsCacheIT.java
@@ -27,11 +27,8 @@
 import com.googlesource.gerrit.plugins.gitrepometrics.collectors.FSMetricsCollector;
 import com.googlesource.gerrit.plugins.gitrepometrics.collectors.GitRefsMetricsCollector;
 import com.googlesource.gerrit.plugins.gitrepometrics.collectors.GitStatsMetricsCollector;
-
-import java.io.IOException;
 import java.time.Duration;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import org.junit.Test;
 
@@ -69,11 +66,10 @@
       pluginName = "git-repo-metrics",
       name = "git-repo-metrics.project",
       values = {"testProject1", "testProject2"})
-  public void shouldRegisterAllMetrics() throws IOException {
-    ConfigSetupUtils configSetupUtils = new ConfigSetupUtils(Arrays.asList("testProject1", "testProject2"));
+  public void shouldRegisterAllMetrics() {
     List<Project.NameKey> availableProjects = Arrays.asList(testProject1, testProject2);
-    new UpdateGitMetricsTask(gitRepoMetricsCache, repoManager, configSetupUtils.getGitRepoMetricsConfig(), testProject1.get()).run();
-    new UpdateGitMetricsTask(gitRepoMetricsCache, repoManager, configSetupUtils.getGitRepoMetricsConfig(), testProject2.get()).run();
+    new UpdateGitMetricsTask(gitRepoMetricsCache, repoManager, testProject1.get()).run();
+    new UpdateGitMetricsTask(gitRepoMetricsCache, repoManager, testProject2.get()).run();
 
     int expectedMetricsCount =
         fsMetricsCollector.availableMetrics().size()