Class: SashimiTanpopo::Provider::GitHub
- Defined in:
- lib/sashimi_tanpopo/provider/github.rb
Overview
Apply recipe files and create Pull Request
Constant Summary collapse
- DEFAULT_API_ENDPOINT =
"https://api.github.com/"
- DEFAULT_GITHUB_HOST =
"github.com"
Class Method Summary collapse
-
.github_host(api_endpoint) ⇒ String
Get GitHub host from api_endpoint.
Instance Method Summary collapse
-
#initialize(recipe_paths:, target_dir:, params:, dry_run:, is_colored:, git_username:, git_email:, commit_message:, repository:, access_token:, api_endpoint: DEFAULT_API_ENDPOINT, pr_title:, pr_body:, pr_source_branch:, pr_target_branch:, pr_assignees: [], pr_reviewers: [], pr_labels: [], is_draft_pr:) ⇒ GitHub
constructor
A new instance of GitHub.
-
#perform ⇒ String?
Apply recipe files.
Methods inherited from Base
Constructor Details
#initialize(recipe_paths:, target_dir:, params:, dry_run:, is_colored:, git_username:, git_email:, commit_message:, repository:, access_token:, api_endpoint: DEFAULT_API_ENDPOINT, pr_title:, pr_body:, pr_source_branch:, pr_target_branch:, pr_assignees: [], pr_reviewers: [], pr_labels: [], is_draft_pr:) ⇒ GitHub
Returns a new instance of GitHub.
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 |
# File 'lib/sashimi_tanpopo/provider/github.rb', line 30 def initialize(recipe_paths:, target_dir:, params:, dry_run:, is_colored:, git_username:, git_email:, commit_message:, repository:, access_token:, api_endpoint: DEFAULT_API_ENDPOINT, pr_title:, pr_body:, pr_source_branch:, pr_target_branch:, pr_assignees: [], pr_reviewers: [], pr_labels: [], is_draft_pr:) super( recipe_paths: recipe_paths, target_dir: target_dir, params: params, dry_run: dry_run, is_colored: is_colored, is_update_local: false, ) @commit_message = @repository = repository @pr_title = pr_title @pr_body = pr_body @pr_source_branch = pr_source_branch @pr_target_branch = pr_target_branch @pr_assignees = pr_assignees @pr_reviewers = pr_reviewers @pr_labels = pr_labels @is_draft_pr = is_draft_pr @git_username = git_username @git_email = git_email @api_endpoint = api_endpoint @client = Octokit::Client.new(api_endpoint: api_endpoint, access_token: access_token) end |
Class Method Details
.github_host(api_endpoint) ⇒ String
Get GitHub host from api_endpoint
91 92 93 94 95 96 97 98 |
# File 'lib/sashimi_tanpopo/provider/github.rb', line 91 def self.github_host(api_endpoint) return DEFAULT_GITHUB_HOST if api_endpoint == DEFAULT_API_ENDPOINT matched = %r{^https?://(.+)/api}.match(api_endpoint) return matched[1] if matched # steep:ignore DEFAULT_GITHUB_HOST end |
Instance Method Details
#perform ⇒ String?
Apply recipe files
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/sashimi_tanpopo/provider/github.rb', line 65 def perform changed_files = apply_recipe_files return nil if changed_files.empty? || @dry_run if exists_branch?(@pr_source_branch) SashimiTanpopo.logger.info "Skipped because branch #{@pr_source_branch} already exists on #{@repository}" return nil end create_branch_and_push_changes(changed_files) pr = create_pull_request add_pr_labels(pr[:number]) add_pr_assignees(pr[:number]) add_pr_reviewers(pr[:number]) pr[:html_url] end |