Class: GitDuplicator::Repository
- Inherits:
-
Object
- Object
- GitDuplicator::Repository
- Defined in:
- lib/git_duplicator/repository/repository.rb
Overview
Basic Repostiroy
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#bare_clone(path_to_repo) ⇒ Object
Bare clone the repository.
-
#initialize(name, url) ⇒ Repository
constructor
Initializer.
-
#mirror(destination_url) ⇒ Object
Mirror the repository.
Constructor Details
#initialize(name, url) ⇒ Repository
Initializer
12 13 14 15 |
# File 'lib/git_duplicator/repository/repository.rb', line 12 def initialize(name, url) self.name = name self.url = url end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/git_duplicator/repository/repository.rb', line 6 def name @name end |
#repo ⇒ Object
Returns the value of attribute repo.
7 8 9 |
# File 'lib/git_duplicator/repository/repository.rb', line 7 def repo @repo end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/git_duplicator/repository/repository.rb', line 6 def url @url end |
Instance Method Details
#bare_clone(path_to_repo) ⇒ Object
Bare clone the repository
26 27 28 29 30 |
# File 'lib/git_duplicator/repository/repository.rb', line 26 def (path_to_repo) self.repo = Git.clone(url, name, bare: true, path: path_to_repo) rescue => exception raise RepositoryCloningError, exception. end |
#mirror(destination_url) ⇒ Object
Mirror the repository
34 35 36 37 38 39 |
# File 'lib/git_duplicator/repository/repository.rb', line 34 def mirror(destination_url) fail('No local repo defined. Set the "repo" attribute') unless repo repo.push(destination_url, '--mirror') rescue => exception raise RepositoryMirorringError, exception. end |