Ejemplo n.º 1
0
    def test_clone(self):
        self.assertEqual('44dac6b', repo.make_commit('one.txt'))
        self.assertEqual('393ad1c', repo.make_commit('two.txt'))
        git.checkout('-b', 'working')

        with repo.clone('foo', 'bar'):
            expected = ['bar', 'foo', 'origin', 'upstream']
            self.assertEqual(sorted(safe_git.remote()), expected)
            git_functions.fetch('foo')
            git_functions.fetch('bar')
            actual = git_functions.branches('-r')
            expected = [
                'bar/master',
                'bar/working',
                'foo/master',
                'foo/working',
                'origin/master',
                'upstream/master',
            ]
            self.assertEqual(actual, expected)
            self.assertEqual('efc4ce6', repo.make_commit('three.txt'))
            git.push('foo', 'HEAD:working')
            self.assertEqual(
                git_functions.commit_id('bar/working'),
                '393ad1c265321cdf4d25661379a1fd6922933c40',
            )
            self.assertEqual(
                git_functions.commit_id('foo/working'),
                'efc4ce65521dbd7a2f410bcc782a088c4460afc5',
            )
Ejemplo n.º 2
0
    def test_update(self):
        repo.make_one_commit('file.txt', ORIGINAL, 'original')
        repo.make_one_commit('file.txt', DELTA3, 'master!')
        git.push('--set-upstream', 'upstream', 'master')
        git.reset('--hard', 'HEAD~')
        git.push('--set-upstream', 'origin', 'master')

        # No conflicts
        git.new('one')
        repo.make_commit('one')
        git.push()

        # Resolvable conflict
        git.new('two')
        repo.make_one_commit('file.txt', DELTA1, 'two')
        git.push()

        # Unresolvable conflict
        # TODO: this didn't work
        git.new('three')
        repo.make_one_commit('file.txt', DELTA2, 'three')
        git.push()

        # Local differs from origin
        git.new('four')
        repo.make_one_commit('file.txt', 'four', 'four')

        git.checkout('master')
        git.update('-v')

        base = ['d1b2fc8 master!', '28da9aa original', 'c0d1dbb 0']

        def test(branch, *items):
            actual = git.log('--oneline', branch)
            expected = list(items) + base
            self.assertEqual(expected, actual)

        test('master')
        test('origin/master')
        test('upstream/master')

        test('one', '2b7979a one')
        test('origin/one', '2b7979a one')

        test('two', '5478a38 two')
        test('origin/two', '5478a38 two')

        test('three', '6158500 three')
        test('origin/three', '6158500 three')

        test('four', '62584d2 four')
        test('origin/four', '62584d2 four')
Ejemplo n.º 3
0
    def test_new(self):
        git.new('one')
        repo.make_commit('1')
        git.push()
        actual = safe_git.log('--oneline', 'origin/one')
        expected = ['a03c0f8 1', 'c0d1dbb 0']
        self.assertEqual(actual, expected)

        git.new('two')
        repo.make_commit('2')
        git.push()
        actual = safe_git.log('--oneline', 'origin/two')
        expected = ['aff4d90 2', 'c0d1dbb 0']
        self.assertEqual(actual, expected)
Ejemplo n.º 4
0
    def test_delete(self):
        git.new('one')
        repo.make_commit('1')
        git.push()

        git.new('two')
        repo.make_commit('2')
        git.push()

        actual = git_functions.branches('-r')
        expected = [
            'origin/master',
            'origin/one',
            'origin/two',
            'upstream/master',
        ]
        self.assertEqual(actual, expected)

        git.delete('one', 'two')
        actual = git_functions.branches('-r')
        expected = ['origin/master', 'upstream/master']
        self.assertEqual(actual, expected)
Ejemplo n.º 5
0
    def test_stripe(self):
        repo.make_commit('1')
        repo.make_commit('2')
        repo.make_commit('3')
        repo.make_commit('4')

        git.push('-u', 'origin', 'master')
        git.stripe()

        actual = git_functions.branches('-r')
        expected = [
            'origin/_gitz_stripe_0',
            'origin/_gitz_stripe_1',
            'origin/_gitz_stripe_2',
            'origin/master',
            'upstream/master',
        ]
        self.assertEqual(actual, expected)

        git.stripe('-d')
        actual = git_functions.branches('-r')
        expected = ['origin/master', 'upstream/master']
        self.assertEqual(actual, expected)