mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-27 02:16:12 +01:00
fixes 413 checkout deleted package
* altered command do_checkout new option -D | --deleted. Can only be used with PACKAGE and needs -o to work * what happens: core function checkout_deleted_package fetches the file list of the deleted package and saves it to given destdir. If destdir is not existent it creates the destination directory. Otherwise the files will be written in the existing directory.
This commit is contained in:
parent
b730f880cf
commit
0123bb71db
@ -4280,6 +4280,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
@cmdln.option('-e', '--expand-link', action='store_true',
|
@cmdln.option('-e', '--expand-link', action='store_true',
|
||||||
help='if a package is a link, check out the expanded '
|
help='if a package is a link, check out the expanded '
|
||||||
'sources (no-op, since this became the default)')
|
'sources (no-op, since this became the default)')
|
||||||
|
@cmdln.option('-D', '--deleted', action='store_true',
|
||||||
|
help='checkout an already deleted package. No meta information ')
|
||||||
@cmdln.option('-u', '--unexpand-link', action='store_true',
|
@cmdln.option('-u', '--unexpand-link', action='store_true',
|
||||||
help='if a package is a link, check out the _link file ' \
|
help='if a package is a link, check out the _link file ' \
|
||||||
'instead of the expanded sources')
|
'instead of the expanded sources')
|
||||||
@ -4364,6 +4366,12 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
project_dir = os.curdir
|
project_dir = os.curdir
|
||||||
package = args[0]
|
package = args[0]
|
||||||
|
|
||||||
|
if opts.deleted and package:
|
||||||
|
if not opts.output_dir:
|
||||||
|
raise oscerr.WrongOptions('-o | --output-dir is needed to get deleted sources')
|
||||||
|
elif opts.deleted and not package:
|
||||||
|
raise oscerr.WrongOptions('-D | --deleted can only be used with a package')
|
||||||
|
|
||||||
rev, dummy = parseRevisionOption(opts.revision)
|
rev, dummy = parseRevisionOption(opts.revision)
|
||||||
if rev == None:
|
if rev == None:
|
||||||
rev = "latest"
|
rev = "latest"
|
||||||
@ -4379,14 +4387,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
get_source_file(apiurl, project, package, filename, revision=rev, progress_obj=self.download_progress)
|
get_source_file(apiurl, project, package, filename, revision=rev, progress_obj=self.download_progress)
|
||||||
|
|
||||||
elif package:
|
elif package:
|
||||||
if opts.current_dir:
|
if opts.deleted:
|
||||||
project_dir = None
|
checkout_deleted_package(apiurl, project, package, opts.output_dir)
|
||||||
checkout_package(apiurl, project, package, rev, expand_link=expand_link, \
|
else:
|
||||||
prj_dir=project_dir, service_files = opts.source_service_files, \
|
if opts.current_dir:
|
||||||
server_service_files=opts.server_side_source_service_files, \
|
project_dir = None
|
||||||
progress_obj=self.download_progress, size_limit=opts.limit_size, \
|
checkout_package(apiurl, project, package, rev, expand_link=expand_link, \
|
||||||
meta=opts.meta, outdir=opts.output_dir)
|
prj_dir=project_dir, service_files = opts.source_service_files, \
|
||||||
print_request_list(apiurl, project, package)
|
server_service_files=opts.server_side_source_service_files, \
|
||||||
|
progress_obj=self.download_progress, size_limit=opts.limit_size, \
|
||||||
|
meta=opts.meta, outdir=opts.output_dir)
|
||||||
|
print_request_list(apiurl, project, package)
|
||||||
|
|
||||||
elif project:
|
elif project:
|
||||||
prj_dir = opts.output_dir if opts.output_dir else project
|
prj_dir = opts.output_dir if opts.output_dir else project
|
||||||
|
20
osc/core.py
20
osc/core.py
@ -7763,4 +7763,24 @@ def get_rpmlint_log(apiurl, proj, pkg, repo, arch):
|
|||||||
f = http_GET(u)
|
f = http_GET(u)
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
|
def checkout_deleted_package(apiurl, proj, pkg, dst):
|
||||||
|
pl = meta_get_filelist(apiurl, proj, pkg, deleted=True)
|
||||||
|
query = {}
|
||||||
|
query['deleted'] = 1
|
||||||
|
|
||||||
|
if os.path.isdir(dst):
|
||||||
|
print('Restoring in existing directory %s' % dst)
|
||||||
|
else:
|
||||||
|
print('Creating %s' % dst)
|
||||||
|
os.makedirs(dst)
|
||||||
|
|
||||||
|
for filename in pl:
|
||||||
|
print('Restoring %s to %s' % (filename, dst))
|
||||||
|
full_file_path = os.path.join(dst, filename)
|
||||||
|
u = makeurl(apiurl, ['source', proj, pkg, filename], query=query)
|
||||||
|
with open(full_file_path, 'wb') as f:
|
||||||
|
for data in streamfile(u):
|
||||||
|
f.write(data)
|
||||||
|
print('done.')
|
||||||
|
|
||||||
# vim: sw=4 et
|
# vim: sw=4 et
|
||||||
|
Loading…
Reference in New Issue
Block a user