class GitDuplicator::Duplicator
Abstract class
Attributes
clone_path[RW]
force_create_destination[RW]
from[RW]
logger[RW]
to[RW]
Public Class Methods
new(from, to, options = {})
click to toggle source
@param [GitDuplicator::Repository, GitDuplicator::ServiceRepository
]
from repository to mirror
@param [GitDuplicator::Repository, GitDuplicator::ServiceRepository
]
to repository to mirror to
@param [Hash] options @option options [String] :clone_path
path to clone the repository to
@option options [Boolean] :force_create_destination
delete the exisiting service repo then create it
@option options [#info] :logger log what’s going on
# File lib/git_duplicator/duplicator/duplicator.rb, line 16 def initialize(from, to, options = {}) self.from = from self.to = to self.clone_path = options.fetch(:clone_path) { '/tmp' } self.force_create_destination = options.fetch(:force_create_destination) { false } self.logger = options.fetch(:logger) { NullLogger.new } end
Public Instance Methods
clean_up()
click to toggle source
# File lib/git_duplicator/duplicator/duplicator.rb, line 52 def clean_up logger.info 'Clean local source repo' perform_clean_up end
clone_source()
click to toggle source
# File lib/git_duplicator/duplicator/duplicator.rb, line 42 def clone_source logger.info("Cloning bare Gitorious repo: #{from.url}") perform_clone_source end
mirror()
click to toggle source
# File lib/git_duplicator/duplicator/duplicator.rb, line 47 def mirror logger.info("Mirroring Gitorious to Bitbucket: #{from.url}") perform_mirror end
perform()
click to toggle source
Perform the duplication
# File lib/git_duplicator/duplicator/duplicator.rb, line 26 def perform recreate_destination clone_source mirror ensure clean_up end
perform_clean_up()
click to toggle source
# File lib/git_duplicator/duplicator/duplicator.rb, line 65 def perform_clean_up fail NotImplementedError end
perform_clone_source()
click to toggle source
# File lib/git_duplicator/duplicator/duplicator.rb, line 57 def perform_clone_source fail NotImplementedError end
perform_mirror()
click to toggle source
# File lib/git_duplicator/duplicator/duplicator.rb, line 61 def perform_mirror fail NotImplementedError end
recreate_destination()
click to toggle source
# File lib/git_duplicator/duplicator/duplicator.rb, line 34 def recreate_destination return unless force_create_destination logger.info("Deleting existing destination repo: #{to.url}") to.delete logger.info("Creating destination repo: #{to.url}") to.create end