-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update version comments for SHA-pinned GitHub Actions #1
Conversation
3c9fb06
to
1c6c9da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are mostly style suggestions. But the next
weirds me out. The if style might satisfy what you expect
# and followed by a whitespace character (comments) or EOL | ||
# and followed by a whitespace character (comments) or EOL. | ||
# If the declaration is followed by a comment, attempt to update | ||
# any version comments associated with SHA source refs. | ||
updated_content = | ||
updated_content. | ||
gsub( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could use updated_content.gsub!
instead of updated_content = updated_content.gsub
. The !
mutates the original updated_content
) | ||
/(?<=\W|"|')#{Regexp.escape(old_declaration)}(?<comment>\s+#.*)?(?=\s|"|'|$)/ | ||
) do |s| | ||
comment = Regexp.last_match(:comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this might also work
s.gsub!(old_declaration, new_declaration)
if (comment = Regexp.last_match(:comment))
if (updated_comment = updated_version_comment(comment, new_req))
s.gsub!(comment, updated_comment)
end
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got this suggestion working and I like it much better. Thanks!
56737a2
to
5b57517
Compare
GitHub encourages pinning third-party GitHub Actions to a full length commit SHA. It's common for actions pinned by commit SHA to include a comment specifying the version associated with the commit. For example: - uses: actions/checkout@01aecc # v2.1.0 This change updates the GitHub Actions manager to bump versions in comments that follow SHA-pinned actions, so the comment stays up-to-date with the SHA being updated. The file_updater now searches the comment string for all references to the previous version and replaces them with the new version. To avoid changing unrelated comments, the comment updater only updates dependencies that pin SHA refs.
5b57517
to
96b107c
Compare
Moved to dependabot#5951 🎉 |
GitHub advocates pinning third-party GitHub Actions to a full length commit SHA. In practice, it's common for actions pinned by commit SHA to include a comment which includes the version associated with the commit. For example:
This change updates the GitHub Actions manager to bump versions in comments that follow SHA-pinned actions, so the comment stays up-to-date with the SHA being updated.
The file_updater now searches the comment string for all references to the previous version and replaces them with the new version. To avoid changing unrelated comments, the comment updater only updates dependencies that pin SHA refs.