Class: Decidim::GitBackportChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/decidim/git_backport_checker.rb

Overview

Extracts the status of the Pull Requests on the decidim repository with the label “type: fix” and shows the status of the related Pull Requests, so we can check which PRs have pending backports

Instance Method Summary collapse

Constructor Details

#initialize(token:, days_to_check_from:, last_version_number:) ⇒ GitBackportChecker

Returns a new instance of GitBackportChecker.

Parameters:

  • token (String)

    token for GitHub authentication

  • days_to_check_from (Integer)

    the number of days since the pull requests were merged from when we will start the check

  • last_version_number (String)

    the version number of the last release that we want to make the backport to



16
17
18
19
20
# File 'lib/decidim/git_backport_checker.rb', line 16

def initialize(token:, days_to_check_from:, last_version_number:)
  @token = token
  @days_to_check_from = days_to_check_from
  @last_version_number = last_version_number
end

Instance Method Details

#callObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/decidim/git_backport_checker.rb', line 22

def call
  @report = by_label(
    label: "type: fix",
    exclude_labels: ["backport", "no-backport"],
    days_to_check_from: @days_to_check_from
  ).map do |pull_request|
    {
      id: pull_request[:id],
      title: pull_request[:title],
      related_issues: related_issues(pull_request[:id])
    }
  end
end

#cli_reportObject



43
44
45
46
47
48
# File 'lib/decidim/git_backport_checker.rb', line 43

def cli_report
  Decidim::BackportsReporter::CLIReport.new(
    report: @report,
    last_version_number: @last_version_number
  ).call
end

#csv_reportObject



36
37
38
39
40
41
# File 'lib/decidim/git_backport_checker.rb', line 36

def csv_report
  Decidim::BackportsReporter::CSVReport.new(
    report: @report,
    last_version_number: @last_version_number
  ).call
end