Unverified Commit 0a654b94 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Automatically guess the project name when we can



Signed-off-by: Andrej Shadura's avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent 14a8d2b0
......@@ -8,7 +8,9 @@ import osc_plugin_dput
@cmdln.option('--maintained-in-git', action='store_true',
help='add MAINTAINED_IN_GIT.txt')
def do_dput(self, subcmd, opts, proj_name, dsc_file):
@cmdln.option('--no-auto', action='store_true',
help='don\'t guess the project name')
def do_dput(self, subcmd, opts, *args):
"""${cmd_name}: Automate the process of submitting a Debian package to the OBS server
It expects a PROJECT_NAME and a .dsc, source .changes file, or
......@@ -25,4 +27,4 @@ def do_dput(self, subcmd, opts, proj_name, dsc_file):
if hasattr(self, "osc_plugin_dput"):
osc_plugin_dput = self.osc_plugin_dput
osc_plugin_dput.do_dput(self, subcmd, opts, proj_name, dsc_file)
osc_plugin_dput.do_dput(self, subcmd, opts, *args)
......@@ -110,7 +110,30 @@ class DPut(object):
@cmdln.option('--maintained-in-git', action='store_true',
help='add MAINTAINED_IN_GIT.txt')
def do_dput(self, subcmd, opts, proj_name, dsc_or_changes_file):
def do_dput(self, subcmd, opts, *args):
if len(args) < 1:
raise WrongArgs('Missing the project name and the source package.\n\n'
+ self.get_cmd_help('dput'))
if len(args) == 1:
if opts.no_auto:
raise WrongArgs('Missing the project name.\n\n'
+ self.get_cmd_help('dput'))
dsc_or_changes_file = args[0]
cwd = Path.cwd()
if osc.core.is_project_dir(cwd) or osc.core.is_package_dir(cwd):
proj_name = osc.core.store_read_project(cwd)
elif osc.core.is_project_dir(cwd.parent) or osc.core.is_package_dir(cwd.parent):
proj_name = osc.core.store_read_project(core.parent)
else:
raise WrongArgs('Can\'t guess the project name and none passed.')
print("Automatically detected the project to submit changes to:", proj_name)
elif len(args) == 2:
proj_name, dsc_or_changes_file = args
else:
raise WrongArgs('Too many arguments, not sure what to do.\n\n'
+ self.get_cmd_help('dput'))
with TemporaryDirectory('_oscdput') as working_dir:
# get debian .change object before moving current path to the
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment