Class: Geet::Services::CreatePr
- Inherits:
-
AbstractCreateIssue
- Object
- AbstractCreateIssue
- Geet::Services::CreatePr
- Defined in:
- lib/geet/services/create_pr.rb
Constant Summary collapse
Constants included from Geet::Shared::Selection
Geet::Shared::Selection::MANUAL_LIST_SELECTION_FLAG, Geet::Shared::Selection::SELECTION_MULTIPLE, Geet::Shared::Selection::SELECTION_SINGLE, Geet::Shared::Selection::SKIP_LIST_SELECTION_FLAG
Constants included from Geet::Shared::RepoPermissions
Geet::Shared::RepoPermissions::ALL_PERMISSIONS, Geet::Shared::RepoPermissions::PERMISSION_ADMIN, Geet::Shared::RepoPermissions::PERMISSION_NONE, Geet::Shared::RepoPermissions::PERMISSION_READ, Geet::Shared::RepoPermissions::PERMISSION_WRITE
Instance Method Summary collapse
-
#execute(title, description, labels: nil, milestone: nil, reviewers: nil, base: nil, draft: false, open_browser: false) ⇒ Object
options: :labels :reviewers :open_browser.
-
#initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT) ⇒ CreatePr
constructor
A new instance of CreatePr.
Methods included from Geet::Shared::RepoPermissions
#permission_greater_or_equal_to?
Methods included from Helpers::OsHelper
#execute_command, #open_file_with_default_application
Constructor Details
#initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT) ⇒ CreatePr
Returns a new instance of CreatePr.
18 19 20 21 22 |
# File 'lib/geet/services/create_pr.rb', line 18 def initialize(repository, out: $stdout, git_client: DEFAULT_GIT_CLIENT) super(repository) @git_client = git_client @out = out end |
Instance Method Details
#execute(title, description, labels: nil, milestone: nil, reviewers: nil, base: nil, draft: false, open_browser: false) ⇒ Object
options:
:labels
:reviewers
:open_browser
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/geet/services/create_pr.rb', line 29 def execute( title, description, labels: nil, milestone: nil, reviewers: nil, base: nil, draft: false, open_browser: false, ** ) ensure_clean_tree if @repository.upstream? && !@git_client.remote_defined?(Utils::GitClient::UPSTREAM_NAME) @out.puts "Upstream not found; adding it to the repository remotes..." AddUpstreamRepo.new(@repository.downstream, out: @out, git_client: @git_client).execute end # See CreateIssue#execute for notes about performance. = @repository.authenticated_user.is_collaborator? && @repository.authenticated_user.(PERMISSION_WRITE) if selected_labels, selected_milestone, selected_reviewers = find_and_select_attributes(labels, milestone, reviewers) end sync_with_remote_branch pr = create_pr(title, description, base: base, draft: draft) if edit_pr(pr, selected_labels, selected_milestone, selected_reviewers) end if open_browser open_file_with_default_application(pr.link) else @out.puts "PR address: #{pr.link}" end pr end |