Skip to content
Snippets Groups Projects
Commit 1af3adeb authored by capotej's avatar capotej
Browse files

Moves 'distro_version_id' from a property on Package to an argument to Client#put_package

parent 0b6d04fb
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -116,15 +116,36 @@ module Packagecloud
parsed_json_result(response)
end
 
def put_package(repo, package)
def id_for_distro_query_or_id(query_or_id)
if query_or_id.is_a? Fixnum
query_or_id
else
find_distribution_id(query_or_id)
end
end
## This is to handle older calls to put_package where
## Package had distro_version_id set
def determine_distro_version_from_package_or_param(package, query_or_id)
if query_or_id != nil
id_for_distro_query_or_id(query_or_id)
else
if package.distro_version_id
package.distro_version_id
end
end
end
def put_package(repo, package, query_or_id=nil)
assert_valid_repo_name(repo)
 
url = "/api/v1/repos/#{username}/#{repo}/packages.json"
 
mixed_msg = MIME::Multipart::FormData.new
 
if package.distro_version_id != nil
mixed_msg.add(MIME::Text.new(package.distro_version_id), "package[distro_version_id]")
distro_version_id = determine_distro_version_from_package_or_param(package, query_or_id)
if distro_version_id
mixed_msg.add(MIME::Text.new(distro_version_id), "package[distro_version_id]")
end
 
pkg_data = MIME::Application.new(package.file.read)
Loading
Loading
@@ -143,7 +164,7 @@ module Packagecloud
end
 
def find_distribution_id(distro_query)
distros = distributions
distros = distributions #TODO: perhaps memoize this per session to save on lookups
if distros.succeeded
deb_distros = distro_map distros.response["deb"]
rpm_distros = distro_map distros.response["rpm"]
Loading
Loading
Loading
Loading
@@ -14,9 +14,17 @@ module Packagecloud
raise ArgumentError, 'file cannot be nil' if file.nil?
@file = file
@filename = filename
@distro_version_id = distro_version_id
if distro_version_id
@distro_version_id = distro_version_id
end
@source_files = source_files
end
 
def distro_version_id=(distro_version_id)
deprec = "[DEPRECATION] distro_version_id on Package is deprecated, please pass distro_version_id to Client#put_package instead"
warn deprec if distro_version_id
@distro_version_id = distro_version_id
end
end
end
\ No newline at end of file
end
module Packagecloud
MAJOR_VERSION = "0"
MINOR_VERSION = "2"
PATCH_VERSION = "20"
PATCH_VERSION = "21"
 
VERSION = [MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION].join(".")
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment