From b85564110510d3af0b942e6383ffb49be881cc31 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Wed, 17 Oct 2012 13:54:31 +0300 Subject: [PATCH] submit: fixes to target guessing logic Try to find the upstream branch of the current branch, not the target. Also, get rid of the confusing variable name 'target_branch' as we're not submitting to any branch - the 'target' is just one part of the tag name. Signed-off-by: Markus Lehtonen --- gitbuildsys/cmd_submit.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/gitbuildsys/cmd_submit.py b/gitbuildsys/cmd_submit.py index 8fe7846..e9f8506 100644 --- a/gitbuildsys/cmd_submit.py +++ b/gitbuildsys/cmd_submit.py @@ -37,15 +37,12 @@ def main(args): try: repo = RpmGitRepository(workdir) commit = repo.rev_parse(args.commit) - if args.target: - target_branch = args.target - else: - target_branch = repo.get_branch() + current_branch = repo.get_branch() except GitRepositoryError, err: msger.error(str(err)) try: - upstream = repo.get_upstream_branch(target_branch) + upstream = repo.get_upstream_branch(current_branch) except GitRepositoryError: upstream = None pass @@ -58,17 +55,18 @@ def main(args): args.remote = 'origin' if not args.target: if upstream and upstream.startswith(args.remote): - target_branch = os.path.basename(upstream) + args.target = os.path.basename(upstream) else: - msger.warning('can\'t find upstream branch for current branch '\ - '%s. Gbs will try to find it by name. Please '\ - 'consider to use git-branch --set-upstream to '\ - 'set upstream remote branch.' % target_branch) + msger.warning("Can't find upstream branch for current branch " + "%s. Gbs uses the local branch name as the target. " + "Please consider to use git-branch --set-upstream " + "to set upstream remote branch." % current_branch) + args.target = current_branch try: - if target_branch == 'master': - target_branch = 'trunk' - tagname = 'submit/%s/%s' % (target_branch, time.strftime( \ + if args.target == 'master': + args.target = 'trunk' + tagname = 'submit/%s/%s' % (args.target, time.strftime( \ '%Y%m%d.%H%M%S', time.gmtime())) msger.info('creating tag: %s' % tagname) repo.create_tag(tagname, msg=args.msg, commit=commit, sign=args.sign, -- 2.34.1