예제 #1
0
 def test_finish_feature_keep(self):
     gitflow = GitFlow(self.repo)
     mgr = FeatureBranchManager(gitflow)
     mgr.finish('even', keep=True)
     # feature branch still exists
     self.assertIn('feat/even',
             [b.name for b in self.repo.branches])
예제 #2
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')
예제 #3
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])
예제 #4
0
    def test_finish_release_unresolved_merge_conflict(self):
        gitflow = GitFlow(self.repo).init()
        fmgr = FeatureBranchManager(gitflow)
        fmgr.finish('even')
        fake_commit(self.repo, 'Overwrite version', filename='VERSION')

        mgr = ReleaseBranchManager(gitflow)
        self.assertRaises(MergeError,
                          mgr.finish, '1.0')
        # do not resolve, but finish again
        self.assertRaises(GitCommandError,
                          mgr.finish, '1.0')
예제 #5
0
    def test_finish_release_merge_conflict(self):
        gitflow = GitFlow(self.repo).init()
        fmgr = FeatureBranchManager(gitflow)
        fmgr.finish('even')
        fake_commit(self.repo, 'Overwrite version', filename='VERSION')

        mgr = ReleaseBranchManager(gitflow)
        self.assertRaises(MergeError, mgr.finish, '1.0')
        # resolve the conflict
        gitflow.git.rm('VERSION')
        gitflow.git.commit('-F.git/MERGE_MSG')
        # the release branch is still here
        self.assertIn('rel/1.0', [b.name for b in self.repo.branches])
        mgr.finish('1.0')
        # now the release branch is gone
        self.assertNotIn('rel/1.0', [b.name for b in self.repo.branches])
예제 #6
0
 def test_finish_feature_merge_conflict(self):
     gitflow = GitFlow(self.repo).init()
     mgr = FeatureBranchManager(gitflow)
     mgr.finish('recursion')
     self.assertRaises(MergeError,
                       mgr.finish, 'even')
     # resolve the conflict
     gitflow.git.rm('odd.py')
     gitflow.git.commit('-F.git/MERGE_MSG')
     # the feature branch is still here
     self.assertIn('feat/even',
             [b.name for b in self.repo.branches])
     mgr.finish('even')
     # now the feature branch is gone
     self.assertNotIn('feat/even',
             [b.name for b in self.repo.branches])
예제 #7
0
    def test_finish_release_merge_conflict_tag(self):
        """
        finish + tag with merge-conflicts on develop
        """
        version_filename = 'VERSION'
        new_version = '1.1\n'

        gitflow = GitFlow(self.repo).init()
        fmgr = FeatureBranchManager(gitflow)
        fmgr.finish('even')
        fake_commit(self.repo, 'Overwrite version',
                    filename=version_filename,
                    change=new_version)

        # verify that the tag does not yet exist
        # "v" comes form "versiontag" prefix in the gitflow config for the "release" fixture
        self.assertNotIn('v1.0', self.repo.tags)

        mgr = ReleaseBranchManager(gitflow)
        taginfo = dict(
            message='Tagging version 1.0',
        )
        self.assertRaises(MergeError,
                          mgr.finish, '1.0', tagging_info=taginfo)

        # verify that the tag exists, even though there was a failed merge
        self.assertIn('v1.0', self.repo.tags)

        # resolve the conflict
        # this is in favor of the change on develop
        write_file(filename=version_filename,
                   append=False,
                   change=new_version)
        gitflow.git.add(version_filename)
        gitflow.git.commit('-F.git/MERGE_MSG')
        # the release branch is still here
        self.assertIn('rel/1.0',
                      [b.name for b in self.repo.branches])
        # finish the release again
        # this should skip the tagging, since that part previously succeeded
        mgr.finish('1.0', tagging_info=taginfo)
        # now the release branch is gone
        self.assertNotIn('rel/1.0',
                         [b.name for b in self.repo.branches])

        # verify that the tag still exists
        self.assertIn('v1.0', self.repo.tags)
예제 #8
0
    def test_finish_feature(self):
        gitflow = GitFlow(self.repo)
        mgr = FeatureBranchManager(gitflow)

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

        # Feature finishes don't advance master, but develop
        self.assertEqual(mc0, mc1)
        self.assertNotEqual(dc0, dc1)

        # Finishing removes the feature branch
        self.assertNotIn('feat/even', [b.name for b in self.repo.branches])

        # Merge commit message
        self.assertEquals('Finished feature even.\n', dc1.message)
