Sha256: 4dc5b810e3190dadeafc1e566bc45acb69559584634aac19050019c6af1c29e0
Contents?: true
Size: 1.35 KB
Versions: 6
Compression:
Stored size: 1.35 KB
Contents
shared_context 'git repository' do subject(:repo){Hillary::Repo.new(local_repo_path, logger)} let(:logger){Logger.new(out)} let(:out){StringIO.new} let(:local_repo_path){File.expand_path('../../tmp/local', __FILE__)} let(:remote_repo_path){File.expand_path('../../tmp/remote.git', __FILE__)} let!(:local_repo) do Grit::Repo.init(local_repo_path).tap do |repo| FileUtils.touch('taco.md') repo.add('taco.md') repo.commit_all('Initial commit') repo.fork_bare(remote_repo_path) repo.remote_add('origin', remote_repo_path) repo.git.pull end end let!(:remote_repo) do Grit::Repo.init_bare(remote_repo_path) end around(:each) do |example| FileUtils.mkdir_p(local_repo_path) Dir.chdir(local_repo_path) do example.call end end after(:each) do FileUtils.rm_rf(local_repo_path) FileUtils.rm_rf(remote_repo_path) end def add_file_to_remote(name, content, branch) index = remote_repo.index parent_commit = remote_repo.get_head(branch).commit index.read_tree(branch) index.add(name, content) index.commit("Add #{name}", [parent_commit], nil, nil, branch) end def add_file_to_local(name, message) FileUtils.touch(name) local_repo.add(name) local_repo.commit_all(message) local_repo.git.push({u: true}, 'origin', 'head') local_repo.git.pull end end
Version data entries
6 entries across 6 versions & 1 rubygems