Class: PullRequest::Create::Repository
- Inherits:
-
Object
- Object
- PullRequest::Create::Repository
- Defined in:
- lib/pull_request/create/repository.rb
Instance Method Summary collapse
- #current_branch ⇒ Object
- #git ⇒ Object
-
#initialize(path, options = {}) ⇒ Repository
constructor
A new instance of Repository.
- #logger ⇒ Object
- #remote_urls ⇒ Object
- #slug ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ Repository
Returns a new instance of Repository.
4 5 6 7 |
# File 'lib/pull_request/create/repository.rb', line 4 def initialize(path, = {}) @path = path @options = end |
Instance Method Details
#current_branch ⇒ Object
17 18 19 |
# File 'lib/pull_request/create/repository.rb', line 17 def current_branch git.current_branch end |
#git ⇒ Object
13 14 15 |
# File 'lib/pull_request/create/repository.rb', line 13 def git @git ||= ::Git.open(@path, @options) end |
#logger ⇒ Object
9 10 11 |
# File 'lib/pull_request/create/repository.rb', line 9 def logger ::PullRequest::Create.logger end |
#remote_urls ⇒ Object
30 31 32 33 34 |
# File 'lib/pull_request/create/repository.rb', line 30 def remote_urls git .remotes .map(&:url) end |
#slug ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/pull_request/create/repository.rb', line 21 def slug slug_regex = %r{\A/?(?<slug>.*?)(?:\.git)?\Z} remote_urls.map do |url| uri = GitCloneUrl.parse(url) match = slug_regex.match(uri.path) match[:slug] if match end.compact.first end |