From: Zhang Qiang Date: Thu, 6 Mar 2014 05:18:40 +0000 (+0800) Subject: Removed tracked upstream/pristine-tar branches in time X-Git-Tag: 0.21~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=22256b6e0e62e7806c63d1f78f86d86042738513;p=tools%2Fgbs.git Removed tracked upstream/pristine-tar branches in time If no local upstream/pristine-tar branches, but exist in remote branches, gbs should track it for export packages usage in gbp. The tracked local branches is temp branch should be removed after finishing export packages. Change-Id: Iff5ba8a86b0b21b72f279eaadf6441a7178ce882 --- diff --git a/gitbuildsys/cmd_export.py b/gitbuildsys/cmd_export.py index 6b700e7..12a29ab 100644 --- a/gitbuildsys/cmd_export.py +++ b/gitbuildsys/cmd_export.py @@ -63,21 +63,32 @@ def get_packaging_dir(args): path = configmgr.get_arg_conf(args, 'packaging_dir') return path.rstrip(os.sep) -def check_export_branches(repo, args): +def track_export_branches(repo, args): '''checking export related branches: pristine-tar, upstream. give warning if pristine-tar/upstream branch exist in remote but have not been checkout to local ''' remote_branches = {} + tracked_branches = [] for branch in repo.get_remote_branches(): remote_branches[branch.split('/', 1)[-1]] = branch upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch') # track upstream/pristine-tar branch - for br in [upstream_branch, 'pristine-tar']: - if not repo.has_branch(br) and br in remote_branches: - log.info('tracking branch: %s -> %s' % (remote_branches[br], br)) - repo.create_branch(br, remote_branches[br]) + for branch in [upstream_branch, 'pristine-tar']: + if not repo.has_branch(branch ) and branch in remote_branches: + log.info('tracking branch: %s -> %s' % (remote_branches[branch], + branch)) + repo.create_branch(branch, remote_branches[branch]) + tracked_branches.append(branch) + + return tracked_branches + +def untrack_export_branches(repo, branches): + ''' remove local tracking branches, created in track_export_branches() + ''' + for branch in branches: + repo.delete_branch(branch) def create_gbp_export_args(repo, commit, export_dir, tmp_dir, spec, args, force_native=False, create_tarball=True): @@ -238,7 +249,7 @@ def main(args): directory=True) export_dir = tempd.path - check_export_branches(repo, args) + tracked_branches = track_export_branches(repo, args) with utils.Workdir(workdir): export_sources(repo, commit, export_dir, main_spec, args) @@ -258,6 +269,10 @@ def main(args): for spec in glob.glob(os.path.join(specbakd.path, "*.spec")): shutil.copy(spec, export_dir) + # Remove tracked export branches + if tracked_branches: + untrack_export_branches(repo, tracked_branches) + specfile = os.path.basename(main_spec) try: spec = rpm.SpecFile(os.path.join(export_dir, specfile))