Revert "Extract original repo from DelegateRepository"

This reverts commit 7b03a85661ad0fa991502b280e4db33f97020e7d.

Reason for revert: the visibility of the delegate() method was changed from package protected to public.

Change-Id: Ieb39167559785c8faefd21106e56b5f2350aa8c6
diff --git a/BUILD b/BUILD
index 613eda5..1052170 100644
--- a/BUILD
+++ b/BUILD
@@ -7,13 +7,10 @@
     "gerrit_plugin",
 )
 
-DELEGATE_REPOSITORY_UNWRAPPER_SRCS = ["src/main/java/com/google/gerrit/server/git/DelegateRepositoryUnwrapper.java"]
-
 gerrit_plugin(
     name = "git-repo-metrics",
     srcs = glob(
         ["src/main/java/**/*.java"],
-        exclude = DELEGATE_REPOSITORY_UNWRAPPER_SRCS,
     ),
     manifest_entries = [
         "Gerrit-PluginName: git-repo-metrics",
@@ -24,23 +21,7 @@
     ],
     resources = glob(
         ["src/main/resources/**/*"],
-    ),
-    deps = [
-        ":delegaterepositoryunwrapper-neverlink",
-    ],
-)
-
-java_library(
-    name = "delegaterepositoryunwrapper",
-    srcs = DELEGATE_REPOSITORY_UNWRAPPER_SRCS,
-    deps = PLUGIN_DEPS,
-)
-
-java_library(
-    name = "delegaterepositoryunwrapper-neverlink",
-    srcs = DELEGATE_REPOSITORY_UNWRAPPER_SRCS,
-    neverlink = True,
-    deps = PLUGIN_DEPS,
+    )
 )
 
 junit_tests(
@@ -67,5 +48,5 @@
 java_library(
     name = "git-repo-metrics__plugin_deps",
     visibility = ["//visibility:public"],
-    exports = PLUGIN_DEPS,
+    exports = PLUGIN_DEPS
 )
diff --git a/README.md b/README.md
index ae86d4a..780f1c0 100644
--- a/README.md
+++ b/README.md
@@ -14,20 +14,19 @@
 git clone --recursive https://gerrit.googlesource.com/gerrit
 git clone https://gerrit.googlesource.com/plugins/git-repo-metrics
 pushd gerrit/plugins && ln -s ../../git-repo-metrics . && popd
-cd gerrit && bazel build //plugins/git-repo-metrics:all
+cd gerrit && bazel build plugins/git-repo-metrics
 ```
 
-Two jar will be created:
+The output plugin jar is created in:
 
 ```
-bazel-bin/plugins/git-repo-metrics/git-repo-metrics.jar
-bazel-bin/plugins/git-repo-metrics/libdelegaterepositoryunwrapper.jar
+bazel-genfiles/plugins/git-repo-metrics/git-repo-metrics.jar
 ```
 
 ## How to install
 
-Copy the `git-repo-metrics.jar` into the Gerrit's `<gerrit_site>/plugins` directory and the `libdelegaterepositoryunwrapper.jar`
-into the `<gerrit_site>/lib` directory. Restart your Gerrit instance and the plugin will be loaded.
+Copy the git-repo-metrics.jar into the Gerrit's /plugins directory and wait for the plugin to be automatically
+loaded.
 
 ## Configuration
 
diff --git a/src/main/java/com/google/gerrit/server/git/DelegateRepositoryUnwrapper.java b/src/main/java/com/google/gerrit/server/git/DelegateRepositoryUnwrapper.java
deleted file mode 100644
index ad07087..0000000
--- a/src/main/java/com/google/gerrit/server/git/DelegateRepositoryUnwrapper.java
+++ /dev/null
@@ -1,25 +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.google.gerrit.server.git;
-
-import org.eclipse.jgit.lib.Repository;
-
-public class DelegateRepositoryUnwrapper {
-  public static Repository unwrap(DelegateRepository delegateRepository) {
-    return delegateRepository.delegate();
-  }
-
-  public DelegateRepositoryUnwrapper() {}
-}
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 51fb927..ed120e5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/UpdateGitMetricsTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/gitrepometrics/UpdateGitMetricsTask.java
@@ -16,8 +16,6 @@
 
 import com.google.common.flogger.FluentLogger;
 import com.google.gerrit.entities.Project;
-import com.google.gerrit.server.git.DelegateRepository;
-import com.google.gerrit.server.git.DelegateRepositoryUnwrapper;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
@@ -59,13 +57,7 @@
           repository.getIdentifier(), projectName);
       // TODO Loop through all the collectors
       Project project = Project.builder(projectNameKey).build();
-
-      Repository unwrappedRepo =
-          repository instanceof DelegateRepository
-              ? DelegateRepositoryUnwrapper.unwrap((DelegateRepository) repository)
-              : repository;
-
-      GitStats gitStats = new GitStats((FileRepository) unwrappedRepo, project);
+      GitStats gitStats = new GitStats((FileRepository) repository, project);
       Map<String, Long> newMetrics = gitStats.get();
       logger.atInfo().log(
           "Here all the metrics for %s - %s", project.getName(), getStringFromMap(newMetrics));