Repository navigation
[code-simplifier] refactor: extract duplicate GitHub repo path regex to named constant - #24449
Merged
Merged
Conversation
Extract the repeated regex /^([^/]+)\/([^/]+)\/.+?(?:@(.+))?$/ (used in both initial workflow ref parsing and referenced_workflows entry parsing) to a module-level named constant GITHUB_REPO_PATH_RE. This eliminates duplication added in PR #24433 and makes the intent of the pattern explicit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pelikhan
approved these changes
Apr 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors check_workflow_timestamp_api.cjs to remove duplication by extracting the GitHub repo/workflow ref parsing regex into a single named module-level constant.
Changes:
- Introduced
GITHUB_REPO_PATH_RE(with an explanatory comment) to centralize the workflow ref parsing pattern. - Updated both call sites to use the shared constant instead of duplicating the same regex literal.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/check_workflow_timestamp_api.cjs | Deduplicates the owner/repo/ref extraction regex by introducing GITHUB_REPO_PATH_RE and reusing it in both parsing locations. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Simplification of recently modified code from PR #24433.
The regex
/^([^/]+)\/([^/]+)\/.+?(?:@(.+))?$/was introduced in two places withincheck_workflow_timestamp_api.cjsby PR #24433:GITHUB_WORKFLOW_REFto extractowner/repo/refreferenced_workflowspath entry to extractowner/repo/refBoth uses serve the same purpose — extracting
owner,repo, and optionalreffrom a GitHub path likeorg/repo/.github/workflows/file.yml@refs/heads/main.Files Simplified
actions/setup/js/check_workflow_timestamp_api.cjs— extracted duplicate regex toGITHUB_REPO_PATH_REmodule-level constantImprovements Made
GITHUB_REPO_PATH_REwith a comment documents the pattern's purposeChanges Based On
Recent changes from:
Testing
vitest run check_workflow_timestamp_api.test.cjs)make lint-cjs)make fmt-cjs)Review Focus
Please verify:
Automated by Code Simplifier Agent — analyzing code from the last 24 hours
Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
pull_request_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: