69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/package_cloud/cli/entry.rb', line 69
def push(repo, package_file, *package_files)
total_time = Benchmark.measure do
ARGV.clear
package_files << package_file
exts = package_files.map { |f| f.split(".").last }.uniq
if package_files.length > 1 && exts.length > 1
abort("You can't push multiple packages of different types at the same time.\nFor example, use *.deb to push all your debs at once.".color(:red))
end
invalid_packages = package_files.select do |f|
!["gem", "deb", "rpm", "dsc", "gz", "bz2", "z", "tar", "egg-info", "zip", "whl", "egg", "jar"].include?(f.split(".").last.downcase)
end
if ["jar"].include?(exts.first.downcase) && options.has_key?("coordinates")
puts "Using coordinates #{options["coordinates"].color(:yellow)}"
end
if !options.has_key?("skip-file-ext-validation") && invalid_packages.any?
message = "I don't know how to push these packages:\n\n".color(:red)
invalid_packages.each do |p|
message << " #{p}\n"
end
message << "\npackage_cloud only supports debs, gems, jars, python packages, and rpms.".color(:red)
abort(message)
end
if !options.has_key?("yes") && exts.first == "gem" && package_files.length > 1
answer = get_valid("Are you sure you want to push #{package_files.length} packages? (y/n)") do |s|
s == "y" || s == "n"
end
if answer != "y"
abort("Aborting...".color(:red))
end
end
validator = Validator.new(client)
if ["gz", "bz2", "z", "tar", "egg-info", "zip", "whl", "egg"].include?(exts.first.downcase)
dist_id = validator.distribution_id(repo, package_files, 'py')
elsif ["jar"].include?(exts.first.downcase)
abort_if_snapshot!(package_files)
dist_id = validator.distribution_id(repo, package_files, 'jar')
else
dist_id = validator.distribution_id(repo, package_files, exts.first)
end
split_repo = repo.split("/")[0..1].join("/")
print "Looking for repository at #{split_repo}... "
client_repo = nil
measurement = Benchmark.measure do
client_repo = client.repository(split_repo)
end
print "success!\n"
$logger.debug("repository lookup request timing: #{measurement}")
package_files.each do |f|
files = nil
ext = f.split(".").last
if ext == "dsc"
print "Checking source package #{f}... "
files = parse_and_verify_dsc(client_repo, f, dist_id)
end
print "Pushing #{f}... "
measurement = Benchmark.measure do
if options.has_key?("skip-errors")
create_package_skip_errors(client_repo, f, dist_id, files, ext, options["coordinates"])
else
create_package(client_repo, f, dist_id, files, ext, options["coordinates"])
end
end
$logger.debug("create package request timing: #{measurement}")
end
end
$logger.debug("push command total timing: #{total_time}")
end
|