Example #1
0
    def test_dry_run_dirty(self):
        contents = [{'A': x} for x in range(5)] 
        common_commits = self.create_repos(2, contents)
        new_content = [{'A': x} for x in range(5, 10)]
        new_commits = self.create_commits(1, new_content)
        new_master_content = [{'A': 10}]
        new_master_commits = self.create_commits(0, new_master_content)

        with self.assertRaises(subject.PushFailure):
            subject.push(self.scratch[1], 'origin', ['master'])
Example #2
0
    def test_for_real_clean(self):
        contents = [{'A': x} for x in range(5)] 
        common_commits = self.create_repos(2, contents)
        new_content = [{'A': x} for x in range(5, 10)]
        new_commits = self.create_commits(1, new_content)
        subject.checkout(self.scratch[0], branch_name='notmaster')
        
        expected = {
            'url': os.path.abspath(self.scratch[0]),
            'branches':{
                'master': (common_commits[-1], new_commits[-1])
            }
        }
        actual = subject.push(self.scratch[1], 'origin', ['master'], dry_run=False)

        self.assertEqual(new_commits[0],
            subject.get_rev(self.scratch[0], new_commits[0][:7]))
Example #3
0
    def test_dry_run_clean(self):
        contents = [{'A': x} for x in range(5)] 
        common_commits = self.create_repos(2, contents)
        new_content = [{'A': x} for x in range(5, 10)]
        new_commits = self.create_commits(1, new_content)
        
        expected = {
            'url': os.path.abspath(self.scratch[0]),
            'branches':{
                'master': (common_commits[-1], new_commits[-1])
            }
        }
        actual = subject.push(self.scratch[1], 'origin', ['master'])
        self.assertEqual(expected['url'], actual['url'])
        self.assertEqual(expected['branches'], actual['branches'])
        self.assertEqual(expected, actual)

        with self.assertRaises(subject.GitError):
            # We chop the commit id down to 7 chars because this
            # forces git to not short-circuit and just echo the
            # full length id it's given.  This also seperates
            # the concern of the git repo having the commit object
            # from a branch having the commit object
            subject.get_rev(self.scratch[0], new_commits[0][:7])