Beispiel #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')
Beispiel #2
0
 def test_gitflow_track_creates_tracking_branch(self):
     gitflow = GitFlow(self.repo).init()
     gitflow.track('feature', 'even')
     self.assertEqual(self.repo.active_branch.name, 'feat/even')
     self.assertTrue(self.repo.active_branch.tracking_branch())
     self.assertEqual(self.repo.refs['feat/even'].tracking_branch(),
                      gitflow.origin().refs['feat/even'])
Beispiel #3
0
    def run_release(args):
        assert args.version
        assert args.environ
        pivotal.check_version_format(args.version)

        gitflow = GitFlow()

        # Fetch remote refs.
        if not args.no_fetch:
            sys.stderr.write('Fetching origin ... ')
            gitflow.origin().fetch()
            print('OK')

        # Check the environ argument.
        branch = GitFlow().managers['release'].full_name(args.version)
        if args.environ not in ('qa', 'client'):
            raise DeploymentRequestError(branch, args.environ)

        if args.environ == 'client' and not args.no_check:
            #+++ Check if all stories were accepted by the client
            pt_release = pivotal.Release(args.version)
            print('Checking Pivotal Tracker stories ... ')
            pt_release.try_stage()
            print('OK')

            #+++ Check all relevant review requests in Review Board, to be sure
            rb_release = review.Release(pt_release)
            print('Checking if all relevant stories have been reviewed ... ')
            rb_release.try_stage(args.ignore_missing_reviews)
            print('OK')

        DeployCommand._run_deploy(args)
Beispiel #4
0
    def test_finish_hotfix(self):
        gitflow = GitFlow(self.repo)
        mgr = HotfixBranchManager(gitflow)
        mgr.create('1.2.3')
        fake_commit(self.repo, 'Bogus commit')
        fake_commit(self.repo, 'Foo commit')
        fake_commit(self.repo, 'Fake commit')
        fake_commit(self.repo, 'Dummy commit')

        mc0 = gitflow.master().commit
        dc0 = gitflow.develop().commit
        mgr.finish('1.2.3')
        mc1 = gitflow.master().commit
        dc1 = gitflow.develop().commit

        # Hotfix finishes advance both master and develop
        self.assertNotEqual(mc0, mc1)
        self.assertNotEqual(dc0, dc1)

        # Finishing removes the hotfix branch
        self.assertNotIn('hf/1.2.3',
                [b.name for b in self.repo.branches])

        # Merge commit message
        self.assertEquals('Finished hotfix 1.2.3.\n', dc1.message)
Beispiel #5
0
 def test_gitflow_status_on_cloned_sample_repo(self):
     gitflow = GitFlow(self.repo)
     # NB: only the active branch is created locally when cloning
     self.assertEqual(self.remote.active_branch.name, 'feat/recursion')
     self.assertItemsEqual([
             ('feat/recursion', '54d59c872469c7bf34d540d2fb3128a97502b73f', True),
         ], gitflow.status())
Beispiel #6
0
 def test_gitflow_pull_really_pulls(self):
     gitflow = GitFlow(self.repo).init()
     self.remote.heads['feat/even'].checkout()
     change = fake_commit(self.remote, "Another commit")
     self.assertNotIn(change, all_commits(self.repo))
     gitflow.pull('feature', 'my-remote', 'even')
     self.assertIn(change, all_commits(self.repo))
Beispiel #7
0
 def test_gitflow_pull_existing_branch_creates_non_tracking_branch(self):
     gitflow = GitFlow(self.repo).init()
     # create local branch based on first commit
     new_branch = self.repo.create_head('feat/even', 'stable')
     new_branch.checkout()
     gitflow.pull('feature', 'my-remote', 'even')
     self.assertEqual(self.repo.active_branch.name, 'feat/even')
     self.assertEqual(self.repo.active_branch.tracking_branch(), None)
Beispiel #8
0
 def test_finish_unresolved_merge_conflict(self):
     gitflow = GitFlow(self.repo).init()
     gitflow.finish('feature', 'recursion', False, False, False, False, None)
     self.assertRaises(MergeError,
                       gitflow.finish, 'feature', 'even', False, False, False, False, None)
     # do not resolve, but finish again
     self.assertRaises(Usage,
                       gitflow.finish, 'feature', 'even', False, False, False, False, None)
Beispiel #9
0
 def test_finish_in_new_sandbox(self):
     sandbox = create_sandbox(self)
     gitflow = GitFlow(sandbox).init()
     gitflow.create('feature', 'wow-feature', base=None, fetch=False)
     self.assertEqual(gitflow.repo.active_branch.name, 'feature/wow-feature')
     fake_commit(gitflow.repo, 'Yet another commit')
     gitflow.finish('feature', 'wow-feature', False, False, False, False, None)
     self.assertNotIn('feature/wow-feature', gitflow.repo.branches)
Beispiel #10
0
 def run(args):
     gitflow = GitFlow()
     for name, hexsha, is_active_branch in gitflow.status():
         if is_active_branch:
             prefix = '*'
         else:
             prefix = ' '
         info('%s %s: %s' % (prefix, name, hexsha[:7]))
Beispiel #11
0
 def test_gitflow_status_on_remote_sample_repo(self):
     gitflow = GitFlow(self.remote)
     self.assertItemsEqual([
             ('stable', '296586bb164c946cad10d37e82570f60e6348df9', False),
             ('devel', '2b34cd2e1617e5f0d4e077c6ec092b9f50ed49a3', False),
             ('feat/recursion', '54d59c872469c7bf34d540d2fb3128a97502b73f', True),
             ('feat/even', 'e56be18dada9e81ca7969760ddea357b0c4c9412', False),
         ], gitflow.status())
Beispiel #12
0
    def test_gitflow_publish_creates_sets_tracking_branch(self):
        gitflow = GitFlow(self.repo).init()
        gitflow.create('feature', 'circular', 'devel', fetch=False)
        gitflow.publish('feature', 'circular')

        self.assertTrue(self.repo.branches['feat/circular'].tracking_branch())
        self.assertTrue(self.repo.branches['feat/circular'].tracking_branch().name,
                        'my-remote/feat/circular')
Beispiel #13
0
 def test_gitflow_init_inits_underlying_git_repo(self):
     sandbox = create_sandbox(self)
     gitflow = GitFlow(sandbox)
     dot_git_dir = os.path.join(sandbox, '.git')
     self.assertFalse(os.path.exists(dot_git_dir))
     gitflow.init()
     self.assertTrue(os.path.exists(dot_git_dir))
     self.assertTrue(gitflow.is_initialized())
Beispiel #14
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))
Beispiel #15
0
 def test_create_branches(self):
     repo = create_git_repo(self)
     gitflow = GitFlow(repo).init()
     gitflow.create('feature', 'foo', None, fetch=False)
     self.assertIn('feature/foo',
             [h.name for h in gitflow.repo.branches])
     gitflow.create('release', '1.0', None, fetch=False)
     self.assertIn('release/1.0',
             [h.name for h in gitflow.repo.branches])
Beispiel #16
0
def _release_version_with_git_flow(version_tag):
    from os import curdir
    from gitflow.core import GitFlow
    from gitpy import LocalRepository
    gitflow = GitFlow()
    gitflow.create("release", version_tag, base=None, fetch=False)
    gitflow.finish("release", version_tag, fetch=False, rebase=False, keep=False, force_delete=True,
                   tagging_info=dict(sign=False, message=version_tag))
    repository = LocalRepository(curdir)
Beispiel #17
0
 def _test_create_branches_from_alt_base(self):
     repo = create_git_repo(self)
     gitflow = GitFlow(repo).init()
     gitflow.create('feature', 'foo', 'master', fetch=False)
     self.assertIn('feature/foo',
             [h.name for h in gitflow.repo.branches])
     gitflow.repo.index.commit('Foo')
     gitflow.create('release', '1.0', 'feature/foo', fetch=False)
     self.assertIn('release/1.0',
             [h.name for h in gitflow.repo.branches])
