def test_gitflow_init_creates_initial_commit(self): repo = create_git_repo(self) all_commits_before_init = all_commits(repo) gitflow = GitFlow(repo).init() all_commits_after_init = all_commits(repo) self.assertNotEquals(all_commits_before_init, all_commits_after_init) self.assertEquals('Initial commit', repo.heads.master.commit.message)
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))
def test_gitflow_cloned_sample_repo_equals_remote(self): # only the active branch (feat/recursion) is cloned which # includes devel and stable heads_to_check = [h.name for h in self.remote.heads] heads_to_check.remove('feat/even') self.assertIn('devel', heads_to_check) self.assertIn('stable', heads_to_check) all_remote_commits = all_commits(self.remote, heads_to_check) all_cloned_commits = all_commits(self.repo) self.assertEqual(all_remote_commits, all_cloned_commits)
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)
def test_create_release_fetch_from_remote_branch_behind_really_fetches(self): rfc0 = self.remote.refs['rel/1.0'].commit # add a commit to remote rel/1.0 branch self.remote.refs['rel/1.0'].checkout() change = fake_commit(self.remote, "Yet another 1.0 commit.") gitflow = GitFlow(self.repo).init() mgr = ReleaseBranchManager(gitflow) mgr.create('1.0', fetch=True) # must not advance rel/1.0 self.assertEqual(self.repo.refs['rel/1.0'].commit, rfc0) # change must nor be in local repo self.assertNotIn(change, all_commits(self.repo))
def test_create_release_from_remote_branch_behind(self): # If BranchManager.create() uses `update`, this test-case has # to be adopted, since since `update` change the cloned repo. rfc0 = self.remote.refs['rel/1.0'].commit # add a commit to remote rel/1.0 branch self.remote.refs['rel/1.0'].checkout() change = fake_commit(self.remote, "Yet another 1.0 commit.") gitflow = GitFlow(self.repo).init() mgr = ReleaseBranchManager(gitflow) mgr.create('1.0') # does not advance rel/1.0, since create() uses `fetch`, not `update` self.assertEqual(self.repo.refs['rel/1.0'].commit, rfc0) # change must not be in local repo, since create() uses `fetch`, not `update` self.assertNotIn(change, all_commits(self.repo))
def test_create_release_from_remote_branch_with_develop_behind(self): # If BranchManager.create() uses `update`, this test-case has # to be adopted, since `update` changes the cloned repo. rfc0 = self.remote.refs['rel/1.0'].commit rdc0 = self.remote.refs['devel'].commit # add a commit to remote develop branch self.remote.refs['devel'].checkout() change = fake_commit(self.remote, "Yet another develop commit.") gitflow = GitFlow(self.repo).init() mgr = ReleaseBranchManager(gitflow) mgr.create('1.0') # must not advance develop nor rel/1.0 self.assertEqual(self.repo.refs['rel/1.0'].commit, rfc0) self.assertEqual(self.repo.refs['devel'].commit, rdc0) # change must not be in local repo self.assertNotIn(change, all_commits(self.repo))
def test_gitflow_pull_non_existing_feature_raises_error(self): all_remote_commits_before_change = all_commits(self.remote) gitflow = GitFlow(self.repo).init() self.assertRaisesRegexp(GitCommandError, "Couldn't find remote ref ", gitflow.pull, 'feature', 'my-remote', 'i-am-not-here')
def test_gitflow_init_cloned_creates_no_extra_commits(self): all_commits_before_init = all_commits(self.repo) gitflow = GitFlow(self.repo).init() all_commits_after_init = all_commits(self.repo) self.assertEquals(all_commits_before_init, all_commits_after_init)
def test_gitflow_pull_non_existing_feature_raises_error(self): all_remote_commits_before_change = all_commits(self.remote) gitflow = GitFlow(self.repo).init() self.assertRaisesRegexp( GitCommandError, "Couldn't find remote ref ", gitflow.pull, 'feature', 'my-remote', 'i-am-not-here')