示例#1
0
文件: sticky.py 项目: dmore/jig
    def process(self, argv):
        with self.out() as out:
            templates_directory = create_auto_init_templates(expanduser('~'))

            set_templates_directory(templates_directory)

            out.append('Jig has been setup to run everytime you clone.')
示例#2
0
    def process(self, argv):
        with self.out() as out:
            templates_directory = create_auto_init_templates(expanduser('~'))

            set_templates_directory(templates_directory)

            out.append('Jig has been setup to run everytime you clone.')
示例#3
0
    def test_init_templatedir_already_set(self):
        """
        Will raise an exception if the config already has init.templatedir set.
        """
        git.cmd.Git().config(
            '--global', '--add', 'init.templatedir', '/tmp/templates'
        )

        with self.assertRaises(InitTemplateDirAlreadySet):
            set_templates_directory(self.templates_directory)
示例#4
0
    def test_sets_templatedir(self):
        """
        Will set the templatedir.
        """
        set_templates_directory(self.templates_directory)

        config = git.cmd.Git().config('--global', '--list')

        self.assertIn(
            'init.templatedir',
            config
        )

        self.assertIn(
            self.templates_directory,
            config
        )
示例#5
0
    def test_error_reading_git_config(self):
        """
        Raises an exception if there are problems reading the Git config.
        """
        with patch('jig.gitutils.hooking.git.cmd') as mock_cmd:
            mock_command = Mock()
            mock_command.config.side_effect = git.exc.GitCommandError(
                'git config', 1, 'error'
            )

            mock_cmd.Git.return_value = mock_command

            with self.assertRaises(GitConfigError) as gce:
                set_templates_directory(self.templates_directory)

        self.assertEqual(
            u'Problem when running git config: error',
            unicode(gce.exception)
        )
示例#6
0
    def test_raises_exception_if_cannot_write(self):
        """
        Raises an exception if it can't write to the Git config.
        """
        side_effects = [
            '',
            git.exc.GitCommandError('', 1, 'error')
        ]

        def config(*args, **kwargs):
            se = side_effects.pop(0)
            if isinstance(se, Exception):
                raise se
            else:
                return se

        with patch('jig.gitutils.hooking.git.cmd') as mock_cmd:
            mock_command = Mock()
            mock_command.config.side_effect = config
            mock_cmd.Git.return_value = mock_command

            with self.assertRaises(GitConfigError):
                set_templates_directory(self.templates_directory)