Skip to content
Snippets Groups Projects
Commit d4cfa0cc authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch 'rs-rename-repository' into 'master'

Rename Repository to RemoteRepository, LocalRepo to LocalRepository

See merge request !121
parents 8c94537d 04ef701e
No related branches found
No related tags found
1 merge request!121Rename Repository to RemoteRepository, LocalRepo to LocalRepository
Pipeline #
require_relative 'init'
require_relative 'lib/support/tasks_helper'
require_relative 'lib/local_repo'
require_relative 'lib/local_repository'
 
begin
require 'rspec/core/rake_task'
Loading
Loading
@@ -12,7 +12,7 @@ rescue LoadError
# no rspec available
end
 
unless Rake.application.top_level_tasks.include?('default') || LocalRepo.ready?
unless Rake.application.top_level_tasks.include?('default') || LocalRepository.ready?
abort('Please use the master branch and make sure you are up to date.'.colorize(:red))
end
 
Loading
Loading
require 'open3'
 
class LocalRepo
class LocalRepository
def self.ready?
new.ready?
end
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ require 'forwardable'
 
require_relative '../changelog'
require_relative '../release'
require_relative '../repository'
require_relative '../remote_repository'
require_relative '../version'
require_relative '../packagecloud_client'
require_relative '../gitlab_dev_client'
Loading
Loading
@@ -42,7 +42,7 @@ module Release
end
 
def repository
@repository ||= Repository.get(remotes)
@repository ||= RemoteRepository.get(remotes)
end
 
def prepare_release
Loading
Loading
require 'colorize'
require 'fileutils'
 
class Repository
class RemoteRepository
class CannotCloneError < StandardError; end
class CannotCheckoutBranchError < StandardError; end
class CannotCreateTagError < StandardError; end
Loading
Loading
require_relative 'repository'
require_relative 'remote_repository'
 
class Sync
attr_reader :remotes
Loading
Loading
@@ -14,7 +14,7 @@ class Sync
private
 
def sync(branch)
repository = Repository.get(remotes, "gitlab-sync-#{Time.now.to_i}")
repository = RemoteRepository.get(remotes, "gitlab-sync-#{Time.now.to_i}")
 
repository.pull_from_all_remotes(branch)
repository.push_to_all_remotes(branch)
Loading
Loading
require 'spec_helper'
require 'local_repo'
require 'local_repository'
 
describe LocalRepo do
let(:fixture) { LocalRepoFixture.new }
describe LocalRepository do
let(:fixture) { LocalRepositoryFixture.new }
let(:repo_path) { File.join('/tmp', fixture.class.repository_name) }
let(:repo_url) { "file://#{fixture.fixture_path}" }
let(:repo_remotes) do
{ origin: repo_url, github: 'https://example.com/foo/bar/baz.git' }
end
let(:repo) { Repository.get(repo_remotes) }
let(:repo) { RemoteRepository.get(repo_remotes) }
 
before do
fixture.rebuild_fixture!
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ describe Release::GitlabCeRelease do
ob_fixture.rebuild_fixture!
 
# Disable cleanup so that we can see what's the state of the temp Git repos
allow_any_instance_of(Repository).to receive(:cleanup).and_return(true)
allow_any_instance_of(RemoteRepository).to receive(:cleanup).and_return(true)
 
# Override the actual remotes with our local fixture repositories
allow_any_instance_of(described_class).to receive(:remotes)
Loading
Loading
require 'spec_helper'
require 'repository'
require 'remote_repository'
 
describe Repository do
describe RemoteRepository do
let(:fixture) { ReleaseFixture.new }
let(:repo_path) { File.join('/tmp', fixture.class.repository_name) }
let(:repo_url) { "file://#{fixture.fixture_path}" }
Loading
Loading
@@ -199,7 +199,7 @@ describe Repository do
allow(repository).to receive(:conflicts?).and_return(true)
 
expect { repository.pull_from_all_remotes('1-9-stable') }
.to raise_error(Repository::CannotPullError)
.to raise_error(described_class::CannotPullError)
end
end
 
Loading
Loading
require 'fileutils'
require 'rugged'
 
class LocalRepoFixture
class LocalRepositoryFixture
attr_reader :repository
 
def self.repository_name
Loading
Loading
@@ -40,12 +40,13 @@ class LocalRepoFixture
oid = repository.write(content, :blob)
index.add(path: path, oid: oid, mode: 0o100644)
 
commit = Rugged::Commit.create(repository, {
commit = Rugged::Commit.create(
repository,
tree: index.write_tree(repository),
message: message,
parents: repository.empty? ? [] : [repository.head.target].compact,
update_ref: 'HEAD'
})
)
 
repository.checkout_head(strategy: :force)
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment