Skip to content
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

Bump commonmarker from 0.23.10 to 1.0.4 in /updater #9593

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PATH
aws-sdk-codecommit (~> 1.28)
aws-sdk-ecr (~> 1.5)
bundler (>= 1.16, < 3.0.0)
commonmarker (>= 0.20.1, < 0.24.0)
commonmarker (>= 1.0.0, < 1.1.0)
docker_registry2 (~> 1.18.0)
excon (~> 0.109)
faraday (= 2.7.11)
Expand Down Expand Up @@ -162,7 +162,7 @@ GEM
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
citrus (3.0.2)
commonmarker (0.23.10)
commonmarker (1.0.4-arm64-darwin)
crack (0.4.5)
rexml
debug (1.9.2)
Expand Down
2 changes: 1 addition & 1 deletion common/dependabot-common.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "aws-sdk-codecommit", "~> 1.28"
spec.add_dependency "aws-sdk-ecr", "~> 1.5"
spec.add_dependency "bundler", ">= 1.16", "< 3.0.0"
spec.add_dependency "commonmarker", ">= 0.20.1", "< 0.24.0"
spec.add_dependency "commonmarker", ">= 1.0.0", "< 1.1.0"
spec.add_dependency "docker_registry2", "~> 1.18.0"
spec.add_dependency "excon", "~> 0.109"
spec.add_dependency "faraday", "2.7.11"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# typed: strong
# frozen_string_literal: true

require "commonmarker"
require "sorbet-runtime"
require "strscan"
require "dependabot/pull_request_creator/message_builder"
require 'commonmarker'

module Dependabot
class PullRequestCreator
Expand Down Expand Up @@ -44,7 +44,7 @@ def initialize(github_redirection_service:)

sig { params(text: String, unsafe: T::Boolean, format_html: T::Boolean).returns(String) }
def sanitize_links_and_mentions(text:, unsafe: false, format_html: true)
doc = CommonMarker.render_doc(
doc = Commonmarker.render_doc(
text, :LIBERAL_HTML_TAG, COMMONMARKER_EXTENSIONS
)

Expand All @@ -61,7 +61,7 @@ def sanitize_links_and_mentions(text:, unsafe: false, format_html: true)

private

sig { params(doc: CommonMarker::Node).void }
sig { params(doc: Commonmarker::Node).void }
def sanitize_mentions(doc)
doc.walk do |node|
if node.type == :text &&
Expand All @@ -86,7 +86,7 @@ def sanitize_mentions(doc)
# This is because there are ecosystems that have packages that follow the same pattern
# (e.g. @angular/angular-cli), and we don't want to create an invalid link, since
# team mentions link to `https://github.com/org/:organization_name/teams/:team_name`.
sig { params(doc: CommonMarker::Node).void }
sig { params(doc: Commonmarker::Node).void }
def sanitize_team_mentions(doc)
doc.walk do |node|
if node.type == :text &&
Expand All @@ -102,7 +102,7 @@ def sanitize_team_mentions(doc)
end
end

sig { params(doc: CommonMarker::Node).void }
sig { params(doc: Commonmarker::Node).void }
def sanitize_links(doc)
doc.walk do |node|
if node.type == :link && node.url.match?(GITHUB_REF_REGEX)
Expand All @@ -126,7 +126,7 @@ def sanitize_links(doc)
end
end

sig { params(doc: CommonMarker::Node).void }
sig { params(doc: Commonmarker::Node).void }
def sanitize_nwo_text(doc)
doc.walk do |node|
if node.type == :text &&
Expand All @@ -137,7 +137,7 @@ def sanitize_nwo_text(doc)
end
end

sig { params(node: CommonMarker::Node).void }
sig { params(node: Commonmarker::Node).void }
def replace_nwo_node(node)
match = T.must(node.string_content.match(GITHUB_NWO_REGEX))
repo = match.named_captures.fetch("repo")
Expand All @@ -156,17 +156,17 @@ def replace_github_host(text)
)
end

sig { params(text: String).returns(T::Array[CommonMarker::Node]) }
sig { params(text: String).returns(T::Array[Commonmarker::Node]) }
def build_mention_nodes(text)
nodes = T.let([], T::Array[CommonMarker::Node])
nodes = T.let([], T::Array[Commonmarker::Node])
scan = StringScanner.new(text)

until scan.eos?
line = scan.scan_until(MENTION_REGEX) ||
scan.scan_until(EOS_REGEX)
line_match = T.must(line).match(MENTION_REGEX)
mention = line_match&.to_s
text_node = CommonMarker::Node.new(:text)
text_node = Commonmarker::Node.new(:text)

if mention && !mention.end_with?("/")
text_node.string_content = line_match.pre_match
Expand All @@ -183,17 +183,17 @@ def build_mention_nodes(text)
nodes
end

sig { params(text: String).returns(T::Array[CommonMarker::Node]) }
sig { params(text: String).returns(T::Array[Commonmarker::Node]) }
def build_team_mention_nodes(text)
nodes = T.let([], T::Array[CommonMarker::Node])
nodes = T.let([], T::Array[Commonmarker::Node])

scan = StringScanner.new(text)
until scan.eos?
line = scan.scan_until(TEAM_MENTION_REGEX) ||
scan.scan_until(EOS_REGEX)
line_match = T.must(line).match(TEAM_MENTION_REGEX)
mention = line_match&.to_s
text_node = CommonMarker::Node.new(:text)
text_node = Commonmarker::Node.new(:text)

if mention
text_node.string_content = line_match.pre_match
Expand All @@ -208,24 +208,24 @@ def build_team_mention_nodes(text)
nodes
end

sig { params(text: String).returns(T::Array[CommonMarker::Node]) }
sig { params(text: String).returns(T::Array[Commonmarker::Node]) }
def build_mention_link_text_nodes(text)
code_node = CommonMarker::Node.new(:code)
code_node = Commonmarker::Node.new(:code)
code_node.string_content = insert_zero_width_space_in_mention(text)
[code_node]
end

sig { params(text: String).returns(CommonMarker::Node) }
sig { params(text: String).returns(Commonmarker::Node) }
def build_nwo_text_node(text)
code_node = CommonMarker::Node.new(:code)
code_node = Commonmarker::Node.new(:code)
code_node.string_content = text
code_node
end

sig { params(url: String, text: String).returns(CommonMarker::Node) }
sig { params(url: String, text: String).returns(Commonmarker::Node) }
def create_link_node(url, text)
link_node = CommonMarker::Node.new(:link)
code_node = CommonMarker::Node.new(:code)
link_node = Commonmarker::Node.new(:link)
code_node = Commonmarker::Node.new(:code)
link_node.url = url
code_node.string_content = insert_zero_width_space_in_mention(text)
link_node.append_child(code_node)
Expand All @@ -241,7 +241,7 @@ def insert_zero_width_space_in_mention(mention)
mention.sub("@", "@\u200B").encode("utf-8")
end

sig { params(node: CommonMarker::Node).returns(T::Boolean) }
sig { params(node: Commonmarker::Node).returns(T::Boolean) }
def parent_node_link?(node)
node.type == :link || (!node.parent.nil? && parent_node_link?(T.must(node.parent)))
end
Expand Down
Loading
Loading