Beispiel #18
0
 def test_config_reader(self):
     gitflow = GitFlow(self.repo).init()
     self.assertRaises(ValueError, gitflow.get,
             'invalid_setting_since_this_has_no_dot')
     self.assertRaises(NoSectionError, gitflow.get,
             'nonexisting.nonexisting')
     self.assertRaises(NoSectionError, gitflow.get,
             'section.subsection.propname')
     self.assertRaises(NoOptionError, gitflow.get, 'foo.nonexisting')
     self.assertEquals('qux', gitflow.get('foo.bar'))
Beispiel #19
0
 def test_gitflow_tag_signed_with_key(self):
     gitflow = GitFlow(self.repo).init()
     commit = self.repo.head.commit
     gitflow.tag('some-tag', commit, 'This is my tag', sign=True,
                 signingkey='Dummy Key for Gitflow testing')
     tag = self.repo.tags['some-tag'].tag
     expected = ['This is my tag', '-----BEGIN PGP SIGNATURE-----']
     self.assertEqual(tag.message.splitlines()[:2], expected)
     self.assertEqual(tag.tag, 'some-tag')
     self.assertEqual(tag.object, commit)
Beispiel #20
0
    def test_delete_feature_without_commits(self):
        gitflow = GitFlow(self.repo)
        mgr = FeatureBranchManager(gitflow)

        self.assertEquals(2, len(mgr.list()))
        mgr.create('foo')
        gitflow.develop().checkout()
        self.assertEquals(3, len(mgr.list()))
        mgr.delete('foo')
        self.assertEquals(2, len(mgr.list()))
        self.assertNotIn('feat/foo', [b.name for b in self.repo.branches])
Beispiel #21
0
 def run_track(args):
     gitflow = GitFlow()
     # NB: `args.name` is required since the branch must not yet exist
     gitflow.start_transaction('tracking remote feature branch %s'
                               % args.name)
     branch = gitflow.track('feature', args.name)
     print
     print "Summary of actions:"
     print "- A new remote tracking branch '%s' was created" % branch
     print "- You are now on branch '%s'" % branch
     print
Beispiel #22
0
 def run_track(args):
     gitflow = GitFlow()
     # NB: `args.version` is required since the branch must not yet exist
     gitflow.start_transaction('tracking remote release branch %s'
                               % args.version)
     branch = gitflow.track('release', args.version)
     print()
     print("Summary of actions:")
     print("- A new remote tracking branch '%s' was created" % branch)
     print("- You are now on branch '%s'" % branch)
     print()
Beispiel #23
0
    def test_delete_release_without_commits(self):
        gitflow = GitFlow(self.repo)
        mgr = ReleaseBranchManager(gitflow)

        self.assertEquals(0, len(mgr.list()))
        mgr.create('1.0')
        gitflow.develop().checkout()
        self.assertEquals(1, len(mgr.list()))
        mgr.delete('1.0')
        self.assertEquals(0, len(mgr.list()))
        self.assertNotIn('rel/1.0', [b.name for b in mgr.list()])
Beispiel #24
0
 def test_gitflow_tag_signed(self):
     gitflow = GitFlow(self.repo).init()
     # need to the the signing key via config
     gitflow.set('user.signingkey', 'Dummy Key for Gitflow testing')
     commit = self.repo.head.commit
     gitflow.tag('some-tag', commit, 'This is my tag', sign=True)
     tag = self.repo.tags['some-tag'].tag
     expected = ['This is my tag', '-----BEGIN PGP SIGNATURE-----']
     self.assertEqual(tag.message.splitlines()[:2], expected)
     self.assertEqual(tag.tag, 'some-tag')
     self.assertEqual(tag.object, commit)
Beispiel #25
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()
Beispiel #26
0
    def test_gitflow_publish_really_pushes(self):
        gitflow = GitFlow(self.repo).init()
        gitflow.create('feature', 'circular', 'devel', fetch=False)
        change = fake_commit(self.repo, "Another commit")
        all_local_commits = all_commits(self.repo)
        self.assertIn(change, all_local_commits)
        gitflow.publish('feature', 'circular')

        all_remote_commits = all_commits(self.remote)
        self.assertEqual(all_remote_commits, all_remote_commits)
        self.assertIn(change, all_remote_commits)
Beispiel #27
0
 def test_gitflow_tag_without_message(self):
     gitflow = GitFlow(self.repo).init()
     self.assertNotIn('some-tag', self.repo.tags)
     commit = self.repo.head.commit
     gitflow.tag('some-tag', commit)
     self.assertIn('some-tag', self.repo.tags)
     tagref = self.repo.tags['some-tag']
     self.assertEqual(tagref.commit, commit)
     self.assertEqual(tagref.name, 'some-tag')
     # if there is no message, tagref.tag is None
     self.assertEqual(tagref.tag, None)
Beispiel #28
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()
Beispiel #29
0
    def test_delete_release_with_commits_forcefully(self):
        gitflow = GitFlow(self.repo)
        mgr = ReleaseBranchManager(gitflow)

        self.assertEquals(0, len(mgr.list()))
        mgr.create('0.7')
        fake_commit(self.repo, 'A commit on the release branch.', append=False)
        gitflow.develop().checkout()
        self.assertEquals(1, len(mgr.list()))
        mgr.delete('0.7', force=True)
        self.assertEquals(0, len(mgr.list()))
        self.assertNotIn('rel/0.7', [b.name for b in self.repo.branches])
Beispiel #30
0
    def test_delete_release_with_commits_raises_error(self):
        gitflow = GitFlow(self.repo)
        mgr = ReleaseBranchManager(gitflow)

        self.assertEquals(0, len(mgr.list()))
        mgr.create('0.7')
        fake_commit(self.repo, 'A commit on the release branch.', append=False)
        gitflow.develop().checkout()
        self.assertEquals(1, len(mgr.list()))
        self.assertRaisesRegexp(GitCommandError,
                'The branch .* is not fully merged',
                mgr.delete, '0.7')
Beispiel #31
0
 def test_delete_current_release_raises_error(self):
     gitflow = GitFlow(self.repo)
     mgr = ReleaseBranchManager(gitflow)
     mgr.create('1.0').checkout()
     self.assertRaisesRegexp(
         GitCommandError,
         'Cannot delete the branch .* which you are currently on',
         mgr.delete, '1.0')
Beispiel #32
0
 def test_finish_release_rebase(self):
     repo = create_git_repo(self)
     gitflow = GitFlow(repo).init()
     mgr = ReleaseBranchManager(gitflow)
     mgr.create('1.0')
     self.assertRaisesRegexp(
         AssertionError, "does not make any sense",
         mgr.finish, '1.0', rebase=True)
Beispiel #33
0
 def test_create_new_feature_branch_non_default_prefix(self):
     gitflow = GitFlow(self.repo).init()
     mgr = FeatureBranchManager(gitflow)
     new_branch = mgr.create('foo')
     self.assertEqual(new_branch.name, 'feat/foo')
     self.assertIn('feat/foo', [b.name for b in mgr.list()])
     self.assertEqual(new_branch.commit,
             gitflow.repo.branches['devel'].commit)
Beispiel #34
0
    def test_finish_release_tag_push(self):
        # Since remote is no bare repo, checkout some branch untouched
        # by this operation. :fixme: find better solution
        self.remote.heads['feat/even'].checkout()
        gitflow = GitFlow(self.repo).init()

        mgr = ReleaseBranchManager(gitflow)
        mgr.create('1.0')
        taginfo = dict(message='Tagging version 1.0')
        mgr.finish('1.0', push=True, tagging_info=taginfo)
        mc1 = gitflow.master().commit
        # remote tag exists
        self.assertIn('v1.0', self.remote.tags)
        self.assertEqual(self.remote.tags['v1.0'].commit, mc1)
        # tag message
        self.assertEqual(self.remote.tags['v1.0'].tag.message,
                         'Tagging version 1.0')
Beispiel #35
0
 def test_feature_finish_rebase(self):
     gitflow = GitFlow('.').init()
     gitflow.develop().checkout()
     fake_commit(gitflow.repo, 'A commit on devel')
     runGitFlow('feature', 'finish', 'even', '--rebase')
     self.assertNotIn('feat/even', Repo().branches)
     self.assertEqual(gitflow.develop().commit.message,
                      'Finished feature even.\n')
Beispiel #36
0
 def test_gitflow_init_cloned_creates_no_extra_banches(self):
     heads_before_init = [h.name for h in self.repo.heads]
     heads_before_init.sort()
     gitflow = GitFlow(self.repo).init()
     heads_after_init = [h.name for h in self.repo.heads]
     heads_after_init.remove('stable')
     heads_after_init.remove('devel')
     self.assertItemsEqual(heads_before_init, heads_after_init)
Beispiel #37
0
 def test_gitflow_pull_existing_branch_while_on_other_branchtype_raises_error(
         self):
     gitflow = GitFlow(self.repo).init()
     # create local branch based on first commit
     new_branch = self.repo.create_head('feat/even', 'stable')
     self.assertRaisesRegexp(
         SystemExit, "To avoid unintended merges, git-flow aborted.",
         gitflow.pull, 'feature', 'my-remote', 'even')
Beispiel #38
0
 def test_create_new_release_branch_non_default_prefix(self):
     gitflow = GitFlow(self.repo).init()
     mgr = ReleaseBranchManager(gitflow)
     new_branch = mgr.create('3.14-beta5')
     self.assertEqual(new_branch.name, 'rel/3.14-beta5')
     self.assertIn('rel/3.14-beta5', [b.name for b in mgr.list()])
     self.assertEqual(new_branch.commit,
             gitflow.repo.branches['devel'].commit)
Beispiel #39
0
 def test_finish_release_tag(self):
     gitflow = GitFlow(self.repo)
     mgr = ReleaseBranchManager(gitflow)
     taginfo = dict(
         message = 'Tagging version 1.0'
         )
     mgr.finish('1.0', tagging_info=taginfo)
     mc1 = gitflow.master().commit
     dc1 = gitflow.develop().commit
     # master is merged back to develop
     self.assertIn(mc1, dc1.parents)
     # tag exists
     self.assertIn('v1.0', self.repo.tags)
     self.assertEqual(self.repo.tags['v1.0'].commit, mc1)
     # tag message
     self.assertEqual(self.repo.tags['v1.0'].tag.message,
                      'Tagging version 1.0')
Beispiel #40
0
 def test_has_merge_conflict(self):
     gitflow = GitFlow(self.repo).init()
     repo = gitflow.repo
     repo.refs['devel'].checkout()
     repo.git.merge('feat/recursion')
     # the next merge creates the merge conflict
     self.assertRaises(GitCommandError, repo.git.merge, 'feat/even')
     self.assertRaises(MergeConflict, gitflow.require_no_merge_conflict)
Beispiel #41
0
 def test_by_nameprefix_not_unique_enough(self):
     gitflow = GitFlow()
     mgr = ReleaseBranchManager(gitflow)
     # Create branch without manager since manager enforces there
     # is a single release branch.
     self.repo.create_head('rel/1.1', 'HEAD')
     self.assertRaises(PrefixNotUniqueError, mgr.by_name_prefix, '1.')
     self.assertRaises(NoSuchBranchError, mgr.by_name_prefix, 'nonexisting')
Beispiel #42
0
 def test_gitflow_init_cloned_creates_master_and_develop(self):
     heads_before_init = [h.name for h in self.repo.heads]
     self.assertNotIn('stable', heads_before_init)
     self.assertNotIn('devel', heads_before_init)
     gitflow = GitFlow(self.repo).init()
     heads_after_init = [h.name for h in self.repo.heads]
     self.assertIn('stable', heads_after_init)
     self.assertIn('devel', heads_after_init)
Beispiel #43
0
 def test_merge_conflict(self):
     gitflow = GitFlow(self.repo)
     mgr = FeatureBranchManager(gitflow)
     mgr.merge('recursion', 'devel')
     self.assertRaises(MergeError,
                       mgr.merge, 'even', 'devel')
     gitflow.git.rm('odd.py')
     gitflow.git.commit('-F.git/MERGE_MSG')
Beispiel #44
0
 def run_start(args):
     gitflow = GitFlow()
     # :fixme: Why does the sh-version not require a clean working dir?
     # NB: `args.name` is required since the branch must not yet exist
     # :fixme: get default value for `base`
     gitflow.start_transaction('create feature branch %s (from %s)' % \
             (args.name, args.base))
     try:
         branch = gitflow.create('feature',
                                 args.name,
                                 args.base,
                                 fetch=args.fetch)
     except (NotInitialized, BaseNotOnBranch):
         # printed in main()
         raise
     except Exception, e:
         die("Could not create feature branch %r" % args.name, e)
Beispiel #45
0
    def test_merge_feature_with_single_commit(self):
        gitflow = GitFlow(self.repo).init()
        mgr = FeatureBranchManager(gitflow)

        dc0 = gitflow.develop().commit
        mgr.merge('recursion', 'devel')
        dc1 = gitflow.develop().commit

        # Assert no merge commit has been made
        self.assertEqual(1, len(dc1.parents))
        self.assertEqual('Made the definition of odd recursive.\n',
                dc1.message)

        # Assert develop branch advanced
        self.assertNotEqual(dc0, dc1)
        # Assert the target-branch is active
        self.assertEqual(gitflow.repo.active_branch.name, 'devel')
Beispiel #46
0
    def test_create_release_changes_active_branch(self):
        repo = create_git_repo(self)
        gitflow = GitFlow(repo).init()
        mgr = ReleaseBranchManager(gitflow)

        self.assertEquals('develop', repo.active_branch.name)
        mgr.create('1.0')
        self.assertEquals('release/1.0', repo.active_branch.name)
Beispiel #47
0
    def test_create_new_release_from_alt_base(self):
        gitflow = GitFlow(self.repo)
        mgr = ReleaseBranchManager(gitflow)

        new_branch = mgr.create('1.0',
                'c8b6deac7ef94f078a426d52c0b1fb3e1221133c')  # devel~1
        self.assertEqual(new_branch.commit.hexsha,
                'c8b6deac7ef94f078a426d52c0b1fb3e1221133c')
Beispiel #48
0
    def test_merge_feature_with_multiple_commits(self):
        gitflow = GitFlow(self.repo)
        mgr = FeatureBranchManager(gitflow)

        dc0 = gitflow.develop().commit
        mgr.merge('even', 'devel')
        dc1 = gitflow.develop().commit

        # Assert merge commit has been made
        self.assertEqual(2, len(dc1.parents))
        self.assertTrue(
            dc1.message.startswith("Merge branch 'feat/even' into devel\n"))

        # Assert develop branch advanced
        self.assertNotEqual(dc0, dc1)
        # Assert the target-branch is active
        self.assertEqual(gitflow.repo.active_branch.name, 'devel')
Beispiel #49
0
    def test_detect_branch_types(self):
        create_git_repo(self)
        gitflow = GitFlow()

        # The types that "ship" with git-flow
        self.assertIn('feature', gitflow.managers)
        self.assertIn('release', gitflow.managers)
        self.assertIn('hotfix', gitflow.managers)
        self.assertIn('support', gitflow.managers)
Beispiel #50
0
 def test_gitflow_init_cloned_creates_no_custom_master_and_develop(self):
     heads_before_init = [h.name for h in self.repo.heads]
     self.assertNotIn('foo', heads_before_init)
     self.assertNotIn('bar', heads_before_init)
     gitflow = GitFlow(self.repo)
     self.assertRaises(NotImplementedError,
                       gitflow.init,
                       master='foo',
                       develop='bar')
Beispiel #51
0
 def test_gitflow_pull_while_on_same_branchtype_raises_error(self):
     gitflow = GitFlow(self.repo).init()
     # activate some feature branch
     new_branch = self.repo.create_head('feat/something', 'stable')
     new_branch.checkout()
     # try to pull another feature branch
     self.assertRaisesRegexp(
         SystemExit, "To avoid unintended merges, git-flow aborted.",
         gitflow.pull, 'feature', 'my-remote', 'my-name-is-irrelevant')
