Class: Geet::Git::Repository
- Inherits:
-
Object
- Object
- Geet::Git::Repository
- Extended by:
- Forwardable
- Defined in:
- lib/geet/git/repository.rb
Overview
This class represents, for convenience, both the local and the remote repository, but the remote code is separated in each provider module.
Constant Summary collapse
- DOMAIN_PROVIDERS_MAPPING =
{ 'github.com' => Geet::GitHub }.freeze
- REMOTE_ORIGIN_REGEX =
For simplicity, we match any character except the ones the separators.
%r{\Agit@([^:]+):([^/]+)/(.*?)(\.git)?\Z}
Instance Method Summary collapse
-
#current_head ⇒ Object
DATA.
-
#initialize(api_token) ⇒ Repository
constructor
A new instance of Repository.
- #owner ⇒ Object
- #provider_domain ⇒ Object
- #repo ⇒ Object
-
#user ⇒ Object
METADATA.
Constructor Details
#initialize(api_token) ⇒ Repository
30 31 32 33 34 35 36 37 38 |
# File 'lib/geet/git/repository.rb', line 30 def initialize(api_token) the_provider_domain = provider_domain provider_module = DOMAIN_PROVIDERS_MAPPING[the_provider_domain] || raise("Provider not supported for domain: #{provider_domain}") api_helper = provider_module::ApiHelper.new(api_token, user, owner, repo) @remote_repository = provider_module::RemoteRepository.new(self, api_helper) @account = provider_module::Account.new(api_helper) end |
Instance Method Details
#current_head ⇒ Object
DATA
60 61 62 |
# File 'lib/geet/git/repository.rb', line 60 def current_head `git rev-parse --abbrev-ref HEAD`.strip end |
#owner ⇒ Object
50 51 52 |
# File 'lib/geet/git/repository.rb', line 50 def owner remote_origin[REMOTE_ORIGIN_REGEX, 2] end |
#provider_domain ⇒ Object
46 47 48 |
# File 'lib/geet/git/repository.rb', line 46 def provider_domain remote_origin[REMOTE_ORIGIN_REGEX, 1] end |
#repo ⇒ Object
54 55 56 |
# File 'lib/geet/git/repository.rb', line 54 def repo remote_origin[REMOTE_ORIGIN_REGEX, 3] end |
#user ⇒ Object
METADATA
42 43 44 |
# File 'lib/geet/git/repository.rb', line 42 def user `git config --get user.email`.strip end |