From: Markus Lehtonen Date: Fri, 24 Aug 2012 13:32:44 +0000 (+0300) Subject: buildpackage-rpm: support special tree-ish names in --git-upstream-tree X-Git-Tag: tizen/0.6.22-20150206~106 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f7e3d730d96b65678330974c5506152e7be6763;p=tools%2Fgit-buildpackage.git buildpackage-rpm: support special tree-ish names in --git-upstream-tree Support special 'WC*' and 'INDEX' values for the --git-upstream-tree option. Signed-off-by: Markus Lehtonen --- diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 22f1eea..44e01ef 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -159,12 +159,33 @@ def get_upstream_tree(repo, spec, options): raise GbpError("%s is not a valid branch" % options.upstream_branch) upstream_tree = options.upstream_branch else: - upstream_tree = options.upstream_tree + upstream_tree = get_tree(repo, options.upstream_tree) if not repo.has_treeish(upstream_tree): raise GbpError('Invalid upstream treeish %s' % upstream_tree) return upstream_tree +def get_tree(repo, tree_name): + """ + Get/create a tree-ish to be used for exporting and diffing. Accepts + special keywords for git index and working copies. + """ + if tree_name == index_name: + # Write a tree of the index + tree = repo.write_tree() + elif tree_name in wc_names: + # Write a tree of the working copy + tree = write_wc(repo, + force=wc_names[tree_name]['force'], + untracked=wc_names[tree_name]['untracked']) + else: + tree = tree_name + if not repo.has_treeish(tree): + raise GbpError('Invalid treeish object %s' % tree) + + return tree + + def git_archive_build_orig(repo, spec, output_dir, options): """ Build orig tarball using git-archive @@ -432,18 +453,7 @@ def main(argv): raise GbpError, "Use --git-ignore-branch to ignore or --git-packaging-branch to set the branch name." # Determine tree-ish to be exported - if options.export == index_name: - # Write a tree of the index - tree = repo.write_tree() - elif options.export in wc_names: - # Write a tree of the working copy - tree = write_wc(repo, - force=wc_names[options.export]['force'], - untracked=wc_names[options.export]['untracked']) - else: - tree = options.export - if not repo.has_treeish(tree): - raise GbpError('Invalid treeish object %s' % tree) + tree = get_tree(repo, options.export) # Dump from git to a temporary directory: dump_dir = tempfile.mkdtemp(dir=options.tmp_dir,