<commit_before>// Copyright (C) 2020 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.plugins.codeowners.backend.proto;

import com.google.gerrit.plugins.codeowners.backend.AbstractFileBasedCodeOwnerBackend;
import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfig;
import com.google.gerrit.plugins.codeowners.backend.PathExpressionMatcher;
import com.google.gerrit.plugins.codeowners.backend.SimplePathExpressionMatcher;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.update.RetryHelper;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.Optional;
import org.eclipse.jgit.lib.PersonIdent;

/** Backend that supports a proto syntax for storing {@link CodeOwnerConfig}s. */
@Singleton
public class ProtoBackend extends AbstractFileBasedCodeOwnerBackend {
  /** The ID of this code owner backend. */
  public static final String ID = "proto";

  /** The name of the files in which {@link CodeOwnerConfig}s are stored. */
  static final String CODE_OWNER_CONFIG_FILE_NAME = "OWNERS_METADATA";

  @Inject
  ProtoBackend(
      GitRepositoryManager repoManager,
      @GerritPersonIdent PersonIdent serverIdent,
      MetaDataUpdate.InternalFactory metaDataUpdateInternalFactory,
      RetryHelper retryHelper,
      ProtoCodeOwnerConfigParser codeOwnerConfigParser) {
    super(
        repoManager,
        serverIdent,
        metaDataUpdateInternalFactory,
        retryHelper,
        CODE_OWNER_CONFIG_FILE_NAME,
        codeOwnerConfigParser);
  }

  @Override
  public Optional<PathExpressionMatcher> getPathExpressionMatcher() {
    return Optional.of(SimplePathExpressionMatcher.INSTANCE);
  }
}
<commit_msg>Mark the ProtoBackend as experimental<commit_after>// Copyright (C) 2020 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.plugins.codeowners.backend.proto;

import com.google.gerrit.plugins.codeowners.backend.AbstractFileBasedCodeOwnerBackend;
import com.google.gerrit.plugins.codeowners.backend.CodeOwnerConfig;
import com.google.gerrit.plugins.codeowners.backend.PathExpressionMatcher;
import com.google.gerrit.plugins.codeowners.backend.SimplePathExpressionMatcher;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.update.RetryHelper;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.Optional;
import org.eclipse.jgit.lib.PersonIdent;

/**
 * Backend that supports a proto syntax for storing {@link CodeOwnerConfig}s.
 *
 * <p><strong>Note:</strong> This backend is currently only experimental and should not be used in
 * production. The reason for this is that the proto syntax is not finalized yet and backwards
 * incompatible changes to it are likely to happen. Instead it's recommended to use the {@link
 * com.google.gerrit.plugins.codeowners.backend.findowners.FindOwnersBackend}.
 */
@Singleton
public class ProtoBackend extends AbstractFileBasedCodeOwnerBackend {
  /** The ID of this code owner backend. */
  public static final String ID = "proto";

  /** The name of the files in which {@link CodeOwnerConfig}s are stored. */
  static final String CODE_OWNER_CONFIG_FILE_NAME = "OWNERS_METADATA";

  @Inject
  ProtoBackend(
      GitRepositoryManager repoManager,
      @GerritPersonIdent PersonIdent serverIdent,
      MetaDataUpdate.InternalFactory metaDataUpdateInternalFactory,
      RetryHelper retryHelper,
      ProtoCodeOwnerConfigParser codeOwnerConfigParser) {
    super(
        repoManager,
        serverIdent,
        metaDataUpdateInternalFactory,
        retryHelper,
        CODE_OWNER_CONFIG_FILE_NAME,
        codeOwnerConfigParser);
  }

  @Override
  public Optional<PathExpressionMatcher> getPathExpressionMatcher() {
    return Optional.of(SimplePathExpressionMatcher.INSTANCE);
  }
}

{'fraction_non_alphanumeric': 0.08156923674499902, 'fraction_numerical': 0.003107399495047582, 'mean_word_length': 4.467091295116773, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4628986', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1366, 'n_words': 417}