Sha256: b35b235e9099ce4bdd5f8e9ded12dda71428087133c4df1725fd5abbff4cf4a6

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 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 #{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

3 entries across 3 versions & 1 rubygems

Version Path
git_pretty_accept-0.4.0 spec/support/local_repo.rb
git_pretty_accept-0.3.1 spec/support/local_repo.rb
git_pretty_accept-0.3.0 spec/support/local_repo.rb