Esempio n. 1
0
    def run_append(args):
        # Print info and ask for confirmation.
        pivotal.prompt_user_to_confirm_release(args.version)

        # Merge, push and insert PT labels.
        gitflow = GitFlow()
        git = gitflow.git
        current_branch = gitflow.repo.active_branch

        develop = gitflow.develop_name()
        gitflow.name_or_current('release', args.version)
        release = gitflow.get_prefix('release') + str(args.version)

        print('')
        sys.stdout.write('Merging develop into ' + release + ' ... ')
        gitflow.checkout('release', str(args.version))
        git.merge(gitflow.develop_name())
        print('OK')

        sys.stdout.write('Pushing ' + release + ' ... ')
        gitflow.origin().push([release])
        print('OK')

        sys.stdout.write('Moving back to ' + str(current_branch) + ' ... ')
        current_branch.checkout()
        print('OK')

        sys.stdout.write('Marking Pivotal Tracker stories ... ')
        pivotal.start_release(args.version)
        print('OK')
Esempio n. 2
0
    def run_append(args):
        # Print info and ask for confirmation.
        pivotal.prompt_user_to_confirm_release(args.version)

        # Merge, push and insert PT labels.
        gitflow = GitFlow()
        git = gitflow.git
        current_branch = gitflow.repo.active_branch

        develop = gitflow.develop_name()
        gitflow.name_or_current('release', args.version)
        release = gitflow.get_prefix('release') + str(args.version)

        print('')
        sys.stdout.write('Merging develop into ' + release + ' ... ')
        gitflow.checkout('release', str(args.version))
        git.merge(gitflow.develop_name())
        print('OK')

        sys.stdout.write('Pushing ' + release + ' ... ')
        gitflow.origin().push([release])
        print('OK')

        sys.stdout.write('Moving back to ' + str(current_branch) + ' ... ')
        current_branch.checkout()
        print('OK')

        sys.stdout.write('Marking Pivotal Tracker stories ... ')
        pivotal.start_release(args.version)
        print('OK')
Esempio n. 3
0
 def test_gitflow_name_or_current_returns_name(self):
     gitflow = GitFlow(self.repo).init()
     # gitflow.init checks out `devel` branch :-(
     self.repo.branches['feat/recursion'].checkout()
     self.assertEqual('even',
         gitflow.name_or_current('feature', 'even'))
     self.assertEqual('xxxx',
         gitflow.name_or_current('feature', 'xxxx', must_exist=False))
Esempio n. 4
0
 def test_gitflow_name_or_current_returns_name(self):
     gitflow = GitFlow(self.repo).init()
     # gitflow.init checks out `devel` branch :-(
     self.repo.branches['feat/recursion'].checkout()
     self.assertEqual('even', gitflow.name_or_current('feature', 'even'))
     self.assertEqual(
         'xxxx', gitflow.name_or_current('feature',
                                         'xxxx',
                                         must_exist=False))
Esempio n. 5
0
 def run_publish(args):
     gitflow = GitFlow()
     version = gitflow.name_or_current('hotfix', args.version)
     gitflow.start_transaction('publishing hotfix branch %s' % version)
     branch = gitflow.publish('hotfix', version)
     print()
     print("Summary of actions:")
     print("- A new remote branch '%s' was created" % branch)
     print("- The local branch '%s' was configured to track the remote branch" % branch)
     print("- You are now on branch '%s'" % branch)
     print()
Esempio n. 6
0
 def run_publish(args):
     gitflow = GitFlow()
     version = gitflow.name_or_current('hotfix', args.version)
     gitflow.start_transaction('publishing hotfix branch %s' % version)
     branch = gitflow.publish('hotfix', version)
     print
     print "Summary of actions:"
     print "- A new remote branch '%s' was created" % branch
     print "- The local branch '%s' was configured to track the remote branch" % branch
     print "- You are now on branch '%s'" % branch
     print
Esempio n. 7
0
 def run_finish(args):
     gitflow = GitFlow()
     version = gitflow.name_or_current('hotfix', args.version)
     gitflow.start_transaction('finishing hotfix branch %s' % version)
     tagging_info = None
     if not args.notag:
         tagging_info = dict(
             sign=args.sign or args.signingkey,
             signingkey=args.signingkey,
             message=args.message)
     release = gitflow.finish('hotfix', version,
                              fetch=args.fetch, rebase=False,
                              keep=args.keep, force_delete=False,
                              tagging_info=tagging_info)
Esempio n. 8
0
 def run_finish(args):
     gitflow = GitFlow()
     version = gitflow.name_or_current('hotfix', args.version)
     gitflow.start_transaction('finishing hotfix branch %s' % version)
     tagging_info = None
     if not args.notag:
         tagging_info = dict(sign=args.sign or args.signingkey,
                             signingkey=args.signingkey,
                             message=args.message)
     release = gitflow.finish('hotfix',
                              version,
                              fetch=args.fetch,
                              rebase=False,
                              keep=args.keep,
                              force_delete=False,
                              tagging_info=tagging_info)
Esempio n. 9
0
 def test_gitflow_name_or_current_defaults_to_current(self):
     gitflow = GitFlow(self.repo).init()
     # gitflow.init checks out `devel` branch :-(
     self.repo.branches['feat/recursion'].checkout()
     self.assertEqual(gitflow.name_or_current('feature', ''), 'recursion')
Esempio n. 10
0
 def test_gitflow_name_or_current_defaults_to_current(self):
     gitflow = GitFlow(self.repo).init()
     # gitflow.init checks out `devel` branch :-(
     self.repo.branches['feat/recursion'].checkout()
     self.assertEqual(gitflow.name_or_current('feature', ''),
                      'recursion')
Esempio n. 11
0
 def run_pull(args):
     gitflow = GitFlow()
     name = gitflow.name_or_current('feature', args.name, must_exist=False)
     gitflow.start_transaction('pulling remote feature branch %s '
                               'into local banch %s' % (args.remote, name))
     gitflow.pull('feature', args.remote, name)
Esempio n. 12
0
    def run_finish(args):
        gitflow = GitFlow()
        git     = gitflow.git
        origin  = gitflow.origin()
        version = gitflow.name_or_current('release', args.version)

        #+++ Check if all stories were QA'd
        pt_release = pivotal.Release(args.version)
        print('Checking Pivotal Tracker stories ... ')
        pt_release.try_finish()
        print('OK')

        #+++ Check all relevant review requests in Review Board, to be sure
        rb_release = review.Release(pt_release)
        print('Checking Review Board review requests ... ')
        rb_release.try_finish(args.ignore_missing_reviews)
        print('OK')

        #+++ Merge release branch into develop and master
        sys.stdout.write('Merging release branch %s ... ' % version)
        tagging_info = None
        if not args.notag:
            tagging_info = dict(
                sign=args.sign or args.signingkey,
                signingkey=args.signingkey,
                message=args.message)
        gitflow.finish('release', version,
                                 fetch=(not args.no_fetch), rebase=False,
                                 keep=True, force_delete=False,
                                 tagging_info=tagging_info, push=False)
        print('OK')

        #+++ Close all relevant review requests
        sys.stdout.write('Submitting all relevant review requests  ... ')
        rb_release.finish()
        print('OK')

        #+++ Collect local and remote branches to be deleted
        sys.stdout.write('Collecting branches to be deleted ... ')
        local_branches  = list()
        remote_branches = list()

        #+ Collect features to be deleted.
        origin_prefix = str(origin) + '/'
        feature_prefix = gitflow.get_prefix('feature')
        # refs = [<type>/<id>/...]
        refs = [str(ref)[len(origin_prefix):] for ref in origin.refs]
        for story in pt_release:
            if story.is_rejected():
                continue
            # prefix = <feature-prefix>/<id>
            prefix = feature_prefix + str(story.get_id())
            base_marker = gitflow.managers['feature'].base_marker_name(prefix)
            try:
                name = gitflow.nameprefix_or_current('feature', prefix)
                local_branches.append(feature_prefix + name)
                if base_marker in gitflow.repo.refs:
                    local_branches.append(base_marker)
            except NoSuchBranchError:
                pass
            for ref in refs:
                # if <feature-prefix>/... startswith <feature-prefix>/<id>
                if ref.startswith(prefix) or ref == base_marker:
                    remote_branches.append(ref)
        #+ Collect releases to be deleted.
        if not args.keep:
            release_branch = gitflow.get_prefix('release') + version
            try:
                gitflow.name_or_current('release', version)
                local_branches.append(release_branch)
            except NoSuchBranchError:
                pass
            if release_branch in refs:
                remote_branches.append(release_branch)
            print 'OK'

        #+++ Delete local and remote branches that are a part of this release
        sys.stdout.write('Checking out %s ... ' % gitflow.develop_name())
        git.checkout(gitflow.develop_name())
        print 'OK'
        #+ Delete local branches.
        print 'Deleting local branches ...'
        for branch in local_branches:
            git.branch('-D', branch)
            print '    ' + branch
        print '    OK'
        #+ Delete remote branches.
        print 'Deleting remote branches and pushing the rest ...'
        for branch in remote_branches:
            print '    ' + branch
        refspecs = [(':' + b) for b in remote_branches]
        refspecs.append(gitflow.develop_name())
        refspecs.append(gitflow.master_name())
        git.push(str(origin), '--tags', *refspecs)
        print '    OK'
Esempio n. 13
0
 def run_pull(args):
     gitflow = GitFlow()
     name = gitflow.name_or_current('feature', args.name, must_exist=False)
     gitflow.start_transaction('pulling remote feature branch %s '
                               'into local banch %s' % (args.remote, name))
     gitflow.pull('feature', args.remote, name)
Esempio n. 14
0
    def run_finish(args):
        gitflow = GitFlow()
        git = gitflow.git
        origin = gitflow.origin()
        version = gitflow.name_or_current('release', args.version)

        #+++ Check if all stories were QA'd
        pt_release = pivotal.Release(args.version)
        print('Checking Pivotal Tracker stories ... ')
        pt_release.try_finish()
        print('OK')

        #+++ Check all relevant review requests in Review Board, to be sure
        rb_release = review.Release(pt_release)
        print('Checking Review Board review requests ... ')
        rb_release.try_finish(args.ignore_missing_reviews)
        print('OK')

        #+++ Merge release branch into develop and master
        sys.stdout.write('Merging release branch %s ... ' % version)
        tagging_info = None
        if not args.notag:
            tagging_info = dict(sign=args.sign or args.signingkey,
                                signingkey=args.signingkey,
                                message=args.message)
        gitflow.finish('release',
                       version,
                       fetch=(not args.no_fetch),
                       rebase=False,
                       keep=True,
                       force_delete=False,
                       tagging_info=tagging_info,
                       push=False)
        print('OK')

        #+++ Close all relevant review requests
        sys.stdout.write('Submitting all relevant review requests  ... ')
        rb_release.finish()
        print('OK')

        #+++ Collect local and remote branches to be deleted
        sys.stdout.write('Collecting branches to be deleted ... ')
        local_branches = list()
        remote_branches = list()

        #+ Collect features to be deleted.
        origin_prefix = str(origin) + '/'
        feature_prefix = gitflow.get_prefix('feature')
        # refs = [<type>/<id>/...]
        refs = [str(ref)[len(origin_prefix):] for ref in origin.refs]
        for story in pt_release:
            if story.is_rejected():
                continue
            # prefix = <feature-prefix>/<id>
            prefix = feature_prefix + str(story.get_id())
            base_marker = gitflow.managers['feature'].base_marker_name(prefix)
            try:
                name = gitflow.nameprefix_or_current('feature', prefix)
                local_branches.append(feature_prefix + name)
                if base_marker in gitflow.repo.refs:
                    local_branches.append(base_marker)
            except NoSuchBranchError:
                pass
            for ref in refs:
                # if <feature-prefix>/... startswith <feature-prefix>/<id>
                if ref.startswith(prefix) or ref == base_marker:
                    remote_branches.append(ref)
        #+ Collect releases to be deleted.
        if not args.keep:
            release_branch = gitflow.get_prefix('release') + version
            try:
                gitflow.name_or_current('release', version)
                local_branches.append(release_branch)
            except NoSuchBranchError:
                pass
            if release_branch in refs:
                remote_branches.append(release_branch)
            print 'OK'

        #+++ Delete local and remote branches that are a part of this release
        sys.stdout.write('Checking out %s ... ' % gitflow.develop_name())
        git.checkout(gitflow.develop_name())
        print 'OK'
        #+ Delete local branches.
        print 'Deleting local branches ...'
        for branch in local_branches:
            git.branch('-D', branch)
            print '    ' + branch
        print '    OK'
        #+ Delete remote branches.
        print 'Deleting remote branches and pushing the rest ...'
        for branch in remote_branches:
            print '    ' + branch
        refspecs = [(':' + b) for b in remote_branches]
        refspecs.append(gitflow.develop_name())
        refspecs.append(gitflow.master_name())
        git.push(str(origin), '--tags', *refspecs)
        print '    OK'