1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-04 18:46:17 +01:00

Add "--force" option to the "osc add" command

"osc add --force <filename>" adds the filename to the working copy
even if it is excluded by the exclude_glob config option.
This commit is contained in:
Marcus Huewe 2021-03-11 17:52:05 +01:00
parent 9fb287c7c2
commit f65f08dfbb
2 changed files with 5 additions and 3 deletions

View File

@ -4759,6 +4759,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print('\n'.join(lines)) 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): def do_add(self, subcmd, opts, *args):
"""${cmd_name}: Mark files to be added upon the next commit """${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://'): elif arg.startswith('http://') or arg.startswith('https://') or arg.startswith('ftp://'):
addDownloadUrlService(arg) addDownloadUrlService(arg)
else: else:
addFiles([arg]) addFiles([arg], force=opts.force)
def do_mkpac(self, subcmd, opts, *args): def do_mkpac(self, subcmd, opts, *args):

View File

@ -7208,7 +7208,7 @@ def addDownloadUrlService(url):
f.close() f.close()
def addFiles(filenames, prj_obj = None): def addFiles(filenames, prj_obj = None, force=False):
for filename in filenames: for filename in filenames:
if not os.path.exists(filename): if not os.path.exists(filename):
raise oscerr.OscIOError(None, 'file \'%s\' does not exist' % 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: for filename in pac.todo:
if filename in pac.skipped: if filename in pac.skipped:
continue 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) print('osc: warning: \'%s\' is excluded from a working copy' % filename, file=sys.stderr)
continue continue
try: try: