<commit_before>module GitHubRepoable
  extend ActiveSupport::Concern

  included do
    before_validation(on: :create) do
      create_github_repository if organization
    end

    before_create :add_team_to_github_repository
    before_create :push_starter_code

    before_destroy :destroy_github_repository
  end

  # Public
  #
  def add_team_to_github_repository
    github_repository = GitHubRepository.new(organization.github_client, github_repo_id)
    github_team       = GitHubTeam.new(organization.github_client, github_team_id)

    github_team.add_team_repository(github_repository.full_name)
  end

  # Public
  #
  def create_github_repository
    github_repository = github_organization.create_repository(repo_name,
                                                              team_id: github_team_id,
                                                              private: self.private?,
                                                              description: "#{repo_name} created by Classroom for GitHub")
    self.github_repo_id = github_repository.id
  end

  # Public
  #
  def destroy_github_repository
    github_organization.delete_repository(github_repo_id)
  end

  # Public
  #
  def push_starter_code
    return true unless starter_code_repo_id

    repository              = GitHubRepository.new(creator.github_client, github_repo_id)
    starter_code_repository = GitHubRepository.new(creator.github_client, starter_code_repo_id)

    repository.get_starter_code_from(starter_code_repository.full_name)
  end

  private
<commit_msg>rubocop<commit_after>module GitHubRepoable
  extend ActiveSupport::Concern

  included do
    before_validation(on: :create) do
      create_github_repository if organization
    end

    before_create :add_team_to_github_repository
    before_create :push_starter_code

    before_destroy :destroy_github_repository
  end

  # Public
  #
  def add_team_to_github_repository
    github_repository = GitHubRepository.new(organization.github_client, github_repo_id)
    github_team       = GitHubTeam.new(organization.github_client, github_team_id)

    github_team.add_team_repository(github_repository.full_name)
  end

  # Public
  #
  def create_github_repository
    repo_description = "#{repo_name} created by Classroom for GitHub"
    github_repository = github_organization.create_repository(repo_name,
                                                              team_id: github_team_id,
                                                              private: self.private?,
                                                              description: repo_description)
    self.github_repo_id = github_repository.id
  end

  # Public
  #
  def destroy_github_repository
    github_organization.delete_repository(github_repo_id)
  end

  # Public
  #
  def push_starter_code
    return true unless starter_code_repo_id

    repository              = GitHubRepository.new(creator.github_client, github_repo_id)
    starter_code_repository = GitHubRepository.new(creator.github_client, starter_code_repo_id)

    repository.get_starter_code_from(starter_code_repository.full_name)
  end

  private

{'fraction_non_alphanumeric': 0.047664141414141416, 'fraction_numerical': 0.0, 'mean_word_length': 2.7021028037383177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7645297', 'n_tokens_mistral': 899, 'n_tokens_neox': 820, 'n_words': 144}