Skip to content

Commit 1658f4a

Browse files
authored
fix(github_hooks): encode branch, tag name when fetching reference (#451)
## 📝 Description Fixes issue where triggering workflows via API fails for branches or tags containing `#` by URI-encoding branch and tag names before retrieving references through the GitHub API. [Task](renderedtext/tasks#8329) ## ✅ Checklist - [x] I have tested this change - [x] ~This change requires documentation update~ N/A
1 parent 74b47bb commit 1658f4a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

github_hooks/lib/internal_api/repo_proxy/branch_payload.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ def initialize(ref, sha)
1010
def call(project, user)
1111
repo_host = ::RepoHost::Factory.create_from_project(project)
1212

13-
reference = repo_host.reference(project.repo_owner_and_name, ref.delete_prefix("refs/"))
13+
encoded_ref = CGI.escape(ref.delete_prefix("refs/heads/"))
14+
reference = repo_host.reference(project.repo_owner_and_name, "heads/#{encoded_ref}")
1415

1516
branch_commit = repo_host.commit(project.repo_owner_and_name, commit_sha(sha, reference))
1617

github_hooks/lib/internal_api/repo_proxy/tag_payload.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ def initialize(ref)
77
def call(project, user)
88
repo_host = ::RepoHost::Factory.create_from_project(project)
99

10-
reference = repo_host.reference(project.repo_owner_and_name, ref.delete_prefix("refs/"))
10+
encoded_ref = CGI.escape(ref.delete_prefix("refs/tags/"))
11+
reference = repo_host.reference(project.repo_owner_and_name, "tags/#{encoded_ref}")
1112

1213
tag_commit = repo_host.commit(project.repo_owner_and_name, commit_sha(reference, repo_host, project))
1314

0 commit comments

Comments
 (0)