<commit_before>module Githole
  class Git

    def initialize(version)
      @version = version
    end

    def respond_to?(cmd)
      ['add','update','push','remove', 'tag'].include?(cmd)
    end

    def add
      checkout master
      fetch
      create remote
      pull remote if branch_exists?("remotes/origin/#{remote}")
      git_push remote
      create local
    end

    def update
      verify remote
      verify local
      # rebase master onto local
      checkout master
      pull master
      checkout local
      rebase master
      # rebase remote onto local
      checkout remote
      pull remote
      checkout local
      rebase remote
    end

    def push
      update
      checkout remote
      merge local
      git_push remote
      checkout local
    end

    def remove
      checkout master
      delete remote
      delete local
    end

    def tag
      checkout master
      pull master
      git "tag -a v#{@version} -m v#{@version}"
      git_push "--tags"
    end

    private

      def git(cmd)
        system("git #{cmd}")
      end

      def fetch
        git "fetch"
      end

      def branches
        `git branch -a`
          .split("\n")
          .collect { |b| b.split(' ').last }
          .collect { |b| b.split(' ').first }
      end

      def checkout(branch, options = '')
        git "checkout #{options} #{branch}"
      end

      def create(branch)
        branch_exists?(branch) ? checkout(branch) : checkout(branch, '-b')
      end

      def delete(branch)
        git "branch -D #{branch}"
      end

      def git_push(branch)
        git "push origin #{branch}"
      end

      def pull(branch)
        git "pull origin #{branch}"
      end

      def rebase(branch)
        git "rebase #{branch}"
      end

      def merge(branch)
        git "merge #{branch}"
      end

      def master
        "master"
      end

      def remote
        "v#{@version}"
      end

      def local
        "local-v#{@version}"
      end

      def branch_exists?(branch)
        branches.include?(branch)
      end

      def remote_exists?
        branch_exists?(remote)
      end

      def local_exists?
        branch_exists?(local)
      end

      def verify(branch)
        create(branch) unless branch_exists?(branch)
      end

  end
end<commit_msg>remove auto-inserting "v" before the version to allow for other uses of this workflow<commit_after>module Githole
  class Git

    def initialize(version)
      @version = version
    end

    def respond_to?(cmd)
      ['add','update','push','remove', 'tag'].include?(cmd)
    end

    def add
      checkout master
      fetch
      create remote
      pull remote if branch_exists?("remotes/origin/#{remote}")
      git_push remote
      create local
    end

    def update
      verify remote
      verify local
      # rebase master onto local
      checkout master
      pull master
      checkout local
      rebase master
      # rebase remote onto local
      checkout remote
      pull remote
      checkout local
      rebase remote
    end

    def push
      update
      checkout remote
      merge local
      git_push remote
      checkout local
    end

    def remove
      checkout master
      delete remote
      delete local
    end

    def tag
      checkout master
      pull master
      git "tag -a #{@version} -m #{@version}"
      git_push "--tags"
    end

    private

      def git(cmd)
        system("git #{cmd}")
      end

      def fetch
        git "fetch"
      end

      def branches
        `git branch -a`
          .split("\n")
          .collect { |b| b.split(' ').last }
          .collect { |b| b.split(' ').first }
      end

      def checkout(branch, options = '')
        git "checkout #{options} #{branch}"
      end

      def create(branch)
        branch_exists?(branch) ? checkout(branch) : checkout(branch, '-b')
      end

      def delete(branch)
        git "branch -D #{branch}"
      end

      def git_push(branch)
        git "push origin #{branch}"
      end

      def pull(branch)
        git "pull origin #{branch}"
      end

      def rebase(branch)
        git "rebase #{branch}"
      end

      def merge(branch)
        git "merge #{branch}"
      end

      def master
        "master"
      end

      def remote
        "#{@version}"
      end

      def local
        "local-#{@version}"
      end

      def branch_exists?(branch)
        branches.include?(branch)
      end

      def remote_exists?
        branch_exists?(remote)
      end

      def local_exists?
        branch_exists?(local)
      end

      def verify(branch)
        create(branch) unless branch_exists?(branch)
      end

  end
end
{'fraction_non_alphanumeric': 0.08652210884353742, 'fraction_numerical': 0.0, 'mean_word_length': 1.6358543417366946, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '721875', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1324, 'n_words': 418}