Beispiel #52
0
    def test_finish_feature_push_keep(self):
        gitflow = GitFlow(self.repo).init()
        mgr = FeatureBranchManager(gitflow)
        mgr.create('even')
        mgr.finish('even', push=True, keep=True)

        # Finishing removes the local and the remote feature branch
        self.assertIn('feat/even', [b.name for b in self.repo.branches])
        self.assertIn('feat/even', [b.name for b in self.remote.branches])
Beispiel #53
0
 def test_feature_list_verbose_no_commits(self):
     repo = create_git_repo(self)
     gitflow = GitFlow(repo).init()
     repo.create_head('feature/wow', 'HEAD')
     stdout = runGitFlow('feature', 'list', '--verbose', capture=1)
     expected = [
       '  wow (no commits yet)'
       ]
     self.assertEqual(stdout.splitlines(), expected)
Beispiel #54
0
 def test_finish_feature_unresolved_merge_conflict(self):
     gitflow = GitFlow(self.repo).init()
     mgr = FeatureBranchManager(gitflow)
     mgr.finish('recursion')
     self.assertRaises(MergeError,
                       mgr.finish, 'even')
     # do not resolve, but finish again
     self.assertRaises(GitCommandError,
                       mgr.finish, 'even')
Beispiel #55
0
 def test_empty_branch_type_list_raises_usage(self):
     create_git_repo(self)
     gitflow = GitFlow().init()
     self.assertRaises(Usage, gitflow.list, 'feature', 'name', False, False)
     self.assertRaises(Usage, gitflow.list, 'release', 'version', False,
                       False)
     self.assertRaises(Usage, gitflow.list, 'hotfix', 'version', False,
                       False)
     self.assertRaises(Usage, gitflow.list, 'support', 'version', False,
                       False)
Beispiel #56
0
    def test_detect_custom_branch_types(self):
        create_git_repo(self)

        # Declare a custom branch type inline
        class FooBarManager(BranchManager):
            identifier = 'foobar'
            DEFAULT_PREFIX = 'xyz/'

        gitflow = GitFlow()
        self.assertIn('foobar', gitflow.managers)
Beispiel #57
0
 def test_create_new_release_branch(self):
     repo = create_git_repo(self)
     gitflow = GitFlow(repo).init()
     mgr = ReleaseBranchManager(gitflow)
     self.assertEqual(0, len(mgr.list()))
     new_branch = mgr.create('3.14-beta5')
     self.assertEqual(1, len(mgr.list()))
     self.assertEqual('release/3.14-beta5', mgr.list()[0].name)
     self.assertEqual(new_branch.commit,
                      gitflow.repo.branches['develop'].commit)
Beispiel #58
0
 def test_create_new_feature_branch(self):
     repo = create_git_repo(self)
     gitflow = GitFlow(repo).init()
     mgr = FeatureBranchManager(gitflow)
     self.assertEqual(0, len(mgr.list()))
     new_branch = mgr.create('foo')
     self.assertEqual(1, len(mgr.list()))
     self.assertEqual('feature/foo', mgr.list()[0].name)
     self.assertEqual(new_branch.commit,
                      gitflow.repo.branches['develop'].commit)
Beispiel #59
0
 def test_create_new_support_branch(self):
     repo = create_git_repo(self)
     gitflow = GitFlow(repo).init()
     mgr = SupportBranchManager(gitflow)
     self.assertEqual(0, len(mgr.list()))
     new_branch = mgr.create('1.x')
     self.assertEqual(1, len(mgr.list()))
     self.assertEqual('support/1.x', mgr.list()[0].name)
     self.assertEqual(new_branch.commit,
                      gitflow.repo.branches['master'].commit)
Beispiel #60
0
 def test_create_new_hotfix_branch(self):
     repo = create_git_repo(self)
     gitflow = GitFlow(repo).init()
     mgr = HotfixBranchManager(gitflow)
     self.assertEqual(0, len(mgr.list()))
     new_branch = mgr.create('1.2.3')
     self.assertEqual(1, len(mgr.list()))
     self.assertEqual('hotfix/1.2.3', mgr.list()[0].name)
     self.assertEqual(new_branch.commit,
                      gitflow.repo.branches['master'].commit)