Skip to content
Merged
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
8 changes: 6 additions & 2 deletions .github/scripts/sync-labels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def parse_repos(value)
end
end

def path_component_escape(value)
URI.encode_www_form_component(value.to_s).gsub("+", "%20")
end

def gh_api(*args, input: nil, allow_failure: false)
command = ["gh", "api", *args]
if input
Expand Down Expand Up @@ -103,7 +107,7 @@ def discover_repos(owner:, include_archived: false)
end

def repo_opted_out?(repo, opt_out_file:)
path = opt_out_file.split("/").map { |part| URI.encode_www_form_component(part) }.join("/")
path = opt_out_file.split("/").map { |part| path_component_escape(part) }.join("/")
_stdout, _stderr, status = gh_api("repos/#{repo}/contents/#{path}", allow_failure: true)
status.success?
end
Expand Down Expand Up @@ -180,7 +184,7 @@ def apply_repo_plan(plan)
)
end
plan.fetch("updates").each do |label|
encoded = URI.encode_www_form_component(label.fetch("name"))
encoded = path_component_escape(label.fetch("name"))
gh_api(
"--method",
"PATCH",
Expand Down
5 changes: 5 additions & 0 deletions test/sync_labels_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ def test_opted_out_repo_is_skipped
assert_equal ["opted out"], plan.fetch("skips")
end

def test_label_names_are_escaped_as_path_components
assert_equal "autorelease%3A%20pending", EvalOpsLabelSync.path_component_escape("autorelease: pending")
assert_equal "area%2Fplatform", EvalOpsLabelSync.path_component_escape("area/platform")
end

def test_markdown_report_summarizes_repo_diffs
report = {
"generated_at" => "2026-05-15T12:00:00Z",
Expand Down
Loading