<commit_before>require "claide"

require "multirepo"
require "multirepo/utility/console"
require "multirepo/config"

module MultiRepo
  class Init < Command
    self.command = "init"
    self.summary = "Initialize the current repo as a multirepo project."
    
    def run
      super
      
      Console.log_step("Initializing multirepo...")
      
      unless Config.exists?
        Config.create
        Console.log_substep("Created .multirepo file")
      else
        Console.log_info(".multirepo file already exists")
      end
      
      sibling_repos.each do |repo|
        if Console.ask_yes_no("Do you want to add #{repo.working_copy} (#{repo.remote('origin').url} #{repo.current_branch}) as a dependency?")
          entry = Entry.new(repo)
          if entry.exists?
            Console.log_info("There is already an entry for #{entry.folder_name} in the .multirepo file")
          else
            entry.add
            Console.log_substep("Added the repository #{entry.repo.working_copy} to the .multirepo file")
          end
        end
      end
      
      MultiRepo.install_pre_commit_hook
      Console.log_substep("Installed pre-commit hook")
              
      Console.log_step("Done!")
    rescue Exception => e
      Console.log_error(e.message)
    end
    
    def sibling_repos
      sibling_directories = Dir['../*/']
      sibling_directories.map{ |d| Repo.new(d) }.select{ |r| r.exists? }
    end<commit_msg>Not listing the current (main) repo as a possible dependency when running Init.<commit_after>require "claide"

require "multirepo"
require "multirepo/utility/console"
require "multirepo/config"

module MultiRepo
  class Init < Command
    self.command = "init"
    self.summary = "Initialize the current repo as a multirepo project."
    
    def run
      super
      
      Console.log_step("Initializing multirepo...")
      
      unless Config.exists?
        Config.create
        Console.log_substep("Created .multirepo file")
      else
        Console.log_info(".multirepo file already exists")
      end
      
      sibling_repos.each do |repo|
        if Console.ask_yes_no("Do you want to add #{repo.working_copy} (#{repo.remote('origin').url} #{repo.current_branch}) as a dependency?")
          entry = Entry.new(repo)
          if entry.exists?
            Console.log_info("There is already an entry for #{entry.folder_name} in the .multirepo file")
          else
            entry.add
            Console.log_substep("Added the repository #{entry.repo.working_copy} to the .multirepo file")
          end
        end
      end
      
      MultiRepo.install_pre_commit_hook
      Console.log_substep("Installed pre-commit hook")
              
      Console.log_step("Done!")
    rescue Exception => e
      Console.log_error(e.message)
    end
    
    def sibling_repos
      sibling_directories = Dir['../*/']
      sibling_repos = sibling_directories.map{ |d| Repo.new(d) }.select{ |r| r.exists? }
      sibling_repos.delete_if{ |r| Pathname.new(r.working_copy).realpath == Pathname.new(".").realpath }
    end
{'fraction_non_alphanumeric': 0.10295550503410199, 'fraction_numerical': 0.0, 'mean_word_length': 2.3958103638368247, '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': '3688326', 'n_tokens_mistral': 924, 'n_tokens_neox': 928, 'n_words': 226}