コード例 #1
0
ファイル: __init__.py プロジェクト: tvoyle/gitflow
    def run_finish(args):
        gitflow = GitFlow()
        repo = gitflow.repo
        git = repo.git

        f_prefix = gitflow.get_prefix('feature')
        name = gitflow.nameprefix_or_current('feature', args.nameprefix)
        full_name = f_prefix + name

        #+++ PT story stuff
        sys.stdout.write('Getting data from Pivotal Tracker ... ')
        story_id = pivotal.get_story_id_from_branch_name('feature', name)
        story = pivotal.Story(story_id)
        release = story.get_release()
        print 'OK'

        # Decide on the upstream branch.
        if release:
            # Merge into the release branch.
            r_prefix = gitflow.get_prefix('release')
            short_name = gitflow.nameprefix_or_current('release', release)
            upstream = r_prefix + short_name
        else:
            # Merge into the develop branch.
            upstream = gitflow.develop_name()

        # Fail as soon as possible if something is not right so that we don't
        # get Pivotal Tracker into an inconsistent state.
        rev_range = [get_feature_ancestor(full_name, upstream),
                     repo.commit(full_name).hexsha]

        #+++ Git manipulation
        sys.stdout.write('Finishing feature branch ... upstream %s ... ' \
                         % upstream)
        gitflow.finish('feature', name, upstream=upstream,
                       fetch=True, rebase=args.rebase,
                       keep=True, force_delete=args.force_delete,
                       tagging_info=None, push=(not args.no_push))
        print 'OK'

        #+++ Review Request
        if not args.no_review:
            sys.stdout.write('Posting review ... upstream %s ... ' % upstream)
            review = BranchReview.from_identifier('feature', name, rev_range)
            review.post(story, summary_from_story=(not args.summary_from_commit))
            print('OK')

            sys.stdout.write('Posting code review url into Pivotal Tracker ... ')
            comment = 'New patch was uploaded into Review Board: ' + review.get_url()
            story.add_comment(comment)
            print('OK')

        #+++ Finish PT story
        sys.stdout.write('Updating Pivotal Tracker ... ')
        if story.is_finished():
            sys.stdout.write('story already finished, skipping ... ')
        else:
            sys.stdout.write('finishing %s ... ' % story.get_id())
            story.finish()
        print 'OK'
コード例 #2
0
ファイル: __init__.py プロジェクト: charness/gitflow
 def run_finish(args):
     gitflow = GitFlow()
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('finishing feature branch %s' % name)
     gitflow.finish('feature', name,
                    fetch=args.fetch, rebase=args.rebase,
                    keep=args.keep, force_delete=args.force_delete,
                    tagging_info=None)
コード例 #3
0
ファイル: __init__.py プロジェクト: charness/gitflow
 def run_publish(args):
     gitflow = GitFlow()
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('publishing feature branch %s' % name)
     branch = gitflow.publish('feature', name)
     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()
コード例 #4
0
 def run_publish(args):
     gitflow = GitFlow()
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('publishing feature branch %s' % name)
     branch = gitflow.publish('feature', name)
     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
コード例 #5
0
 def run_finish(args):
     gitflow = GitFlow()
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('finishing feature branch %s' % name)
     gitflow.finish('feature',
                    name,
                    fetch=args.fetch,
                    rebase=args.rebase,
                    keep=args.keep,
                    force_delete=args.force_delete,
                    tagging_info=None)
コード例 #6
0
ファイル: __init__.py プロジェクト: tvoyle/gitflow
 def run_publish(args):
     gitflow = GitFlow()
     git = gitflow.git
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('publishing feature branch %s' % name)
     branch = gitflow.publish('feature', name)
     print(branch)
     base_marker = gitflow.managers['feature'].base_marker_name(str(branch))
     git.push(gitflow.origin_name(), base_marker)
     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
コード例 #7
0
ファイル: __init__.py プロジェクト: tvoyle/gitflow
 def run_publish(args):
     gitflow = GitFlow()
     git     = gitflow.git
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('publishing feature branch %s' % name)
     branch = gitflow.publish('feature', name)
     print(branch)
     base_marker = gitflow.managers['feature'].base_marker_name(str(branch))
     git.push(gitflow.origin_name(), base_marker)
     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
コード例 #8
0
ファイル: __init__.py プロジェクト: charness/gitflow
 def run_rebase(args):
     gitflow = GitFlow()
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('rebasing feature branch %s' % name)
     gitflow.rebase('feature', name, args.interactive)
コード例 #9
0
ファイル: __init__.py プロジェクト: charness/gitflow
 def run_diff(args):
     gitflow = GitFlow()
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('diff for feature branch %s' % name)
     gitflow.diff('feature', name)
コード例 #10
0
ファイル: __init__.py プロジェクト: charness/gitflow
 def run_checkout(args):
     gitflow = GitFlow()
     # NB: Does not default to the current branch as `nameprefix` is required
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('checking out feature branch %s' % name)
     gitflow.checkout('feature', name)
コード例 #11
0
ファイル: __init__.py プロジェクト: tvoyle/gitflow
    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'
コード例 #12
0
 def run_rebase(args):
     gitflow = GitFlow()
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('rebasing feature branch %s' % name)
     gitflow.rebase('feature', name, args.interactive)
コード例 #13
0
 def run_diff(args):
     gitflow = GitFlow()
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('diff for feature branch %s' % name)
     gitflow.diff('feature', name)
コード例 #14
0
 def run_checkout(args):
     gitflow = GitFlow()
     # NB: Does not default to the current branch as `nameprefix` is required
     name = gitflow.nameprefix_or_current('feature', args.nameprefix)
     gitflow.start_transaction('checking out feature branch %s' % name)
     gitflow.checkout('feature', name)
コード例 #15
0
ファイル: __init__.py プロジェクト: tvoyle/gitflow
    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'
コード例 #16
0
ファイル: test_core.py プロジェクト: OBdA/gitflow
 def test_gitflow_nameprefix_or_current_expands_prefix(self):
     gitflow = GitFlow(self.repo).init()
     # gitflow.init checks out `devel` branch :-(
     self.repo.branches['feat/recursion'].checkout()
     self.assertEqual(gitflow.nameprefix_or_current('feature', 'e'), 'even')
コード例 #17
0
 def test_gitflow_nameprefix_or_current_expands_prefix(self):
     gitflow = GitFlow(self.repo).init()
     # gitflow.init checks out `devel` branch :-(
     self.repo.branches['feat/recursion'].checkout()
     self.assertEqual(gitflow.nameprefix_or_current('feature', 'e'), 'even')
コード例 #18
0
ファイル: __init__.py プロジェクト: tvoyle/gitflow
    def run_finish(args):
        gitflow = GitFlow()
        repo = gitflow.repo
        git = repo.git

        f_prefix = gitflow.get_prefix('feature')
        name = gitflow.nameprefix_or_current('feature', args.nameprefix)
        full_name = f_prefix + name

        #+++ PT story stuff
        sys.stdout.write('Getting data from Pivotal Tracker ... ')
        story_id = pivotal.get_story_id_from_branch_name('feature', name)
        story = pivotal.Story(story_id)
        release = story.get_release()
        print 'OK'

        # Decide on the upstream branch.
        if release:
            # Merge into the release branch.
            r_prefix = gitflow.get_prefix('release')
            short_name = gitflow.nameprefix_or_current('release', release)
            upstream = r_prefix + short_name
        else:
            # Merge into the develop branch.
            upstream = gitflow.develop_name()

        # Fail as soon as possible if something is not right so that we don't
        # get Pivotal Tracker into an inconsistent state.
        rev_range = [
            get_feature_ancestor(full_name, upstream),
            repo.commit(full_name).hexsha
        ]

        #+++ Git manipulation
        sys.stdout.write('Finishing feature branch ... upstream %s ... ' \
                         % upstream)
        gitflow.finish('feature',
                       name,
                       upstream=upstream,
                       fetch=True,
                       rebase=args.rebase,
                       keep=True,
                       force_delete=args.force_delete,
                       tagging_info=None,
                       push=(not args.no_push))
        print 'OK'

        #+++ Review Request
        if not args.no_review:
            sys.stdout.write('Posting review ... upstream %s ... ' % upstream)
            review = BranchReview.from_identifier('feature', name, rev_range)
            review.post(story,
                        summary_from_story=(not args.summary_from_commit))
            print('OK')

            sys.stdout.write(
                'Posting code review url into Pivotal Tracker ... ')
            comment = 'New patch was uploaded into Review Board: ' + review.get_url(
            )
            story.add_comment(comment)
            print('OK')

        #+++ Finish PT story
        sys.stdout.write('Updating Pivotal Tracker ... ')
        if story.is_finished():
            sys.stdout.write('story already finished, skipping ... ')
        else:
            sys.stdout.write('finishing %s ... ' % story.get_id())
            story.finish()
        print 'OK'