Class: GitDuplicator::Services::BitbucketRepository
- Inherits:
-
GitDuplicator::ServiceRepository
- Object
- Repository
- GitDuplicator::ServiceRepository
- GitDuplicator::Services::BitbucketRepository
- Defined in:
- lib/git_duplicator/services/bitbucket.rb
Overview
Bitbucket based repository
Constant Summary collapse
- BASE_URI =
'https://api.bitbucket.org/2.0'
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#remote_options ⇒ Object
Returns the value of attribute remote_options.
Attributes inherited from GitDuplicator::ServiceRepository
Attributes inherited from Repository
Instance Method Summary collapse
-
#create ⇒ Object
Create the repositroy.
-
#delete ⇒ Object
Delete the repositroy.
-
#initialize(name, owner, options = {}) ⇒ BitbucketRepository
constructor
Initializer.
-
#url ⇒ Object
URL of the repositroy.
Methods inherited from Repository
#bare_clone, #mirror, #mirror_clone, #set_mirrored_remote, #update_mirrored
Constructor Details
#initialize(name, owner, options = {}) ⇒ BitbucketRepository
Initializer
24 25 26 27 28 29 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 24 def initialize(name, owner, = {}) self.credentials = .fetch(:credentials) { {} } self. = .fetch(:remote_options) { {} } self.working_directory = .fetch(:working_directory) { nil } super(name, owner, working_directory) end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
8 9 10 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 8 def credentials @credentials end |
#remote_options ⇒ Object
Returns the value of attribute remote_options.
8 9 10 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 8 def end |
Instance Method Details
#create ⇒ Object
Create the repositroy
38 39 40 41 42 43 44 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 38 def create request_url = BASE_URI + "/repositories/#{owner}/#{name}" response = HTTP.with(headers(:post, request_url)) .post(request_url, json: ) code, body = response.code.to_i, response.body fail(RepositoryCreationError, body) unless 200 == code end |
#delete ⇒ Object
Delete the repositroy
48 49 50 51 52 53 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 48 def delete request_url = BASE_URI + "/repositories/#{owner}/#{name}" response = HTTP.with(headers(:delete, request_url)).delete(request_url) code, body = response.code.to_i, response.body fail(RepositoryDeletionError, body) unless [204, 404].include?(code) end |
#url ⇒ Object
URL of the repositroy
32 33 34 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 32 def url "[email protected]:#{owner}/#{name}.git" end |