Module: Commiti::PrCreator
- Extended by:
- PrRemoteParser
- Defined in:
- lib/services/git/pr/pr_creator.rb
Constant Summary
Constants included from PrRemoteParser
Commiti::PrRemoteParser::SCP_REMOTE
Class Method Summary collapse
Methods included from PrRemoteParser
Class Method Details
.create(origin_url:, base_branch:, head_branch:, title:, body:, config:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/services/git/pr/pr_creator.rb', line 12 def self.create(origin_url:, base_branch:, head_branch:, title:, body:, config:) remote = extract_remote_info(origin_url) return { url: nil, reason: :unsupported_provider } if remote.nil? token = token_for_provider(remote[:provider], config) return { url: nil, reason: :missing_token, provider: remote[:provider] } if token.nil? url = case remote[:provider] when :github, :gitbucket create_github_like_pr(remote: remote, base_branch: base_branch, head_branch: head_branch, title: title, body: body, token: token) when :gitlab create_gitlab_mr(remote: remote, base_branch: base_branch, head_branch: head_branch, title: title, body: body, token: token) end return { url: nil, reason: :unsupported_provider } if url.nil? { url: url, reason: :created } rescue StandardError => e { url: nil, reason: :api_error, provider: remote && remote[:provider], error: e. } end |