lib/chef/knife/cookbook_github_install.rb in knife-github-cookbooks-0.1.5 vs lib/chef/knife/cookbook_github_install.rb in knife-github-cookbooks-0.1.6
- old
+ new
@@ -139,10 +139,23 @@
"git://github.com/#{@github_user}/#{@github_repo}.git"
end
end
def sha
- @sha ||= noauth_rest.get_rest("http://github.com/api/v2/json/repos/show/#{@github_user}/#{@github_repo}/branches")['branches'][github_branch]
+ @sha ||= begin
+ data = nil
+ raise "Unable to find SHA checksum" unless ['heads','tags'].any? do |ref_type|
+ begin
+ data = noauth_rest.get_rest("https://api.github.com/repos/#{@github_user}/#{@github_repo}/git/refs/#{ref_type}/#{github_branch}")
+ ui.info("Found #{github_branch} amoung #{ref_type}.")
+ true
+ rescue
+ ui.info("Unable to find #{github_branch} amoung #{ref_type}.")
+ false
+ end
+ end
+ data['object']['sha']
+ end
end
def github_branch
@github_branch ||= 'master'
end