예제 #9
0
    def test_finish_release_merge_conflict(self):
        gitflow = GitFlow(self.repo).init()
        fmgr = FeatureBranchManager(gitflow)
        fmgr.finish('even')
        fake_commit(self.repo, 'Overwrite version', filename='VERSION')

        mgr = ReleaseBranchManager(gitflow)
        self.assertRaises(MergeError,
                          mgr.finish, '1.0')
        # resolve the conflict
        gitflow.git.rm('VERSION')
        gitflow.git.commit('-F.git/MERGE_MSG')
        # the release branch is still here
        self.assertIn('rel/1.0',
                [b.name for b in self.repo.branches])
        mgr.finish('1.0')
        # now the release branch is gone
        self.assertNotIn('rel/1.0',
                [b.name for b in self.repo.branches])
예제 #10
0
    def test_finish_feature(self):
        gitflow = GitFlow(self.repo)
        mgr = FeatureBranchManager(gitflow)

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

        # Feature finishes don't advance master, but develop
        self.assertEqual(mc0, mc1)
        self.assertNotEqual(dc0, dc1)

        # Finishing removes the feature branch
        self.assertNotIn('feat/even',
                [b.name for b in self.repo.branches])

        # Merge commit message
        self.assertEquals('Finished feature even.\n', dc1.message)
예제 #11
0
    def test_finish_release_merge_conflict_tag(self):
        """
        finish + tag with merge-conflicts on develop
        """
        version_filename = 'VERSION'
        new_version = '1.1\n'

        gitflow = GitFlow(self.repo).init()
        fmgr = FeatureBranchManager(gitflow)
        fmgr.finish('even')
        fake_commit(self.repo,
                    'Overwrite version',
                    filename=version_filename,
                    change=new_version)

        # verify that the tag does not yet exist
        # "v" comes form "versiontag" prefix in the gitflow config for the "release" fixture
        self.assertNotIn('v1.0', self.repo.tags)

        mgr = ReleaseBranchManager(gitflow)
        taginfo = dict(message='Tagging version 1.0', )
        self.assertRaises(MergeError, mgr.finish, '1.0', tagging_info=taginfo)

        # verify that the tag exists, even though there was a failed merge
        self.assertIn('v1.0', self.repo.tags)

        # resolve the conflict
        # this is in favor of the change on develop
        write_file(filename=version_filename, append=False, change=new_version)
        gitflow.git.add(version_filename)
        gitflow.git.commit('-F.git/MERGE_MSG')
        # the release branch is still here
        self.assertIn('rel/1.0', [b.name for b in self.repo.branches])
        # finish the release again
        # this should skip the tagging, since that part previously succeeded
        mgr.finish('1.0', tagging_info=taginfo)
        # now the release branch is gone
        self.assertNotIn('rel/1.0', [b.name for b in self.repo.branches])

        # verify that the tag still exists
        self.assertIn('v1.0', self.repo.tags)
예제 #12
0
    def test_finish_feature_push(self):
        remote =  GitFlow(self.remote).init()
        gitflow = GitFlow(self.repo).init()

        rmc0 = remote.master().commit
        rdc0 = remote.develop().commit
        mc0 = gitflow.master().commit
        dc0 = gitflow.develop().commit

        mgr = FeatureBranchManager(gitflow)
        mgr.create('even')
        mgr.finish('even', push=True)

        rmc1 = remote.master().commit
        rdc1 = remote.develop().commit
        mc1 = gitflow.master().commit
        dc1 = gitflow.develop().commit

        # Feature finishes don't advance remote master, but remote develop
        self.assertEqual(rmc0, rmc1)
        self.assertNotEqual(rdc0, rdc1)
        self.assertEqual(mc0, mc1)
        self.assertNotEqual(dc0, dc1)

        # local and remote heads must be the same again
        self.assertEqual(rmc1, mc1)
        self.assertEqual(rdc1, dc1)

        # Finishing removes the local and the remote feature branch
        self.assertNotIn('feat/even',
                [b.name for b in self.repo.branches])
        self.assertNotIn('feat/even',
                [b.name for b in self.remote.branches])

        # Merge commit message
        self.assertEquals('Finished feature even.\n', rdc1.message)
예제 #13
0
 def test_finish_feature_keep(self):
     gitflow = GitFlow(self.repo)
     mgr = FeatureBranchManager(gitflow)
     mgr.finish('even', keep=True)
     # feature branch still exists
     self.assertIn('feat/even', [b.name for b in self.repo.branches])