Class: Dependabot::PullRequestCreator::PrNamePrefixer

Inherits:
Object
  • Object
show all
Defined in:
lib/hack/dependabot-core/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb

Instance Method Summary collapse

Instance Method Details

#gitea_client_for_sourceObject



56
57
58
59
60
61
62
# File 'lib/hack/dependabot-core/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 56

def gitea_client_for_source
  @gitea_client_for_source ||=
    Dependabot::Clients::Gitea.for_source(
      source: source,
      credentials: credentials
    )
end

#last_dependabot_commit_messageObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hack/dependabot-core/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 30

def last_dependabot_commit_message
  @last_dependabot_commit_message ||=
    case source.provider
    when "github" then last_github_dependabot_commit_message
    when "gitlab" then last_gitlab_dependabot_commit_message
    when "azure" then last_azure_dependabot_commit_message
    when "gitea" then last_gitea_dependabot_commit_message
    when "codecommit" then last_codecommit_dependabot_commit_message
    else raise "Unsupported provider: #{source.provider}"
    end
end

#last_gitea_dependabot_commit_messageObject



42
43
44
45
46
47
48
49
# File 'lib/hack/dependabot-core/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 42

def last_gitea_dependabot_commit_message
  recent_gitea_commits.
    reject { |c| c.commit&.message&.start_with?("Merge") }.
    find { |c| c.commit.author&.name&.include?("dependabot") }&.
    commit&.
    message&.
    strip
end

#recent_commit_messagesObject

override



9
10
11
12
13
14
15
16
17
18
# File 'lib/hack/dependabot-core/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 9

def recent_commit_messages
  case source.provider
  when "github" then recent_github_commit_messages
  when "gitlab" then recent_gitlab_commit_messages
  when "azure" then recent_azure_commit_messages
  when "gitea" then recent_gitea_commit_messages
  when "codecommit" then recent_codecommit_commit_messages
  else raise "Unsupported provider: #{source.provider}"
  end
end

#recent_gitea_commit_messagesObject



20
21
22
23
24
25
26
27
28
# File 'lib/hack/dependabot-core/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 20

def recent_gitea_commit_messages
  recent_gitea_commits.
    reject { |c| c.author&.type == "Bot" }.
    reject { |c| c.commit&.message&.start_with?("Merge") }.
    map(&:commit).
    map(&:message).
    compact.
    map(&:strip)
end

#recent_gitea_commitsObject



51
52
53
54
# File 'lib/hack/dependabot-core/common/lib/dependabot/pull_request_creator/pr_name_prefixer.rb', line 51

def recent_gitea_commits
  @recent_gitea_commits ||=
    gitea_client_for_source.commits
end