import gbp_repocache
from gbp_repocache import CachedRepo, CachedRepoError
from obs_service_gbp_utils import GbpServiceError, fork_call, sanitize_uid_gid
+from obs_service_gbp_utils import write_treeish_meta
# Setup logging
choices=['yes', 'no'])
parser.add_argument('--config', action='append',
help='Config file to use, can be given multiple times')
+ parser.add_argument('--git-meta', metavar='FILENAME',
+ help='Create a json-formatted file FILENAME containing'
+ 'metadata about the exported revision')
args = parser.parse_args(argv)
if not args.config:
args.config = default_configs
# Export sources with GBS
gbs_export(repo, args, config)
+ # Write git-meta
+ if args.git_meta:
+ try:
+ write_treeish_meta(repo.repo, args.revision, args.outdir,
+ args.git_meta)
+ except GbpServiceError as err:
+ raise ServiceError(str(err), 1)
except ServiceError as err:
LOGGER.error(err[0])
ret = err[1]
Requires: gbs-export
Requires: git-buildpackage-common
Requires: gbp-repocache
-Requires: obs-service-git-buildpackage-utils
+Requires: obs-service-git-buildpackage-utils > 0.5
BuildRequires: python
BuildRequires: python-setuptools
%if 0%{?do_unittests}
"""Tests for the GBS source service"""
import grp
+import json
import os
import shutil
import stat
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 the user/group settings"""
# Changing to current user/group should succeed