Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the readability/maintainability of the pr-checks/sync_back.ts sync-back script by documenting and centralizing the regular expressions it uses to detect and update GitHub Action references.
Changes:
- Adds detailed documentation and names for the regexes used to extract and replace action references.
- Refactors regex construction/replacement into reusable
SyncBackPatternbuilders plus a shared escaping helper.
Comments suppressed due to low confidence (2)
pr-checks/sync_back.ts:77
- The comment for
YAML_PATTERNsays it groupsuses: actionNameandrest_of_line, but the regex only capturesuses: actionName(group 1) and does not capture the remainder of the line. Please correct the comment (or add a second capture group if that was the intent).
/**
* Used to find lines containing action references in a PR check specification.
*
* Matches `uses: actionName@rest_of_line` in PR check specifications and groups `uses: actionName`
* and `rest_of_line`, allowing `rest_of_line` to be replaced with a new version string.
*/
const YAML_PATTERN: SyncBackPattern = (actionName: string) =>
new RegExp(`(uses:\\s+${actionName})@(?:[^@\n]+)`, "g");
pr-checks/sync_back.ts:52
ESCAPE_PATTERNis used to escape regex metacharacters before interpolatingactionNameinto aRegExp, not for escaping TypeScript/YAML string literals. Consider tweaking this comment to avoid implying it handles string escaping.
/**
* Used to identify characters in `action_name` strings that need to
* be escaped before inserting them into TypeScript or YAML strings.
*/
const ESCAPE_PATTERN = /[.*+?^${}()|[\]\\]/g;
aaf2d8d to
6531f80
Compare
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.
Follow up to #3529 to address @esbena's review comment.
Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Environments:
How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist