Exemplo n.º 1
0
    def test_should_not_pop_stash_on_failure(self):
        from sh import echo

        git_touch_add_commit('foo', 'bar', 'moo')
        foo_commit, _ = git_log_oneline()[2]

        echo('bar', _out='bar')
        echo('moo', _out='moo')
        git('add', 'bar')

        expected = {
            'bar': 'M ',
            'moo': ' M'
        }
        self.assertEqual(expected, git_status())

        with self.assertRaises(GitRebaseFailed):
            fix(foo_commit)

        status = {
            'bar': 'DU'
        }
        self.assertEqual(status, git_status())

        self.assertEqual(1, git_stash_len())

        actual = git_show('HEAD')['subject']
        expected = git_show(foo_commit)['subject']
        self.assertEqual(expected, actual)
Exemplo n.º 2
0
    def test_should_rebase_by_default(self):
        from sh import touch

        touch('foo')
        git('add', 'foo')
        fix('HEAD')

        actual = git_show('HEAD')['subject']
        expected = 'commit1'
        self.assertEqual(expected, actual)
Exemplo n.º 3
0
    def test_should_create_fixup_commit(self):
        from sh import touch

        git_commit_empty('foo')
        touch('foo')
        git('add', 'foo')
        fix('-n', 'HEAD')

        actual = git_show('HEAD')['subject']
        expected = 'fixup! foo'
        self.assertEqual(expected, actual)
Exemplo n.º 4
0
    def test_should_rollback_on_failure_if_requested(self):
        from sh import echo

        git_touch_add_commit('foo', 'bar')
        foo_commit, _ = git_log_oneline()[1]
        echo('bar', _out='bar')
        git('add', 'bar')

        with self.assertRaises(GitRebaseFailed):
            with git_state_invariant():
                fix('--atomic', foo_commit)
Exemplo n.º 5
0
    def test_should_stash_changes(self):
        from sh import touch

        touch('foo')
        git('add', 'foo')
        touch('bar')

        status = {
            'foo': 'A ',
            'bar': '??'
        }
        self.assertEqual(status, git_status())

        fix('HEAD')

        status = {
            'bar': '??'
        }
        self.assertEqual(status, git_status())

        actual = git_show('HEAD')['subject']
        expected = 'commit1'
        self.assertEqual(expected, actual)
Exemplo n.º 6
0
 def test_should_fail_if_called_with_invalid_commit(self):
     with self.assertRaises(CommitNotFound):
         fix('banana')
Exemplo n.º 7
0
 def test_should_fail_if_called_outside_of_git_repo(self):
     with self.assertRaises(NotAGitRepository):
         fix('banana')