def test_create_new_hotfix_branch_non_default_prefix(self): gitflow = GitFlow(self.repo).init() mgr = HotfixBranchManager(gitflow) new_branch = mgr.create('1.2.3') self.assertEqual('hf/1.2.3', mgr.list()[0].name) self.assertEqual(new_branch.commit, gitflow.repo.branches['stable'].commit)
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)
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)
def test_hotfix_branch_origin(self): gitflow = GitFlow() mgr = HotfixBranchManager(gitflow) new_branch = mgr.create('3.14-beta5') self.assertEqual(new_branch.commit, gitflow.repo.branches['stable'].commit)
def test_empty_repo_has_no_hotfixes(self): repo = create_git_repo(self) gitflow = GitFlow(repo) mgr = HotfixBranchManager(gitflow) self.assertItemsEqual([], mgr.list())
def test_full_name(self): gitflow = GitFlow(self.repo) fb = HotfixBranchManager(gitflow) self.assertEquals('hf/foo', fb.full_name('foo')) self.assertEquals('hf/hotfix/foo', fb.full_name('hotfix/foo'))
def test_shorten(self): gitflow = GitFlow(self.repo) fb = HotfixBranchManager(gitflow) self.assertEquals('foo', fb.shorten('hf/foo')) self.assertEquals('hotfix/foo', fb.shorten('hotfix/foo'))