Skip to content

Commit

Permalink
Merge branch '4-stable' into 4-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
tarebyte authored May 15, 2021
2 parents e704ad9 + 9aa29ba commit d3a368b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/octokit/client/refs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def ref(repo, ref, options = {})
# @example Create refs/heads/master for octocat/Hello-World with sha 827efc6d56897b048c772eb4087f854f46256132
# Octokit.create_ref("octocat/Hello-World", "heads/master", "827efc6d56897b048c772eb4087f854f46256132")
def create_ref(repo, ref, sha, options = {})
ref = "refs/#{ref}" unless ref =~ %r{refs/}
ref = "refs/#{ref}" unless ref =~ %r{\Arefs/}
parameters = {
:ref => ref,
:sha => sha
Expand Down
7 changes: 7 additions & 0 deletions spec/octokit/client/refs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
assert_requested request
end

it "prepends refs/ to the ref parameter when required" do
request = stub_post("/repos/#{@test_repo}/git/refs").
with(:body => {ref: "refs/heads/refs/test-ref-2", sha: @first_sha}.to_json)
@client.create_ref(@test_repo, "heads/refs/test-ref-2", @first_sha)
assert_requested request
end

it "does not duplicate refs/ in ref parameter" do
request = stub_post("/repos/#{@test_repo}/git/refs").
with(:body => {ref: "refs/heads/testing/test-ref-2", sha: @first_sha}.to_json)
Expand Down

0 comments on commit d3a368b

Please sign in to comment.