From f65f08dfbb07781c3a5769a10ad1e6007ef69b1b Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Thu, 11 Mar 2021 17:52:05 +0100 Subject: [PATCH] Add "--force" option to the "osc add" command "osc add --force " adds the filename to the working copy even if it is excluded by the exclude_glob config option. --- osc/commandline.py | 4 +++- osc/core.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index b4d065b7..e7903b6f 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4759,6 +4759,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. print('\n'.join(lines)) + @cmdln.option('-f', '--force', action='store_true', + help='add files even if they are excluded by the exclude_glob config option') def do_add(self, subcmd, opts, *args): """${cmd_name}: Mark files to be added upon the next commit @@ -4784,7 +4786,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. elif arg.startswith('http://') or arg.startswith('https://') or arg.startswith('ftp://'): addDownloadUrlService(arg) else: - addFiles([arg]) + addFiles([arg], force=opts.force) def do_mkpac(self, subcmd, opts, *args): diff --git a/osc/core.py b/osc/core.py index 3854401b..d9262f74 100644 --- a/osc/core.py +++ b/osc/core.py @@ -7208,7 +7208,7 @@ def addDownloadUrlService(url): f.close() -def addFiles(filenames, prj_obj = None): +def addFiles(filenames, prj_obj = None, force=False): for filename in filenames: if not os.path.exists(filename): raise oscerr.OscIOError(None, 'file \'%s\' does not exist' % filename) @@ -7267,7 +7267,7 @@ def addFiles(filenames, prj_obj = None): for filename in pac.todo: if filename in pac.skipped: continue - if filename in pac.excluded: + if filename in pac.excluded and not force: print('osc: warning: \'%s\' is excluded from a working copy' % filename, file=sys.stderr) continue try: