Module: PlanMyStuff::Pipeline::IssueLinker
- Defined in:
- lib/plan_my_stuff/pipeline/issue_linker.rb
Overview
Resolves linked issues from pull request payloads and finds their corresponding ProjectItems in the pipeline project.
Uses module_function pattern (matches MetadataParser, Pipeline).
Constant Summary collapse
- CLOSING_KEYWORD_PATTERN =
Regex matching GitHub closing keywords in PR bodies. Matches all nine variants: close/closes/closed, fix/fixes/fixed, resolve/resolves/resolved (case-insensitive).
/\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)\b/i
Class Method Summary collapse
-
.extract_issue_numbers(pr_payload, commit_messages: []) ⇒ Array<Integer>
Extracts issue numbers from a PR payload by parsing the PR body and commit messages for GitHub closing keywords (close/closes/closed, fix/fixes/fixed, resolve/resolves/resolved).
-
.find_project_item(issue_number, _repo: nil, project_number: nil) ⇒ PlanMyStuff::ProjectItem?
Finds the ProjectItem in the pipeline project that matches the given issue number.
Class Method Details
.extract_issue_numbers(pr_payload, commit_messages: []) ⇒ Array<Integer>
Extracts issue numbers from a PR payload by parsing the PR body and commit messages for GitHub closing keywords (close/closes/closed, fix/fixes/fixed, resolve/resolves/resolved).
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/plan_my_stuff/pipeline/issue_linker.rb', line 27 def extract_issue_numbers(pr_payload, commit_messages: []) texts = [] body = pr_payload[:body] || pr_payload['body'] texts << body if body.present? Array.wrap().each do || texts << if .present? end return [] if texts.empty? matches = texts.join("\n").scan(CLOSING_KEYWORD_PATTERN).flatten matches.map!(&:to_i) matches.uniq! matches end |
.find_project_item(issue_number, _repo: nil, project_number: nil) ⇒ PlanMyStuff::ProjectItem?
Finds the ProjectItem in the pipeline project that matches the given issue number. Loads the full project and iterates its items.
54 55 56 57 58 59 |
# File 'lib/plan_my_stuff/pipeline/issue_linker.rb', line 54 def find_project_item(issue_number, _repo: nil, project_number: nil) number = PlanMyStuff::Pipeline.resolve_pipeline_project_number(project_number) project = PlanMyStuff::Project.find(number) project.items.find { |item| item.number == issue_number } end |