From 99124466816d9f4a691a5c3abbb4f5288dca3d04 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 3 Apr 2014 19:06:11 +0300 Subject: [PATCH] Don't read default config files if --config is given Only read the default config files if the user does not provide any config files via the --config command line option. Change-Id: If816bd325ab96f9ba218bd7dbda96c2e10225e34 Signed-off-by: Markus Lehtonen --- obs_service_gbp/command.py | 7 ++++++- tests/test_obs_service_gbp.py | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/obs_service_gbp/command.py b/obs_service_gbp/command.py index 4b684dd..41c8778 100644 --- a/obs_service_gbp/command.py +++ b/obs_service_gbp/command.py @@ -174,13 +174,18 @@ def parse_args(argv): choices=['yes', 'no']) parser.add_argument('--spec-vcs-tag', help='Set/update the VCS tag in the' 'spec file') - parser.add_argument('--config', default=default_configs, action='append', + parser.add_argument('--config', action='append', help='Config file to use, can be given multiple times') parser.add_argument('--git-meta', metavar='FILENAME', help='Write data about the exported revision into ' 'FILENAME in json format') args = parser.parse_args(argv) args.outdir = os.path.abspath(args.outdir) + + # Use default config files if --config was not defined + if args.config is None: + args.config = default_configs + return args def main(argv=None): diff --git a/tests/test_obs_service_gbp.py b/tests/test_obs_service_gbp.py index 27123db..63f3e5a 100644 --- a/tests/test_obs_service_gbp.py +++ b/tests/test_obs_service_gbp.py @@ -151,6 +151,14 @@ class TestService(UnitTestsBase): ok_(not os.path.exists(default_cache), os.listdir('.')) ok_(os.path.exists('my-repo-cache'), os.listdir('.')) + def test_options_config2(self): + """Test that empty/non-existent config file is ok""" + with open('my.conf', 'w') as conf: + conf.write('[foo-section]\n') + + ok_((service(['--url', self.orig_repo.path, '--config', 'my.conf'])) + == 0) + def test_options_git_meta(self): """Test the --git-meta option""" eq_(service(['--url', self.orig_repo.path, '--git-meta=_git_meta']), 0) -- 2.7.4