Sha256: b1d513fb189be2c38a96e5f75de8fd0ba437fe43697fac1d68d7385e75e785f6

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

class LocalRepo
  attr_reader :git, :project_path, :path

  def initialize(project_path, path, remote_repo)
    @project_path = project_path
    @path = path
    @remote_repo = remote_repo

    Git.clone remote_repo.path, path
    @git = Git.open(path)
  end

  def add_initial_commit
    File.open("#{path}/readme.txt", 'w') { |f| f.write('readme') }
    File.open("#{path}/.gitignore", 'w') do |f|
      f.write('.git-pretty-accept-template.txt')
    end

    git.add all: true
    git.commit 'Initial commit.'
    git.push
  end

  def add_merge_message_template_file(message)
    File.open("#{path}/.git-pretty-accept-template.txt", 'w') do |file|
      file.write message
    end
  end

  def checkout(branch)
    git.branch(branch).checkout
  end

  def commit_some_change(message)
    File.open("#{path}/#{message}.txt", 'w') { |f| f.write(message) }
    git.add all: true
    git.commit message
  end

  def create_branch(branch)
    git.branch(branch).checkout
    git.push git.remote('origin'), branch
  end

  def git_pretty_accept(branch)
    FileUtils.cd(path) do
      puts `bundle exec #{project_path}/bin/git-pretty-accept --no-edit --no-autosquash #{branch}`
    end
  end

  def push_some_change(message)
    commit_some_change message
    git.push git.remote('origin'), git.branches.local.find(&:current)
  end

  def track(branch)
    git.branch(branch).checkout
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git_pretty_accept-1.0.0 spec/support/local_repo.rb
git_pretty_accept-0.5.0 spec/support/local_repo.rb