from obs_service_gbp import LOGGER, gbplog
from obs_service_gbp_utils import GbpServiceError, fork_call, sanitize_uid_gid
+from obs_service_gbp_utils import write_treeish_meta
from gbp_repocache import CachedRepo, CachedRepoError
import gbp_repocache
'spec file')
parser.add_argument('--config', default=default_configs, 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)
return args
return 1
# Run GBP
- return gbp_export(repo, args, config)
+ ret = gbp_export(repo, args, config)
+
+ # Write git meta file
+ if not ret and args.git_meta:
+ try:
+ write_treeish_meta(repo.repo, args.revision, args.outdir,
+ args.git_meta)
+ except GbpServiceError as err:
+ LOGGER.error(err)
+ ret = 1
+ return ret
"""Tests for the git-buildpackage OBS source service"""
import grp
+import json
import os
import stat
from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611
ok_(not os.path.exists(default_cache), os.listdir('.'))
ok_(os.path.exists('my-repo-cache'), os.listdir('.'))
+ def test_options_git_meta(self):
+ """Test the --git-meta option"""
+ eq_(service(['--url', self.orig_repo.path, '--git-meta=_git_meta']), 0)
+
+ # Check that the file was created and is json parseable
+ with open('_git_meta') as meta_fp:
+ json.load(meta_fp)
+
+ # Test failure
+ eq_(service(['--url', self.orig_repo.path,
+ '--git-meta=test-package.spec']), 1)
+
def test_user_group_config(self):
"""Test setting the user and group under which gbp is run"""
# Changing to current user/group should succeed