Skip to content

Deduplicate closeOlder issue/PR wrapper wiring with a shared adapter#45045

Draft
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/duplicate-code-close-older-wrappers
Draft

Deduplicate closeOlder issue/PR wrapper wiring with a shared adapter#45045
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/duplicate-code-close-older-wrappers

Conversation

Copilot AI commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

closeOlderIssues and closeOlderPullRequests had near-identical wrapper logic around closeOlderEntities, creating duplicated adapter wiring and drift risk. This change centralizes the shared orchestration while preserving entity-specific behavior and output shape.

  • Refactor: extract shared closeOlder adapter

    • Added actions/setup/js/close_older_adapter.cjs with closeOlderWithAdapter(...) to handle:
      • common closeOlderEntities(...) config wiring
      • forwarding of callerWorkflowId / closeOlderKey into search closures
      • consistent { number, html_url } result mapping
  • Wrapper simplification: issues + pull requests

    • Updated:
      • actions/setup/js/close_older_issues.cjs
      • actions/setup/js/close_older_pull_requests.cjs
    • Each wrapper now passes only entity-specific pieces (searchOlder*, message mapping, comment/close handlers, labels), removing duplicated plumbing.
  • Coverage for shared adapter behavior

    • Added actions/setup/js/close_older_adapter.test.cjs to validate:
      • forwarding of dedupe context (callerWorkflowId, closeOlderKey)
      • message-parameter transformation before getCloseMessage
      • normalization of missing html_url in mapped results
return closeOlderWithAdapter({
  github, owner, repo, workflowId, newEntity, workflowName, runUrl,
  callerWorkflowId, closeOlderKey,
  entityType: "issue",
  entityTypePlural: "issues",
  searchOlderEntities: searchOlderIssues,
  getCloseMessage: getCloseOlderIssueMessage,
  messageParams: p => ({
    newIssueUrl: p.newEntityUrl,
    newIssueNumber: p.newEntityNumber,
    workflowName: p.workflowName,
    runUrl: p.runUrl,
  }),
  addComment: addIssueComment,
  closeEntity: closeIssueAsNotPlanned,
  delayMs: API_DELAY_MS,
});

Copilot AI and others added 3 commits July 12, 2026 06:35
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor duplicate code in closeOlder adapter wrappers Deduplicate closeOlder issue/PR wrapper wiring with a shared adapter Jul 12, 2026
Copilot AI requested a review from pelikhan July 12, 2026 06:42
@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category refactor
Risk 🟢 low
Score 35/100 (impact:15 + urgency:10 + quality:10)
Action 📦 batch_review
Batch pr-batch:refactor-dedup (with #45044, #45018)

Rationale: Draft. Deduplicates closeOlder issue/PR wrapper wiring into shared adapter. Low risk, 4 files. Batch with other refactor/dedup PRs.

Triage run §29183606049

Generated by 🔧 PR Triage Agent · 171.6 AIC · ⌖ 5.63 AIC · ⊞ 5.6K ·

@github-actions

Copy link
Copy Markdown
Contributor

Hey @copilot-swe-agent 👋 — great work extracting the shared closeOlderWithAdapter adapter! Centralizing the duplicated orchestration logic across close_older_issues.cjs and close_older_pull_requests.cjs is a clean refactor that reduces drift risk.

This PR looks well-structured: it's focused on a single concern, includes a dedicated test file (close_older_adapter.test.cjs), and has a clear description of the change and its motivation. It looks ready for review. ✅

Generated by ✅ Contribution Check · 95.5 AIC · ⌖ 17.4 AIC · ⊞ 6.2K ·

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category refactor
Risk 🟢 Low
Score 42/100 (impact: 18, urgency: 10, quality: 14)
Batch refactor-dedup (with #45044, #45018)
Action batch_review

Draft. Deduplication refactor with moderate size (+199/-42). Review together with the refactor-dedup batch.

Generated by 🔧 PR Triage Agent · 48.3 AIC · ⌖ 7.99 AIC · ⊞ 5.6K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[duplicate-code] Duplicate Code: closeOlder issue/PR adapter wrappers share the same wiring

2 participants