Class: Geet::Services::OpenRepo

Inherits:
Object
  • Object
show all
Includes:
Helpers::OsHelper
Defined in:
lib/geet/services/open_repo.rb

Overview

Open in the browser the current repository.

Constant Summary collapse

DEFAULT_GIT_CLIENT =
Utils::GitClient.new

Instance Method Summary collapse

Methods included from Helpers::OsHelper

#execute_command, #open_file_with_default_application

Constructor Details

#initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT) ⇒ OpenRepo

Returns a new instance of OpenRepo.



14
15
16
17
18
# File 'lib/geet/services/open_repo.rb', line 14

def initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT)
  @repository = repository
  @out = out
  @git_client = git_client
end

Instance Method Details

#execute(upstream: false) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/geet/services/open_repo.rb', line 20

def execute(upstream: false)
  remote_options = upstream ? {name: Utils::GitClient::UPSTREAM_NAME} : {}

  repo_url = @git_client.remote(**remote_options)
  repo_url = convert_repo_url_to_http_protocol(repo_url)

  open_file_with_default_application(repo_url)

  repo_url
end