<commit_before>require File.join(Rails.root, "lib", "gitlabhq", "git_host")

class Repository
  REPO_N = 0
  REPO_R = 1
  REPO_RW = 2

  attr_accessor :project

  def self.default_ref
    "master"
  end

  def self.access_options
    {
      "Denied"      => REPO_N,
      "Pull"        => REPO_R,
      "Pull & Push" => REPO_RW
    }
  end

  def initialize(project)
    @project = project
  end

  def path
    @path ||= project.path
  end

  def project_id
    project.id
  end

  def write_hooks
    %w(post-receive).each do |hook|
      write_hook(hook, File.read(File.join(Rails.root, 'lib', "#{hook}-hook")))
    end
  end

  def write_hook(name, content)
    hook_file = File.join(project.path_to_repo, 'hooks', name)

    File.open(hook_file, 'w') do |f|
      f.write(content)
    end

    File.chmod(0775, hook_file)
  end

  def repo
    @repo ||= Grit::Repo.new(project.path_to_repo)
  end

  def url_to_repo
    Gitlabhq::GitHost.url_to_repo(path)
  end

  def path_to_repo
    GIT_HOST["base_path"] + path + ".git"
  end

  def update_repository
    Gitlabhq::GitHost.system.new.configure do |c|
      c.update_project(path, project)
    end

    write_hooks if File.exists?(project.path_to_repo)
  end<commit_msg>Bug#326: Always empty repositories if trailing slash is missed in base_path<commit_after>require File.join(Rails.root, "lib", "gitlabhq", "git_host")

class Repository
  REPO_N = 0
  REPO_R = 1
  REPO_RW = 2

  attr_accessor :project

  def self.default_ref
    "master"
  end

  def self.access_options
    {
      "Denied"      => REPO_N,
      "Pull"        => REPO_R,
      "Pull & Push" => REPO_RW
    }
  end

  def initialize(project)
    @project = project
  end

  def path
    @path ||= project.path
  end

  def project_id
    project.id
  end

  def write_hooks
    %w(post-receive).each do |hook|
      write_hook(hook, File.read(File.join(Rails.root, 'lib', "#{hook}-hook")))
    end
  end

  def write_hook(name, content)
    hook_file = File.join(project.path_to_repo, 'hooks', name)

    File.open(hook_file, 'w') do |f|
      f.write(content)
    end

    File.chmod(0775, hook_file)
  end

  def repo
    @repo ||= Grit::Repo.new(project.path_to_repo)
  end

  def url_to_repo
    Gitlabhq::GitHost.url_to_repo(path)
  end

  def path_to_repo
    File.join(GIT_HOST["base_path"], "#{path}.git")
  end

  def update_repository
    Gitlabhq::GitHost.system.new.configure do |c|
      c.update_project(path, project)
    end

    write_hooks if File.exists?(project.path_to_repo)
  end
{'fraction_non_alphanumeric': 0.11739130434782609, 'fraction_numerical': 0.0067193675889328066, 'mean_word_length': 2.8290468986384267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1843786', 'n_tokens_mistral': 1012, 'n_tokens_neox': 963, 'n_words': 202}