utils.git_status_checker(repo, args)
workdir = repo.path
- packaging_dir = get_packaging_dir(args)
- if not os.path.exists(os.path.join(workdir, packaging_dir)):
- raise GbsError("No packaging directory '%s/', so there is nothing to "
- "export." % packaging_dir)
# Only guess spec filename here, parse later when we have the correct
# spec file at hand
commit = 'WC.UNTRACKED'
else:
commit = 'HEAD'
+ packaging_dir = get_packaging_dir(args)
relative_spec = utils.guess_spec(workdir, packaging_dir, args.spec, commit)
if args.outdir:
git_path = os.path.abspath(git_path)
if commit_id == 'WC.UNTRACKED':
- check = lambda fname: os.path.exists(os.path.join(git_path, fname))
+ check = lambda fname, dir_only=False: os.path.exists(os.path.join( \
+ git_path, fname))
glob_ = lambda pattern: [ name.replace(git_path+'/', '')
for name in glob.glob(os.path.join(git_path, pattern)) ]
msg = 'No such spec file %s'
else:
- check = lambda fname: file_exists_in_rev(git_path, fname, commit_id)
+ check = lambda fname, dir_only=False : file_exists_in_rev(git_path, \
+ fname, commit_id, dir_only=dir_only)
glob_ = lambda pattern: glob_in_rev(git_path, pattern, commit_id)
msg = "No such spec file %%s in %s" % commit_id
+ if not check(packaging_dir, True):
+ raise GbsError("No packaging directory: '%s/', so there is nothing to "
+ "export." % packaging_dir)
if given_spec:
spec = os.path.join(packaging_dir, given_spec)
if not check(spec):
return None
-def file_exists_in_rev(git_path, relative_path, commit_id):
+def file_exists_in_rev(git_path, relative_path, commit_id, dir_only=False):
"""Check if file exists in given given revision."""
- cmd = 'cd %s; git ls-tree --name-only %s %s' % (
- git_path, commit_id, relative_path)
+ git_opts = ['--name-only']
+ if dir_only:
+ git_opts += ['-d']
+ cmd = 'cd %s; git ls-tree %s %s %s' % (
+ git_path, ' '.join(git_opts), commit_id, relative_path)
try:
output = subprocess.check_output(cmd, shell=True)