from gbp.rpm import (SpecFile, guess_spec)
from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base,
parse_gbp_commands, format_patch,
+ format_diff,
switch_to_pq_branch, apply_single_patch,
apply_and_commit_patch, drop_pq)
if not repo.has_treeish(treeish):
raise GbpError('%s not a valid tree-ish' % treeish)
+ try:
+ end_commit = end
+ end_commit_sha1 = repo.rev_parse("%s^0" % end_commit)
+ except GitRepositoryError:
+ # In case of plain tree-ish objects, assume current branch head is the
+ # last commit
+ end_commit = "HEAD"
+ end_commit_sha1 = repo.rev_parse("%s^0" % end_commit)
+
+ start_sha1 = repo.rev_parse("%s^0" % start)
+ if repo.get_merge_base(start_sha1, end_commit_sha1) != start_sha1:
+ raise GbpError("Start commit '%s' not an ancestor of end commit "
+ "'%s'" % (start, end_commit))
# Generate patches
- for commit in reversed(repo.get_commits(start, end)):
+ for commit in reversed(repo.get_commits(start, end_commit)):
info = repo.get_commit_info(commit)
cmds = parse_gbp_commands(info, 'gbp-rpm', ('ignore'), None)[0]
if not 'ignore' in cmds:
else:
gbp.log.info('Ignoring commit %s' % info['id'])
+ # Generate diff to the tree-ish object
+ if end_commit != end:
+ gbp.log.info("Generating diff file %s..%s" % (end_commit, end))
+ patch_fn = format_diff(outdir, None, repo, end_commit, end)
+ if patch_fn:
+ patches.append(patch_fn)
+
return patches, commands