<commit_before>package com.criteo.gerrit.plugins.automerge;

import com.google.gerrit.server.config.GerritServerConfig;

import org.eclipse.jgit.lib.Config;

public class AutomergeConfig {

  public final static String AUTOMERGE_SECTION = "automerge";
  public final static String BOT_EMAIL_KEY = "botEmail";
  private final static String defaultBotEmail = "<EMAIL>";
  private final static String defaultTopicPrefix = "crossrepo/";
  public final static String TOPIC_PREFIX_KEY = "topicPrefix";

  public static final String getDefaultBotEmail() {
    return defaultBotEmail;

  }

  public static final String getDefaultTopicPrefix() {
    return defaultTopicPrefix;
  }

  private final Config config;


  public AutomergeConfig(@GerritServerConfig final Config config) {
    this.config = config;
  }

  public final String getBotEmail() {
    final String botEmail = config.getString(AUTOMERGE_SECTION, null, BOT_EMAIL_KEY);
    if (botEmail == null) {
      return defaultBotEmail;
    }
    return botEmail;
  }

  public final String getTopicPrefix() {
    final String topicPrefix = config.getString(AUTOMERGE_SECTION, null, TOPIC_PREFIX_KEY);
    if (topicPrefix == null) {
      return defaultTopicPrefix;
    }
    return topicPrefix;
  }
}<commit_msg>Add a way to retrieve a comment from a file.<commit_after>package com.criteo.gerrit.plugins.automerge;

import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;

import org.apache.commons.io.FileUtils;
import org.eclipse.jgit.lib.Config;

import java.io.File;
import java.io.IOException;


public class AutomergeConfig {

  public final static String ATOMIC_REVIEW_DETECTED_FILE = "atomic_review_detected.txt";
  public final static String ATOMIC_REVIEWS_SAME_REPO_FILE = "atomic_review_same_repo.txt";
  public final static String AUTOMERGE_SECTION = "automerge";
  public final static String BOT_EMAIL_KEY = "botEmail";
  public final static String CANT_MERGE_COMMENT_FILE = "cantmerge.txt";

  private final static String defaultBotEmail = "<EMAIL>";
  private final static String defaultTopicPrefix = "crossrepo/";
  public final static String TOPIC_PREFIX_KEY = "topicPrefix";

  public static final String getDefaultBotEmail() {
    return defaultBotEmail;

  }

  public static final String getDefaultTopicPrefix() {
    return defaultTopicPrefix;
  }

  private final Config config;

  @Inject
  private SitePaths sitePaths;


  public AutomergeConfig(@GerritServerConfig final Config config) {
    this.config = config;
  }

  public final String getBotEmail() {
    final String botEmail = config.getString(AUTOMERGE_SECTION, null, BOT_EMAIL_KEY);
    if (botEmail == null) {
      return defaultBotEmail;
    }
    return botEmail;
  }

  /**
   * Return a comment from a file located in the gerrit etc_dir
   *
   * @param filename
   * @return a string containing a comment.
   * @throws IOException
   */
  public final String getCommentFromFile(final String filename) {
    final File commentFile = new File(sitePaths.etc_dir, filename);
    try {
      return FileUtils.readFileToString(commentFile);
    } catch (final IOException exc) {
      return String.format("Cannot find %s file in gerrit etc dir. Please check your gerrit configuration", filename);
    }
  }

  public final String getTopicPrefix() {
    final String topicPrefix = config.getString(AUTOMERGE_SECTION, null, TOPIC_PREFIX_KEY);
    if (topicPrefix == null) {
      return defaultTopicPrefix;
    }
    return topicPrefix;
  }

}
{'fraction_non_alphanumeric': 0.07961872722175498, 'fraction_numerical': 0.0, 'mean_word_length': 4.178519593613934, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3752048', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1039, 'n_words': 292}