Skip to content

Commit

Permalink
Merge pull request #8127 from kurtmckee/fix-version-comments-after-qu…
Browse files Browse the repository at this point in the history
…oted-strings-issue-8125

Fix version comments after quoted strings
  • Loading branch information
deivid-rodriguez authored Oct 16, 2023
2 parents 8f138a0 + 9a01d01 commit 92d8f7d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def updated_workflow_file_content(file)
updated_content =
updated_content
.gsub(
/(?<=\W|"|')#{Regexp.escape(old_declaration)}(?<comment>\s+#.*)?(?=\s|"|'|$)/
/(?<=\W|"|')#{Regexp.escape(old_declaration)}["']?(?<comment>\s+#.*)?(?=\s|$)/
) do |match|
comment = Regexp.last_match(:comment)
match.gsub!(old_declaration, new_declaration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@
it "updates SHA version" do
old_sha = dependency.previous_requirements.first.dig(:source, :ref)
expect(subject.content).to include "#{dependency.name}@#{dependency.requirements.first.dig(:source, :ref)}"
expect(subject.content).not_to match(/#{old_sha}\s+#.*#{dependency.previous_version}/)
expect(subject.content).not_to match(/#{old_sha}['"]?\s+#.*#{dependency.previous_version}/)
end
it "updates version comment" do
new_sha = dependency.requirements.first.dig(:source, :ref)
expect(subject.content).not_to match(/@#{new_sha}\s+#.*#{dependency.previous_version}\s*$/)
expect(subject.content).not_to match(/@#{new_sha}['"]?\s+#.*#{dependency.previous_version}\s*$/)

expect(subject.content).to include "# v#{dependency.version}"
expect(subject.content).to include "# #{dependency.version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jobs:
- uses: actions/checkout@01aecccf739ca6ff86c0539fbc67a7a5007bbc81 #v2.1.0
# The comment on the next line has a trailing tab. The version should still be updated.
- uses: actions/checkout@01aecccf739ca6ff86c0539fbc67a7a5007bbc81 #v2.1.0
- uses: actions/checkout@01aecc # v2.1.0
- uses: "actions/checkout@01aecccf739ca6ff86c0539fbc67a7a5007bbc81" # v2.1.0
- uses: 'actions/checkout@01aecccf739ca6ff86c0539fbc67a7a5007bbc81' # v2.1.0
integration:
- uses: actions/checkout@v2.1.0 # comments that include the version (v2.1.0) shouldn't be updated for non-SHA refs
- uses: actions/checkout@01aecc#v2.1.0 # this shouldn't be updated, because the version is part of the ref, not a comment.
- uses: actions/checkout@01aecccf739ca6ff86c0539fbc67a7a5007bbc81#v2.1.0 # this shouldn't be updated, because the version is part of the ref, not a comment.

# The version in the comment for the next action shouldn't be updated
# because it refers to past behavior.
Expand Down

0 comments on commit 92d8f7d

Please sign in to comment.