From 5b28515160b9b27607c19386e417c78388658222 Mon Sep 17 00:00:00 2001 From: Zhang Qiang Date: Wed, 21 Mar 2012 14:50:05 +0800 Subject: [PATCH] add options --tag for creating tag. --- gitbuildsys/cmd_import.py | 25 +++++++++++-------------- gitbuildsys/cmd_import_orig.py | 7 +++---- tools/gbs | 10 ++++++++++ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gitbuildsys/cmd_import.py b/gitbuildsys/cmd_import.py index 9a7fa2a..8dc28b8 100644 --- a/gitbuildsys/cmd_import.py +++ b/gitbuildsys/cmd_import.py @@ -73,7 +73,6 @@ def do(opts, args): pkgname = utils.parse_spec(specfile, 'name') pkgversion = utils.parse_spec(specfile, 'version') -#import pdb;pdb.set_trace() try: repo = git.Git('.') except errors.GitInvalid: @@ -93,22 +92,20 @@ def do(opts, args): os.chdir(repo.path) - if not repo.find_tag(tag): - commit = repo.commit_dir(upstream.unpacked, msg, - author = {'name':COMM_NAME, - 'email':COMM_EMAIL - } - ) - if commit: - msger.info('submitted the upstream data as first commit') + commit = repo.commit_dir(upstream.unpacked, msg, + author = {'name':COMM_NAME, + 'email':COMM_EMAIL + } + ) + if commit: + msger.info('submitted the upstream data as first commit') + if opts.tag: msger.info('create tag named: %s' % tag) repo.create_tag(tag, msg, commit) - msger.info('create upstream branch') - repo.create_branch('upstream', commit) - else: - msger.info('No changes between currentlly git repo and tar ball') + msger.info('create upstream branch') + repo.create_branch('upstream', commit) else: - msger.info('tag %s already exsit, so dont need update' % tag) + msger.info('No changes between currentlly git repo and tar ball') packagingdir = '%s/packaging' % upstream.unpacked if not os.path.exists(packagingdir): diff --git a/gitbuildsys/cmd_import_orig.py b/gitbuildsys/cmd_import_orig.py index 0cde169..36c65cb 100644 --- a/gitbuildsys/cmd_import_orig.py +++ b/gitbuildsys/cmd_import_orig.py @@ -42,7 +42,6 @@ def do(opts, args): workdir = os.getcwd() tmpdir = '%s/%s' % (TMPDIR, USER) - import pdb;pdb.set_trace() if len(args) != 1: msger.error('missning argument, please reference gbs import-orig --help.') else: @@ -80,16 +79,16 @@ def do(opts, args): 'email':COMM_EMAIL } ) - if commit: + if commit and opts.tag: msger.info('create tag named: %s' % tag) repo.create_tag(tag, msg, commit) repo.checkout_branch('master') - if not opts.no_merge: + if commit and not opts.no_merge: try: msger.info('merge imported upstream branch to master branch') - repo.merge(tag) + repo.merge(commit) except: msger.error('Merge failed, please resolve') diff --git a/tools/gbs b/tools/gbs index 601fbe1..fb47808 100755 --- a/tools/gbs +++ b/tools/gbs @@ -186,6 +186,11 @@ class TizenPkg(cmdln.Cmdln): default=None, dest='author_email', help='author email of git commit') + @cmdln.option('--tag', + action="store_true", + default=False, + dest='tag', + help='Create tag while import new version of upstream tar ball') def do_import(self, subcmd, opts, *args): """${cmd_name}: Import spec file/source rpm/tar ball to git repository @@ -221,6 +226,11 @@ class TizenPkg(cmdln.Cmdln): default=False, dest='no_merge', help='Dont merge new upstream branch to master branch, please user merge it manually') + @cmdln.option('--tag', + action="store_true", + default=False, + dest='tag', + help='Create tag while import new version of upstream tar ball') def do_import_orig(self, subcmd, opts, *args): """${cmd_name}: Import tar ball to upstream branch -- 2.7.4