我正在尝试通过Github API创建一个关闭master的新分支,但是我收到了“Reference update failed”错误。这是我的红宝石代码:
def self.create_ref access_token, github_user, github_repo, ref
sha=nil
url = "https://api.github.com/repos/#{github_user}/#{github_repo}/git/refs/heads/master"
RestClient.get(url,{params:{access_token:access_token},accept:'json'}){ |response, request, result|
puts response
sha=JSON.parse(response)['object']['sha']
}
url = "https://api.github.com/repos/#{github_user}/#{github_repo}/git/refs"
RestClient.post(url,{ref:name,sha:sha }.to_json,{params:{access_token:access_token},accept:'json'}){ |response, request, result|
puts response
}
end
使用master sha代码是否有错误的方法来创建新的ref?